News for hackers. Stuff that matters.
Re:Nim 2.0 thoughts by michaelsbradley on Saturday May 15, 2021 @01:50PM (#27167338)
The reference counter with "destructors and move semantics..." is not presently the default, though it will be in the future. The OP mentions that.

The current default GC involves a somewhat unusual memory model that can make certain kinds of multi-threaded programming difficult: each thread has its own heap and independent GC; memory subject to GC cannot be read/written across threads and locks can't be used to remedy the situation; if you force the compiler to accept code that violates the "no shared" rule, the ref count of the GC on one thread or another will eventually get corrupted and the program will crash with SIGSEGV.

However, by allocating on and copying to/from the shared heap (which is never subject to garbage collection) you can do message passing across threads.

Re:Nim 2.0 thoughts by elcritch on Saturday May 15, 2021 @07:05PM (#27169764)
Note I’m using Nim with the new GC (both ARC & ORC) on dual core esp32’s.

Locks do work with ARC, though some care needs to be taken. Both the Nim and free-rtos multi-threaded queues work well with the correct move/sink annotations.

The design of ARC allows you to move entire memory graphs between separate heaps. It works fine, but what’s not working is the compile time verification that a given memory graph is only owned/aliased by the top pointer. So there’s a lot of work to do in making it “safer and easy” to use.

Here’s an example: https://github.com/elcritch/nesper/blob/f54fff8b240e94684ae8...

Re:Nim 2.0 thoughts by kaba0 on Saturday May 15, 2021 @04:10PM (#27168546)
I think Erlang has something similar.