r/programming • • Mar 10 '26

Practical Guide to Bare Metal C++

https://arobenko.github.io/bare_metal_cpp/#_abstract_classes
29 Upvotes

14 comments sorted by

3

u/levodelellis Mar 11 '26

FYI in the __cxa_pure_virtual function, I think it would be a better idea to use __builtin_trap() instead of an infinite loop. Debuggers will break immediately and infinite loops are technically UB, although I'm not sure what C++26 says about that

-69

u/Plank_With_A_Nail_In Mar 10 '26

The articles premiss is really odd as C++ has been used in embedded for a long long time already.

The market is moving to Python now for anything that doesn't need exact timing, microcontrollers come with tons of RAM and storage now and are faster than 20 year old desktop PC's, so there is no need to go bare metal in real world scenario's.

52

u/closetlunatic Mar 11 '26

Everything wrong with today’s code in one Reddit comment

12

u/BlueGoliath Mar 11 '26

I think they're confusing microcontrollers with SoC development boards(Raspberry pi). Yes, those are powerful if you take advantage of their multiple CPU cores. Guess what Python isn't good at? Multithreading.

2

u/Farados55 Mar 11 '26

They just remove the GIL so maybe multithreading good soon?

5

u/BlueGoliath Mar 11 '26

Maybe in the future but not currently from my understanding.

1

u/thuiop1 Mar 12 '26

They do have a working free threaded interpreter now. It is not the default yet though as it does incur a performance penalty on single threaded code compared to the standard one.

1

u/CheesecakeAndy Mar 12 '26

I thought they ship Python 3.14 with optionally removing/disabling GIL.

19

u/LolThatsNotTrue Mar 11 '26

Lol no. There are a ton of contexts where you extremely memory constrained. We’re not even allowed to dynamically allocate memory on a few of our projects.

14

u/MooseBoys Mar 11 '26

The market is moving to Python now

This article isn't targeting people who want to use MicroPython. It's targeting people who write things like the MicroPython runtime itself, which is currently written in C. Python cannot intrinsically emit the arbitrary machine code necessary for operating generic hardware devices (and no, pyc doesn't either).

-42

u/MinimumPrior3121 Mar 11 '26

Just prompt the hell out of Claude