3 ms·
One of the reasons C++ is so complicated is that you don't pay for the features that you don't use. If you wanted generics in C, you can easily use C++ without
by wvenable 7y ago
One of the reasons C++ is so complicated is that you don't pay for the features that you don't use. If you wanted generics in C, you can easily use C++ without any of those other features (baggage, if you will) and not pay for it.
Heck, you could define a few macros and make it impossible to use any baggage features you don't like.
I've used C++ in a pretty tight embedded environment and it was great.
- Crinus 7y agoYou may not pay for them (generally) in terms of execution time, but you pay for them in terms of compilation time and language complexity.
- wvenable 7y agoIf I don't use them then language complexity doesn't matter. Compilation times might be a factor assuming that turning them off doesn't also decrease that (which it might).
- bsder 7y ago> I've used C++ in a pretty tight embedded environment and it was great. I'd love to hear some details. I'm always looking for C++ stories that didn't end in disaster and what the people did that worked.
- com2kid 7y agoI've done similar. The Microsoft Band UI was written in C++. No templates or other advanced features, compiler was stuck on 2003 standard. We had templates but used the trick of implementing them in a .cpp file and declaring all the instanciations of them we'd ever use at the bottom of the same file. Had to write our own to guarantee 0 allocs. It is quite do-able. Lots of static declarations, basically write C with classes. V-tables ended up being non-trivial in size, but what can you do, GUIs and all that. Possibly the best (only?) good use of inheritance hierarchies. 256KB memory, the UI only had 60KB or so available for it IIRC. We also had a scratch pad available over a super slow bus of a couple megs, but it couldn't be used too much or we'd drop frames and we loved our 30fps v-sync'd performance.
- dragontamer 7y agoPretty much any CUDA programmer can talk about how they got 1024 threads working on 64kB "shared memory" with their C++ compiler. That "shared memory" region is exceptionally fast, so its a good idea to hyper-optimize your memory accesses to use that region. There are some very interesting constraints in GPU-programming. Fitting C++ classes and even some data-structures in the "shared memory" region is pretty nifty.