

Ask HN: What did you do to become an expert in C++? - yr

How did you master C++ language ?
======
Animus7
It just takes time. 10K hours or whatnot. I've been writing C++ almost every
day for the last 10 years, and I'm still learning.

My best advice would be to just do it. Don't focus on memorizing the syntax of
pointer-to-member functions or the stupidly complicated overload rules. C++ is
powerful but a lot of it is quite useless in practice.

Instead, you should be writing DNS servers, hiding text as bit patterns in
JPEGs, or whatever other thing you find intellectually interesting. Sprinkle
in some Google and bake for a few years.

I'm sorry to say that like with most things in life, there aren't any
shortcuts here.

------
makecheck
It's important to distinguish C++ expertise from that of other languages. C++
is so large (and with C++0x will be larger still) that any expert you do meet
will know at best a large portion of some subset of the language. And this is
fine.

The most important skill is general problem solving, and for this a variety of
tools is helpful. So in the C++ world, focus on a few language features that
are most different from one another. Make sure you know _basically_ how
templates work, but don't fret if you've never seen a specialization or any of
the 44 corner cases that are unsupported or undefined. Learn at least common
STL containers like vectors, sets and maps, and learn basic_string. Expose
yourself to at least one algorithm like fill_n(), and recognize how it is
different for vectors versus C arrays. Learn ostringstream. Use namespaces,
and learn about the "using" keyword. Learn the basics of classes, constructors
and destructors, and the RAII technique. Master all of this before exploring
the messes that are inheritance and exception handling.

------
queensnake
Read the Exceptional C++ series (shorter, 'highlights' version is C++ Coding
Standards), Modern C++ Design, and Andrei Alexandrescu's unpublished columns.

~~~
hannibalhorn
Gotta second this, after reading these books you'll have a completely
different perspective on how to write code in C++. It's completely different
than C.

------
turbojerry
As many have said here, it's about actually writing code in the end,
personally I learned C++ by writing an electronic schematic editor as a front
end to a SPICE circuit simulator, so I learned C++ and the Windows API at the
same time. Of course as well as writing code, reading other peoples is useful
too, when i was learning there weren't the reasources there are today, you can
go over to github or sourceforge and find lots of interesting code to learn
from, and do code reviews on to see how you might have done things
differently.

------
elmindreda
You don't master it, so instead I will write about what I did to learn
reasonable amounts of it.

I wrote lots of code, tried use it and then fed what I learnt back into the
design. Repeatedly.

I read tons of other people's code. Large, running projects. Example code
won't work.

Occasionally, I read books, but the only one I ever read all the way through
was /Teach Yourself C++ in 21 Days/ back in 1996 (and its title is ridiculous;
I'm still learning every day).

------
nostrademons
(Not an expert, but reasonably proficient.)

I worked with a lot of really good C++ programmers and had them do my code
reviews. The best way to learn is to expose yourself to people who know more
than you do and give you feedback.

As one of my coworkers is fond of saying, "If you work with people better than
yourself, you'll get better. It just happens naturally."

------
SamReidHughes
Assuming that I _have_ mastered it, it happened from learning and using
Haskell, watching people post and smart people answer in some C++ megathread,
and getting a job where the product is written in C++. And also some early
experience using it in a CS II class that used Koenig & Moo.

------
sambeau
The answer is the same as it is for any programming language: write something
big.

You can read as much as you want but it will never make you an expert. To
fully understand a language you have to live in it for a while.

------
badkins
My first real project was writing a game engine, and then using it to write a
couple games. After that, I learned a whole lot writing a compiler for a C
like language.

------
known
I wrote a proprietary trading system in C++.

