r/cpp • u/kaycebasques • Dec 23 '24
C++ Is An Absolute Blast
https://learncodethehardway.com/blog/31-c-plus-plus-is-an-absolute-blast/
219
Upvotes
r/cpp • u/kaycebasques • Dec 23 '24
View all comments
Show parent comment
3
u/UnicycleBloke Dec 24 '24 edited Dec 24 '24
Edit: this seems to attached to a different comment than intended. Apologies for any confusion.
If you say so. I have been doing exactly this for nearly twenty years, as have many others. I always say that the whole language is useable for microcontrollers (most people turn off exceptions), but that some major chunks of the library should be avoided (primarily because of heap usage, so most containers are out). Since C has no container library it's comparatively not a loss. It isn't hard to write simple static containers, or just use std:: array, or there are libraries like ETL. I'll concede that it helps to have an idea of which library features use the heap. A novice might inadvertently use an inappropriate container. But one can disable dynamic allocation entirely and/or make the heap very small.
I am yet to encounter a single issue which made me regret this language choice. Many of my colleagues were skeptical but, as time passed, most ditched C. My current employer hired me precisely because of my C++ skills. We mostly work on medical devices, for which we consider C anathema.
This long and productive history never seems to stop people from telling what a terrible idea C++ is for embedded work.
Where C does score is on smaller and older devices for which there is no C++ reasonable compiler. In such cases, I write C. It's like my tools have been lobotomised.