Nim on a Real-Time Operating System: Apache NuttX RTOS and Ox64 BL808 SBC
lupyuen.codeberg.page
lupyuen.codeberg.page
With ARC, you don't need to "run" any runtime GC. ARC is a fully static thing, the reference-counting happens at compile time (static analysis) and the compiler injects (the equivalent of) malloc() and free() calls in the compiled code based on that.
It's great for embedded IMO. You get the performance of manual memory management with the convenience of GC. The only thing to be wary of is that it "hides" a bit when allocation happens. On embedded, you often want to minimize dynamically allocated memory for performance and heap fragmentation reasons, though the latter should be less of an issue with 64 mb of RAM. In nim, you just have to remember that creatin a string, a seq or a `ref object` allocates. So you want to eg. avoid creating and destroying a string repetitively in a loop. Instead create a `var` (allocate a buffer) once, outside the loop, and modify it as needed in the iterations. Everything else in nim (including plain objects, which map to regular C structs) is stack allocated, so ARC doesn't get involved at all.
Further reading:
https://nim-lang.org/blog/2020/10/15/introduction-to-arc-orc...
https://nim-lang.org/docs/mm.html
https://nim-lang.org/docs/destructors.html
https://nim-lang.org/docs/nimc.html#nim-for-embedded-systems
ARC is deterministic. ORC isn't, but doing cycles in general is usually a code smell, especially on embedded.
Also the GC is type-bound and only needed if you use ref objects. If you don't, no GC.
How long haven't you checked that for? It's been ORC for years.
Try this with a recent nim version:
nim --fullhelp
-mm:orc|arc|refc|markAndSweep|boehm|go|none|regions
select which memory management to use; default is 'orc'
When you confidently try to correct someone, at least consider you may be wrong.Orc was blocked for a while due to cycles with async. I was under the impression that they were still there.
> It's been ORC for years.
The switch has been made for Nim v2 announced in December 2022, the PR #19972 that defaults to ORC has been made on September 2023.
ORC has just celebrated 1 year as default GC, certainly not years.
> When you confidently try to correct someone, at least consider you may be wrong.
I don't get why you're so butthurt about this and feel the need to be so nasty in your replies.
It’s one of the unexpected joys in IT to take a microcontroller, add a few cable, all per detailed instruction for beginners and then yes the light goes blink, as per instructions . At yet it makes you happy ;-)
"Embedded" typically means specialized hardware and code.
"Running the same binary everywhere" is generally not a practical consideration with specialized hardware.
Typical concerns I associate with "embedded" are minimizing production cost and maximizing efficiency in order to try and achieve a marketplace cost advantage. It is not clear how 64bit will help in this regard.
The address space of 16 bit pointers is only 64KB so I can understand 32 bit for pointers as well as math use in some cases. But the need to exceed a 4 GB/32bit address space for "embedded" is extremely rare at this time..