C++ is recommended for physics majors and engineers, and I was considering taking the class but the teachers at my school for this are terrible. I’ve heard terrible experiences from past students. Terrible reviews online, all across the faculty in this department. Plus it’s a 4 unit semester course with a lab component that would take all day and I need that room in my schedule for more important classes that relate to my major. Originally I was just planning on learning it on my own, I thought it wouldn’t be so hard. But the resources online seem too extensive…it wasn’t as easy as I thought it would be. I get bored easily, too. Does anybody have any better resources that are simple and to the point? How did you learn C++?
There’s a lot to C++ and it takes time to learn, especially if you don’t already know C and object-oriented programming.
I first learned C on the job back in the 80’s with the Kernighan and Ritchie book. Then I learned object-oriented programming by learning Ada on another job. After that, I got a job where I had to learn C++. I used the Stoustrup book for that. I never had formal classes in any of them.
There are bound to be better books now. I always have a hard time learning languages using only web resources.
I also used the Stroustrup book (the beginner one, Principles and Practices using C++, not The C++ Programming Language which is very much not for beginners) to learn C++. It was a good book that taught a lot of important things that were merely glossed over in class, but I needed two other things before I started to actually get the hang of using it properly:
- A class in Java on OOP programming. This taught me to use a structured approach to designing code, and to use data structures. Very useful and a difficult, though far from impossible, skill to learn on your own.
- Actual coding in C++ in a professional environment (work and research). Visual Studio is an extremely advanced tool that takes years to properly understand, and it makes your life a lot easier.
Stroustrup is a very good book, written by the person who actually invented C++ and understands what it is meant to do. His coding methodology is very sound and very useful. It was more useful than any class I took on the actual subject of coding in C++, but there are many details from his book you will not appreciate until you are taught to use it in a class setting.
To really understand what C++ can do at a high level, you probably need a Masters in CS. There is a lot to it, more than anyone would think without having the proper CS background. For physics/math/engineering, you don’t need to know C++ in that depth, but you do need to know how to write computationally efficient code in a good style (because high-performance computing is what you’ll really be doing). Those majors tend not to write significant amounts of code, but rather just use straightforward coding tools when they are necessary (usually Matlab/Python/Mathematica would suffice, but C/C++ are for high-performance applications). For that application, I’d say the following are necessary:
- Basic foundations of C++ (Stroustrup will more than suffice)
- A class on structured programming in OOP, along with data structures (tough to learn from a book)
- Algorithms (Might be able to get by without it, but not recommended. Very hard to appreciate without a good teacher)
- Numerical analysis (Probably want one heavy on theory. Good free book: http://www.mathworks.com/moler/chapters.html)
- Scientific computing (Might want a class, but it's pretty high level and you will have significant prereqs).
All in all: there are things you can learn from a book, and I definitely recommend Stroustrup. But you won’t get everything you need by self-study. If you want to have a solid foundation in using code for the purposes of physics/math/engineering, you need to put in a strong effort over the course of a few years. And since it is a very important skill that is becoming more and more important over the years, you would be well-advised to put in the effort to learn it properly.
@NeoDymium thank you so much! very extensive and helpful post. I checked if my school had an OOP class, and apparently the pre-req for that class is C++ or java, lol. i think ill try out Stroustrup and the mathworks link for now, and then try to take the actual C++ class at a university once i transfer, hopefully there are better CS teachers there. thanks once again!
As a final note, don’t be disappointed if the numerical analysis part goes over your head. You generally would need differential equations and linear algebra, along with the full calculus sequence, to understand most of it. Some sections need more than that.
@NeoDymium alright! btw, why is high level math needed to understand a coding program? what is the relationship?
The short answer is that it isn’t. Rather, the high level math is often baked into programs because it has a particular use. This is the case with stuff like linear algebra and graphics, discrete structures, statistics and finance (among many other applications) and tons of other fields that have computer programs made for them. All of the math and physics a CS major may take is essentially the “and its applications” part of a good understanding of CS.
So you don’t need any of the math to program by nature, but you may find yourself using it on the job.
One could also argue that the high level math only strengthens your logical / mathematical thinking, which is very closely tied to programming skill as one of its main pillars.
You don’t need much math for strictly coding, but:
- If you study any form of theory in CS (which starts with algorithms), you need to be able to write proofs. Discrete math and maybe real analysis are helpful here. Any program that has to be written to be computational efficient will probably require customized algorithms. The further you go, the more you will need math.
- Numerical analysis and scientific computing are specific applications which are math heavy. Those are primarily where scientists and engineers use code. Those topics don’t require much additional knowledge in the way of coding other than the ability to understand why a certain pre-written algorithm is useful in any given situation.
You can write a lot of code without ever knowing a thing about math, but I wouldn’t recommend it.