| New Reply |
Thoughts on C++ |
Share Thread |
| Oct20-12, 10:35 PM | #1 |
|
|
Thoughts on C++
I am taking C++ this semester, and am not really good at it. It is my first programming class, and I kind of stink, though I am trying. I don't think I'm going to get a great grade, and it will bring down my average. I was thinking of dropping it, but then had a look at the class averages...most are MUCH lower than mine, and I'm a little startled. Is C++ just a hard language to learn, or am I in a class of total slackers? If the former, maybe I should hold on to my not-so-great grade and be happy it's not worse. But if the latter, I might be better off trying again later. Any advice appreciated from those who have experience with C++. TIA.
|
| Oct20-12, 11:25 PM | #2 |
|
Mentor
|
I don't think it's C++ per se that's difficult, it's computer programming in general. I taught introductory programming courses for many years, first Fortran, then Pascal and finally C++. A few students always "got" programming quickly, but most of the rest struggled to get used to it, at least at first. Some people need more practice than others, regardless of the language.
Also, programming requires two very different skills. First, the ability to take a "real-world" problem statement and convert it into a step-by-step algorithm for solving it. Second, the "nuts and bolts" of coding: getting the syntax right, using your programming tools (IDE or command line), and debugging. These two things are often done by different people in a programming shop, because people are often better at one than the other. |
| Oct20-12, 11:36 PM | #3 |
|
|
Thanks for your input. I immediately noticed from your description that my issue is with the "nuts and bolts" part...it is amazing to me to be so undermined by minor details. If it is an adjustment for most, I will try to hang in there and do better:)
|
| Oct20-12, 11:41 PM | #4 |
|
|
Thoughts on C++
Hey andryd9.
In addition to jtbells advice, I would say that once you know the programming mindset, learning the specifics is not much of a quantum leap. In programming there are two main things that you need to keep in your mind and those are state and flow-control. State is the state of the machine and flow-control is the flow of execution (i.e. how instructions get executed). Basically in programming you use time, a lot of fumbling around, and experience to build these up in a gradual fashion. At first you only look at a few variables, then you look at entire classes then modules, then entire libraries and finally entire repositories with many external libraries, and particular parts that make up the whole and inter-connect together. With flow-control it's the same deal. You start with simple programs then you introduce branching, functions, recursion, and then use language specific features to affect control like constructors and other similar things (which are a part of C++). You then start to look at multi-threaded and parallel environments and look at the issues regarding this, as well as operating systems and specific platforms, as well as message passing and event systems (or callbacks) and other kinds of flow-control. These two things are then related to the language, the platform, the data and how its described and the meta-data that helps aid all this functionality with regard to the language, application, run-time environment and so on. Every single program has its own way of doing things and each one is designed for a particular reason: it doesn't matter if its a C++ program or a PHP script, they all require you to understand the state and flow-control and when you recognize these then the whole thing makes sense and you know what is going on. |
| Oct21-12, 01:57 AM | #5 |
|
|
|
| Oct21-12, 02:46 AM | #6 |
|
|
I'm in a similar situation too, and trying to get my head around the language. A book I have found useful is 'Thinking in C++' by Bruce Eckel. There is a free electronic version of this online.
Good luck, and persevere! |
| Oct21-12, 02:52 AM | #7 |
|
|
But after a while you will see the code in your head and you will see things that you didn't see before just like with anything and when you get to that stage, you will (if you choose to) start to master it by dealing with things with greater complexity and scope. |
| Oct21-12, 04:16 AM | #8 |
|
Admin
|
|
| Oct21-12, 09:36 AM | #9 |
|
|
Thanks, Chiro and Borek, for the input. And I think the reason that I am struggling with the syntax and not the algorithmic part as such is because of the class format...at home on my own I can perfect the syntax, but often encounter problems that I struggle to frame correctly so that the language can help to solve them. In class, however, our tests consist of written programs. The algorithms are very simple, and I can almost hear the instructor thinking "There, this is so easy any fool could figure it out!" in his head. But they are all long and often require many detailed steps, increasing the possibility of a small error. If your program does not compile or you don't submit by the time deadline, you are sunk. Really sunk- it doesn't matter how much you've done well, you get nothing.(I have been working on debugging, as it seems to me that doing this quickly is vital.)
|
| Oct21-12, 10:06 AM | #10 |
|
Admin
|
Learning C++ is a necessary evil.
![]() I learned Fortran (the older F77 version). To learn C++ now is somewhat like learning Roman after having grown in speaking Greek. The languages accomplish the same, but they are different in many ways, although there is similarity in structure and function. I'd simply reiterate what jtbell, borek and others have mentioned. Part of scientific programming/computation (numerical analysis) is being able to translate the mathematics into an algorithm that works in numerical analysis. This is not trivial. The other part is learning the computer language with one uses to write the algorithm(s) and solve the problem. Along with that is the input and output of data, which itself is critical. If one puts garbage in, the one's program is simply a fancy (and potentially expensive) garbage processor. Much of scientific programming comes with a legacy of FORTRAN. C++ is more recent, and there is a tendency to write new scientific programming in C++, particularly for systems employing object oriented programming (OOP). I'm in a situation where I have to use both FORTRAN and C++. |
| Oct21-12, 12:31 PM | #11 |
Recognitions:
|
But as Borek said, in C++ some of those issues are made worse by the cryptic syntax - for example "a function that returns a pointer to something" and "a pointer to a function that returns something" are very different concepts, but the only difference in the C++ code is a pair of ()'s. |
| Oct21-12, 12:48 PM | #12 |
|
Admin
|
Some text editors actually use colour to help with syntax, e.g., matching (,) or {,} in C/C++.
I think TextPad is one such editor. It's very helpful. |
| Oct21-12, 12:58 PM | #13 |
|
|
OP: The sooner you start to code, the longer the project will take. I usually spend a lot of time with pencil and paper writing out memory management issues, logical structures of my algorithms, etc. Don't rely on the compiler as a crutch to find the errors in your program. Do your best to anticipate problem areas and address them before you start actually writing the code.
|
| Oct21-12, 03:39 PM | #14 |
|
Mentor
|
To take better advantage of C++ you need to move to object oriented programming. This is the French part of C++. Because the C++ flavor of object oriented programming is still written in terms of a procedural point of view, that object oriented stuff still looks a bit familiar. It is a different language, though, requiring a very different mindset compared to programming in C. To take full advantage of C++ you need to use the template programming capabilities that are part of the language. This is the Basque part of the language. Even though the Basque region is sandwiched between France and Spain, the Basque language has nothing in common with either French or Spanish. That's C++ templates to a T. |
| Oct21-12, 04:32 PM | #15 |
|
|
Im in my secon year of my computer science degree and I hadn't done programming before but I read up on the concept of it before going to uni. I started with Python and basically all programming languages are the same.
The hardest part is learning the syntax, you want to make a program that counts to 10 then stops at 10. Sure it's very simply just use a loop, but almost every language uses different syntax so at times I know EXACTLY what it is I want to do but it takes me a google search to find out the correct syntax. Unfortunately compilers are not smart enough to take a guess as to what it is you're trying to accomplish. |
| Oct21-12, 05:11 PM | #16 |
|
Mentor
|
|
| New Reply |
Similar discussions for: Thoughts on C++
|
||||
| Thread | Forum | Replies | ||
| Thoughts from an old man | Relationships | 6 | ||
| having second thoughts about my course... | Career Guidance | 6 | ||
| Just a few thoughts | General Discussion | 3 | ||
| Your thoughts | High Energy, Nuclear, Particle Physics | 0 | ||