top | item 1227841

Never trust a programmer who says he knows C++

87 points| skorks | 16 years ago |lbrandy.com | reply

92 comments

order
[+] wheels|16 years ago|reply
One funny consequence of this effect is that at 20 I listed like 15 programming languages on my resume; at 26 I listed 3.
[+] jerf|16 years ago|reply
I've long since taken C++ off of my resume, because I haven't used it for 10+ years, since I was in school. But because I'm a normal person for a HN reader, I've kept up with the news, and in learning so many other languages at one time or another have a pretty decent idea what's going on. Recently we started hiring for a C++ position, and I was asked to sit in on the interviews. I said that I didn't really know C++, but I do know enough other stuff to keep up.

Or so I thought. Our interviewer handed out a bit of code something like this

  int some_func(int, SomeComplexObject&);


  .. some code context...
  {
     {
         int a = 1;
         SomeComplexObject b = new SomeComplexObject()
         some_func(a, &b);
     }
     if (b = 0) {
         cout >> "Error" >> endl;
     }
   }
or whatever, something like that, and asked what was wrong. People with "years of experience" in C++ would strain and strain to find "the" error. This is of course a steaming pile of errors, the only legal code line is "int a = 1;" and that's redundant (just stick the 1 in the function call).

I don't have C++ on my resume, but after that experience I'm pretty sure I could put it back on without experiencing too much flak.

On that note, if you're into languages I really recommend the C++ FAQ Lite: http://www.parashift.com/c++-faq-lite/ Anybody who can follow that should probably just leave C++ on the resume. We all know C++ is massive, this is an interesting case study in how the massive language interacts with itself.

[+] chasingsparks|16 years ago|reply
I've been moving in the same direction. My question: which three?
[+] kabdib|16 years ago|reply
I have three standard "screener" questions: (a) what's a virtual method, (b) why would you want to have a destructor be virtual, and (c) what's a virtual base class.

Most folks (if they have a head on their shoulders) get A, a lot get B, and C befuddles almost everyone. (There are a few situations where you'd want to use a virtual base class. And if someone replies, "Oh yeah! I use those all the time!" they're probably using /other/ parts of the language that are just as unsavory).

Related to the original discussion: I've found the folks who self-rate themselves (on a scale of 1-10) as nines (and one guy was a ten) are generally bozos. This is independent of the language in question.

[+] gridspy|16 years ago|reply
I've been using C++ as my primary language for the last 10 years and know what virtual base classes are. I would never use them, Instead I'd avoid diamond inheritance at all costs.

I'd rate myself as a 9 or 10 for language proficiency but perhaps not for certain niches. For example I know comparably little about Win32 or COM (ugh).

However, there are tons of programmers out there who can't program. Faced with a clean slate they would either choke or create an atrocity. If they rated themselves 5/10 then for me to rate myself only 8/10 would be a disservice to myself. The same is true of perhaps 90% of the programmers on HN.

Of course, I can look back at my former self and know that he thought he was awesome but clearly I have surpassed his ability. It only makes sense that there are far greater programmers out there and I have met a few.

[+] _sh|16 years ago|reply
I used to think a good C++ screener question might be: "When would you use the 'nothrow' constant, and when would you have empty 'throws' specifications in method declarations?"

But then I realized this is just getting tricky with C++ arcana, and is unfair. I once read all of Herb Sutter's 'Exceptional C++' series, and they scared me so much that I still get the frights, years on, when contemplating approaching a C++ compiler.

And I used to think I was OK with C++ too. But after Sutter's books I had to accept that, nah, at best I was mediocre. I admire people who can boldly cast out and rapidly prototype a library or something. Or who have the patience to iteratively engineer a Boost library. I will never achieve this, despite once desperately wanting too.

[+] ntoshev|16 years ago|reply
So you're asking for OOP, no generic programming / templates? I know template metaprogramming magic becomes madness real fast :-)

I tend not to ask direct language questions anymore, everything is related to the code written on the interview. Like, you asked for a function doing something with an array of ints, and when you get the code you say "now, can we have this function work with arbitrary types instead of just int", "what are the constraints about this types", "what happens if it has a copy constructor but no assignment operator" etc.

And I accept everyone knows and uses some subset of the language.

[+] Eliezer|16 years ago|reply
Long as you don't need any honest 9s or 10s for whatever it is you're doing, I guess that's fine.
[+] d0m|16 years ago|reply
A better question is: Why do we need to put the archaic virtual keyword in front of a method? Shouldn't non-virtual functions used in an inheritence way be declared as private while the other being automatically virtual ?

Then if he agrees, he's ok. If he gives you more examples of why C++ is archaic, he's great. If he begins talking about non-virtual methods being more optimized than virtual one, thanks him for his time and try to find someone else.

[+] unknown|16 years ago|reply

[deleted]

[+] chancho|16 years ago|reply
> Anybody who says they are good at C++ is either delusional or has spent years writing, linking, debugging it.

This strikes me as a completely reasonable and not deprecating thing to say about any powerful language (such as C) or any advanced tool in any profession for that matter.

[+] tman|16 years ago|reply
Badly standardized? Not since the mid-90's. And the days of cross-compiler pain went away almost completely when the last big holdout of the pre-standard days, Microsoft, finally released their 2003 C++ compiler.

