5 ms·
You don’t always get to choose your language. Especially in the embedded/firmware area of software development, C is the most widely available option, if not th
by throw-qqqqq 1y ago
You don’t always get to choose your language. Especially in the embedded/firmware area of software development, C is the most widely available option, if not the only option besides ASM shrugs
- rowanG077 1y agoDefinitely. I still don't think you should swim against the stream. Just bite the bullet and write idiomatic C. The people who will have to debug your code in the future will thank you.
- throw-qqqqq 1y agoI agree 100%
- windward 1y agoIt is, but the bar of what's considered too 'clever' in embedded/firmware is usually lower than this. In fact, even the ternary conditional operator is too much.
- fuhsnn 1y agoThe said library is a bit farther away from the C that is widely available. It relies on C23 features, GNU statement expression, GNU nested function, sanitizer runtimes, VLA types and a very niche pattern of sizeof executing its statement-expression argument; only platforms that provide latest GCC/Clang would be able to use this.
- uecker 1y agoIn the library I experiment with various things, and C23 and nested functions are not really required. And for running the code, it only relies on GNU statement expression. For bounds checking, you need need the sanitizers. Overall, it is still far more portable than C++ or any other new language.
- throw-qqqqq 1y agoFair point. I did not notice that. Most C-only compilers only support C99 or a subset thereof
- pjmlp 1y agoUnless you are talking about PIC and similar CPUs, there is hardly a modern 16 bit CPU that doesn't have a C++ compiler available as well, assuming that we still consider 16 bit modern for whatever reason. Heck I learned to program in C++, back when DR-DOS 5 was the latest version, and all I had available was 640 KB to play around, leaving aside MEMMAX. Nowadays the only reason many embedded developers keep using C is religous.
- uecker 1y agoReligion and the garbage code C++ compilers produces, incomprehensible error message, unstable tooling, and very long compilation times.
- simonask 1y agoWhat year is it, 1998? Am I going crazy? I think you're making some extraordinary claims. I'd love to see some receipts. :-)
- uecker 1y agoWhat specific claim do you think is extraordinary: That embedded programmers still often use C, that compilation times for C++ are often very long, that the languages is less stable than C, or that code produced by C++ can be worse?
- simonask 1y agoEspecially the last claim seems (that code generation for C++ is worse). It's the same compiler backend in all major compilers. Do you have any examples?
- throw-qqqqq 1y agoPurely guessing, but the "unstable tooling" could perhaps refer to the fact that C++ as a language has evolved a lot. I have had trouble compiling older C++ code bases with newer compilers, even when specifying C++98 as source standard. I gave up trying to get Scott McPeak's Elkhound C++ parser to compile, last I had to attempt it. C is a bit more forgiving on that topic (it hasn't changed as much, for better or worse).