

Tips for Learning C++ - jmtame

I currently use a lot of very high-level languages (javascript, html/css, php, etc), but want to learn something a little lower-level like C++ for fun.  A Google search has an overwhelming amount of advice, maybe someone with a bit of experience could chime in and offer some tips ie compilers, great tutorials and articles, libraries, etc?
======
biohacker42
C++ is almost universally reviled. But I am grateful to know it. Here's why:

C++ was my first programming language, I picked it up quickly and had fun and
still do. I still have fun in C++ despite the fact that it is most certainly a
horrifically complicated language, juggling chainsaws and all that.

The only good reason I can think of to learn C++ instead of C or D, is because
it will make every other language you are ever exposed to look easy.

That's why I am grateful it was my first language. Who knows, I might not have
ever learned it, if I was fluent in one or more other programming languages
already.

Also C++ jobs tend to pay well, but that's the wrong reason to go into
chainsaw juggling.

------
krschultz
cplusplus.com to be honest that has most of the info you need to start

------
newt0311
Instead of C++, I would advise learning C. If you are still interested in
learning C++, I would still advise learning C first as C++ is (or at least was
originally based on) C. K&R is probably the best way to start on C.

~~~
apu
While I heartily agree that K&R is the best way to learn C, I'd strongly
recommend _against_ learning C en route to C++. Most "best practices" in C are
usually frowned upon (or worse) in C++. For example, using c-style arrays
(instead of Vectors), using pointers excessively (instead of references),
malloc/free (instead of new/delete), lots of global functions/variables
(instead of classes, etc).

As far as picking between the two, it depends on your goals. If you really
just want to learn about low-level programming, then C is probably the best
option. On the other hand, if you want to be able to write low-level code for
speed (i.e., to then call it from a high-level language), you might be better
off with C++ (which is much more flexible while maintaining most of C's
speed). Keep in mind, however, that using C++ effectively can get
significantly more complicated than C (templates, classes, etc.), and so it is
not usually a good idea to learn it "for learning's sake."

~~~
pmjordan
I know probably 99% of the C++ standard and used C++ in anger for years, and I
do not recommend learning it unless you _need_ to do so. Getting into the
(console & PC) game industry is one of the only reasons I can think of. Even
so, most veteran game programmers use only a small subset of C++, and most of
the code is effectively C.

C++ is a terrible hack, and if you're very familiar with other languages
you'll be shocked by what is considered beautiful or elegant in the C++ world.
(e.g. Boost)

If you want to just low-level optimise parts of a program written in a high-
level language, C++ is actually a pretty poor choice. C is actually going to
give you fewer headaches with language interop, as it has a standardised ABI.
There are tools to do, say, C++ to Java interop, but I can't recommend even
_trying_ to do that kind of thing. In comparison, JNI (implementing Java class
functions in C) is a walk in the park.

Yes, you can do anything you can do with C in C++. Yes, C practices (char*
strings, etc.) are considered bad style by the C++ world. I'm going to just
come out and say it: in my opinion, the C++ world has no idea what good style
is.

As for learning C, it's a very good idea. You'll learn a whole load of things
that will help you even when you're not using C itself. Hopefully, you won't
need to use C itself all that much in practice, but it's a damn handy language
to know, even if all you use it for is to write glue code between some
libraries and your favourite language.

