Re:Pointer Free Programming and the Future of Nim
by seertaak on Friday October 20, 2017 @01:34AM
(#15513705)
I'm a C++ dev and this sounds extremely interesting. I have nim a spin a year ago and really liked what I saw, but GC was a real issue because I'm doing audio development where you end up having to circumvent the GC anyway. I would love to allow my users to create MIDI plugins with nim and this is a key step towards that.
[ Parent
| on HN ]
Re:Pointer Free Programming and the Future of Nim
by mratsim on Friday October 20, 2017 @06:57AM
(#15514815)
I'd like to add that "circumventing the GC" is supported by default. There are 3 object types in Nim
- `type Foo = object` --> Value type, on the stack
- `type Foo = ref object` --> Reference type, managed by GC
- `type Foo = ptr object` --> Pointer type, manual memory management (with Nim's equivalent for malloc, free and memcopy)
Also Nim does not have 1 GC but several:
- Default Deferred Reference Counting - Not stop the world
- Boehm GC
- Mark and Sweep
- Memory Regions
- Real-time GC (with tunable max-pause)
- GC disabled
GC can also be deactivated per thread (setupForeignThreadGc) or for a section of the code (GC_ref, GC_unref) even on Ref types to improve interoperability with other languages.