Ask HN: Use C with Classes for Embedded?

by Suracon 5/5/2025, 5:43 AMwith 8 comments

Hello. I am writing code for embedded systems. Most cpu are ARM or SoftCpu from FPGA vendors. Up to now I use C11. All the CPU are supported by gcc, thank god. I used to write c++ before C++ 11. The good old time. I now think more and more often to switch to C++ on embedded. No exceptions no RTTI no STL or Boost. Just C with Classes for the luxury of C++. What do you think? Is it worth the hazel?

by Disposal8433on 5/5/2025, 5:46 AM

I have a small experience with embedded systems but I once helped a team of hardware engineers switch from a "assembly-like code with loops and state machines" to C++17/20 on a very barebone platform and everyone was happy with the improvements in code quality and tools. IIRC we even used relatively advanced objects like `std::optional`. No need to shun the STL as it supposedly compiles to small code most of the time.

by daviddever23boxon 5/5/2025, 4:17 PM

Isn't this the premise upon which Google's Pigweed (https://pigweed.dev/) operates?

by rzzzwilsonon 5/5/2025, 5:52 AM

Why not? Just stay away from anything that may allocate/free memory after system initialization, like "String".