Hacker News new | past | comments | ask | show | jobs | submit login

C++ is a no-go in the embedded world for a lot of reasons.

First, you have to have a C++ compiler. That's not always a given.

Second, everybody likes to use a different subset of C++ in the embedded world. Some people have heaps, some don't. Some people use exceptions, some don't. etc.

Third, it's quite a bit more difficult to figure out what your max stack usage is if you have to traipse through virtual inheritance chains. C isn't easy, but C++ makes it horrifically difficult.

Does that answer your question?




I do embedded work for a living and can confirm all this. Perhaps bsder is a little too categorical, but C++ is definitely a language that poses additional difficulties for embedded developers. Many people feel that it offers too little in exchange -- that is, when a decent, reasonably non-buggy compiler exists for your platform.

This is not to say that there isn't a lot of embedded C++ code (I don't have numbers, but I suspect C and C++ are a lot closer together than C++'s haters would think) -- or that there isn't a lot of good embedded C++ code. I've seen a lot of good C++ code, and the only reason why I haven't written any is that my C++ skills are so out of date that I have a good chance of borking anything longer than a hundred lines.

And indeed, as bsder points out, a lot of the problems are people/politics-related. It's not that "C++ sucks", it's just that there is so much of it that as soon as you get ten people together, two of them are bound to know and use some gimmick that the other eight don't know about, four of them want to avoid exceptions while the other six used to do Java so they have no idea how else you're supposed to deal with failures, and three of them love C++11's new features but that's irrelevant because your compiler (which, by the way, costs about as much as half a kidney on the black market) barely holds together and the team it was outsourced to back in 2007 can barely patch up the null pointer dereferences, let alone add new features.

If you have full control over your codebase and don't (or barely) need to integrate anything from the outside world, it's actually OK. Otherwise, there's a good chance that you're in for such a rough ride that you'll swear you'll never use C++ again.


Yeah, C++ seems to have happily taken over the "write-only language" trophy from Perl. That's not a compliment.

And, I don't think I have ever seen a language mutate so much over time. C++ from 1996 looks nothing like C++ from 2006 which looks nothing like C++ from 2016. Also not a compliment.

I just simply no longer care to allocate the brain space for a language that buys me so very little in the embedded space. If I could find a decent interpreted language for the embedded space (256K flash/16K RAM), I'd never touch C++ again.




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

Search: