Remix.run Logo
kabdib 4 hours ago

I've been doing embedded systems in C++ since rocks were young, and this is a great summary of what to avoid.

I would sure love a good coroutine runtime, and first-class support for defer. You can do these manually, but language/toolchain/debugger support is nice to have.

(Pragmatically, I will be retired by the time they would be useful)

usrnm 4 hours ago | parent | next [-]

A defer is just a dozen lines of code nowadays, if you really need it, but in most cases you don't if you're doing RAII

wglb 4 hours ago | parent | prev | next [-]

It is still a bit amazing to me that it was significantly easier to do coroutines in Sigma 5 assembly and likely most any assembly than in C or C++. Two languages supposedly close to the machine.

kabdib 4 hours ago | parent [-]

I have seen a pure C/C++ implementation of coroutines (it used setjmp/longjmp, and memcpy to copy stacks in and out of the native arena). Not the most portable of constructions, but it worked absurdly well.

Being able to write "async" code essentially in-line is a superpower.

wglb 2 hours ago | parent [-]

Agree but nowhere as easy as what we did https://ciex-software.com/coroutines.html

AnimalMuppet 4 hours ago | parent | prev [-]

In embedded, I like wrapping a class around a set of registers. Nobody else gets to write to that piece of hardware except that class.

As far as avoiding things... avoid basically everything you don't need. Don't add language features that don't actually help you, just because they're there. Keep the subset you use small. But pick that subset to match your problem well, rather than out of dogma.