Hacker News new | ask | show | jobs
by gorgoiler 1490 days ago
Embedded devices really opened my eyes to this world. What a fool I was using malloc on my first Arduino project.
1 comments

Arduino is entirely C++ though
> Arduino is entirely C++ though

No, it's C++ without exceptions (so constructors are useless).

On Arduino you will almost certainly program in a C-with-classes manner; lack of exceptions make almost everything that C++ brings to the table useless[1].

> lack of exceptions make almost everything that C++ brings to the table useless[1].

sorry what ? constexpr (https://github.com/arduino-libraries/Arduino_EdgeControl/blo...), templates (https://github.com/arduino-libraries/Temboo/blob/dcce3007eb5...), etc. are all widely used in the Arduino community. I've recently done some work involving C++20 coroutines on an RP2040. etc etc...

And even without exceptions, RAII can still help ensuring a large amount of invariants automatically.

It is remarkable how many large and modern C++ code bases somehow make thorough use of the language, including constructors, without exceptions. Unless the asserted need for exceptions is a gross mischaracterization.