3 ms·
Embedded programming in C is a chore, because embedded code can be much trickier to debug. Writing C without bugs is a great deal of work, and very stressful. D
by ncmncm 5y ago
Embedded programming in C is a chore, because embedded code can be much trickier to debug. Writing C without bugs is a great deal of work, and very stressful. Debugging it when you don't is also very stressful.
Embedded programming in C++ is pure fun. The more modern your code is, the less room you leave for bugs: when it compiles, it mostly works. Where it doesn't, it shows up in your logic, not in random memory corruption.
- beached_whale 5y agoI do a lot of static_asserts and small composable constexpr methods so that when I am wrong I get a compile failure. Actually with IDE's I get a little overlay telling me the error usually. Constexpr methods seem perfect for embedded in a lot of ways too. Yes, I won't be touching real memory or ports, but I can ensure that the method isn't doing silly things either. Having a memory address class that filters on the proper operations and only allows them is awesome. Saw a good video on the topic recently too https://www.youtube.com/watch?v=fsMmh8F8uV0 https://www.youtube.com/watch?v=fsMmh8F8uV0
- osivertsson 5y agoExcept that most devs don’t understand what their C++ code actually does at runtime and many try to be too clever and use too many features. I have seen spectacular failures regarding memory usage and copies, static initializers, even exceptions (just design your APIs without them!) C++ code bases may have less buffer overflows and off-by-one errors but I don’t trust them unless they come with an extensive safety-net in the form of unit-tests with good coverage.