Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Code portability is a big one. People write C compilers in a week as a hobby. Now compare to how long it took Clang to fully support all of C++. Now certainly, C++ is on every major platform in broad use. But maybe you are targeting something embedded, or a hobbyist OS. Or maybe you want to write up a quick embedded interpreter for scripting in your application. There's something intrinsically satisfying about minimalism and simplicity.

It's also really hard to control the feature-set of C++ you want. The second you start pulling in code libraries, you find yourself needing to use the parts you don't want. Not in your own code directly, but in your interactions with their library code. Catching exceptions, needing RTTI, etc.

Symbol exporting is also a really sore point in C++. The symbol names C++ compilers spit out are just terrifying. With a C language, it's trivial to write bindings for other languages like C# and Python.

But for what it's worth, I still program almost exclusively in C++.



Aren't there C++ compilers that will compile to C code? Doesn't that effectively make C++ just as portable as C?


> Aren't there C++ compilers that will compile to C code?

Uh ... no? CFront did that when it was just "C with Classes", but nowadays with C++14? That would be absolutely terrifying.


Arguably the most versatile compiler in the world is EDG's.

One of its features is: "a C-generating back end, which can be used to generate C code for C++ programs"

source: https://www.edg.com/index.php?location=c_frontend

In fact, the Itanium C++ ABI (which has no relation to the architecture) specifically uses valid C identifiers to mangle C++ names to support products like EDG.

source: http://mentorembedded.github.io/cxx-abi/abi.html#mangling-ty...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: