Why C and not C++?

You have a large body of code that is using C just fine, thanks, and moving it to C++ (while probably “trivial” for some meaning of trivial involving a few weeks/months/years of refactoring) would expose you to every C++ yahoo’s whim.

“I wanna use maaaaaap! Why can’t I use map? Map map mapmaapmap.”

“Because this stuff runs in an interrupt handler, and is shared with thread-world code through a very carefully designed API involving a couple layers of synchronization. Many Bothans died to make this work well, and fast.”

“No map?”

“No map. Go read about NUMA.”

“What about streams?”

[buries head in hands]

tl;dr; It’s an idiot shield. Kids, get off the lawn 🙂



This entry was posted in Uncategorized. Bookmark the permalink.

10 Responses to Why C and not C++?

  1. C++ extremist says:

    … but, so, if you /need/ a map, you hand-roll your own using void*s, thereby weakening the optimizer slightly, and then cast all over the place? C’mon, using C++ doesn’t stop you from caring about the machine and efficiency or in any other way stop you from being a ‘C’ person. Come up with a better example (but, hint: there aren’t any).

    You know, you don’t have to refactor all at once, or even at all; just write new code in C++.

    But take comfort – it’s not just embedded systems that are stuck in C; the Oracle kernel is pure C, and will be forever afaik for the same reason of not even messing with what’s not broken.

  2. BlueRaja says:

    The real reason is that they don’t actually know C++ – they just know C and a bit about classes. Porting a C program to idiomatic-C++ (including RIAA, smart-pointers etc.) is extremely non-trivial.

  3. Charles says:

    This is the danger of abstraction; by hiding the implementation details, you create an atmosphere of ignorance that *will* bite you.

    — Charles

  4. Wise old coder says:

    For C programmers that hate C++:


    • xrgtn says:

      Re: For C programmers that hate C++

      This was in fact for programmers who cannot make up their mind about whether to use ambient shading, Gouraud or Phong. If there is really such a requirement for production code, C programmer would use preprocessor to make code as fast as possible and exploit compile-time type checking to full extent.

  5. sapphirepaw says:

    Map is only for languages with pervasive support for lazy sequences anyway. Otherwise someone will inevitably try to map over the lines of a 400GB file and run out of memory.

  6. Andrew says:

    Double plus good. By which I mean a double plus that is not and cannot be overloaded to mean that hidden agendas are being initialized.

    • Shamus H says:

      But I like my syntactic sugar! Sure it can be abused, but even so, it’s a nice thing to have around and use when it makes sense–such as, say, a geometric vector (okay, admittedly this falls apart with operator*() because you have dot products and cross products, but still :-).

      drools while staring blankly into space

      Mmm…. Syntatic sugar… Full of all kinds of syntacticy sugary goodness… Ooohohohhh…

  7. Mark Ransom says:

    You’ll be pleased to know that Linus Torvalds agrees with you.


    I also came across a couple of good rebuttals while searching for that quote.


    If you’re close to the metal as in an interrupt handler, I can understand why a little abstraction would be a dangerous thing. Linus was talking about Git though, and I think he doth protest too much. Context matters.

Leave a Reply to Charles Cancel reply

Your email address will not be published. Required fields are marked *