Your next point, that C++ is just C "with OO" strikes me as deeply ignorant. OO is an important feature, but 95% of the language innovation of the last 20 years has been in templates.

Compilation errors are a pain in C++. It's something that takes months for a smart programmer to figure out. Debugging C++ is harder than debugging C, yes. It's a more complex beast.

Reading your post I get the impression of someone who has read a lot more about C++ than working with C++. Try interacting with any modern C++ code-base (something written in the last 10 years), avoiding the template meta-programming code-bases which are really only of use for library-writers not library-users.

[+] DanielBMarkham|16 years ago|reply
Another post that confuses "all the features of C++" with "programming in C++"

Once more for the record, programming in C++ does not involve using all of the features of this massive language. In fact, a good C++ programmer keeps things as brutally simple as possible. C++ programming forces you to.

The author is dead-on about how you get swamped by the features. What he missed is that you come out of the valley on the other side with a good appreciation for "That hurts. Let's not do that unless we absolutely have to"

You know, C++ has to be a significant language. Nowhere else have so many people cried out in pain and frustration. Yet the language still rolls on. That's probably not much of an endorsement! (grin)

[+] VBprogrammer|16 years ago|reply
I mostly agree with you but I don't think I'd apply for a job specifically programming in C++ without knowing the appropriate use cases for the majority of the language features. Obviously different if you are only listing it as a language you have some familiarity with.
[+] gawi|16 years ago|reply
Never trust a programmer who says he knows C++... Never trust someone who says he knows... Never trust a programmer... Never trust C++ ... Never C++...

At university, they taught me C++. I suffered a lot. So the minute I graduated, I stopped doing it. This was a valuable lesson after all.

If someone pretends to understand C++, just look at his code and say "Ok, so what happens if you add 'volatile' just here."

[+] gridspy|16 years ago|reply
And a good programmer will raise his eyebrow at you and coolly reply "a little less optimisation"
[+] kscaldef|16 years ago|reply
I agree with the general observation, but it's definitely not the case that C++ is the only language where this happens.
[+] aidenn0|16 years ago|reply
True, but C++ is a perfect storm for this.

1) There are a lot of nooks and crannies that can bite you in the butt

2) It's cosmetically similar to C and Java so you get a false sense of security (The article points this out).

3) It's popular (same effect for PHP or Java (I took a intro to programming in this language, so I know it!))

4) Due to #1, every decent C++ shop tends to standardize on a subset of the language, with practices that deal with the nooks and crannies of just that subset.

[+] DCoder|16 years ago|reply
In my current free time project, I learned enough C++ by reading assembly to not find anything new in Lippman's "C++ Object Model". I'm not sure if that's a good sign or a bad one - did I see so many tricks, was I not reading attentively, or what... pity the book doesn't cover COM+ though.

When I inherited this project, it was relying on (cast)s and macros all around and this led me to some nasty traps, I switched to building a lot of templates, they've so far proven invaluable in saving debugging time, enforcing type safety, and communicating expected data types to other developers. Templates are good. And macros are traps, but everyone already knew that.

Granted, the project is a niche, I don't think there are many similar projects out there, so not sure how useful my knowledge of the object model is. I'm reversing/extending a C++ game with no source, btw. DLL injection and all that goodness.

[+] stcredzero|16 years ago|reply
Odds are, one should never trust a programmer who thinks they know [X]. Odds are they only think they know really know [X], but they haven't gone too much farther than figuring out how to use the library.
[+] icefox|16 years ago|reply
After finding out what language/library someone is most proficient in I always ask them what they find bad/wrong about that language/library.
[+] mprime|16 years ago|reply
Wait, what?

EDIT: This comment literally says "usually if you think you know something, you don't." So I guess I shouldn't apply for a job using language FooBar, since by this guy's rule I probably don't actually know FooBar.

How does this make sense?

[+] tjarratt|16 years ago|reply
Guess I'll be taking C++ off my resume then. Wouldn't want to risk having an interviewer think I'm not trustworthy!
[+] froo|16 years ago|reply
Always trust a graph that has no numbers or points to compare scale!
[+] defen|16 years ago|reply
I remember well the "static object initialization segfaults" valley.
[+] frou_dh|16 years ago|reply
Never trust an old man who says he's stood on the moon
[+] JoeAltmaier|16 years ago|reply
You can cut your hand off with a power tool.
[+] jrockway|16 years ago|reply
I have never met anyone who knows C++. I have also never met a C++ programmer that knew how to program or what OOP was. (Polymorphism? What's that? Tests? What are those?)
[+] neilc|16 years ago|reply
Sounds like you've just met a lot of bad C++ programmers. Given that most programmers are terrible and there are a LOT of people who claim to be "C++ programmers", I guess that isn't too surprising. People who actually know (sane, modern) C++ are rare.
[+] tbrownaw|16 years ago|reply
> I have never met anyone who knows C++.

Hello jrockway, nice to meet you. :)

> I have also never met a C++ programmer that knew how to program or what OOP was. (Polymorphism? What's that? Tests? What are those?)

If you understand those, there's a decent chance you're a real programmer rather than a language-specific programmer.

[+] mprime|16 years ago|reply
I'll be upfront in admitting that I loathe C++ just as much the next guy (I can't seem to get away from Lispy languages), but isn't this being a teeny bit ridiculous?