|Nim 1.2 Arrives With New Garbage Collector|
|Written by Ian Elliot|
|Tuesday, 14 April 2020|
There's a new release of Nim, the systems programming language, formerly called Nimrod. This update features a new garbage collector and new sugar macros.
Nim's options include a deferred reference counting garbage collector that is fast, incremental and pauseless; or a soft real-time garbage collector that lets you specify its max pause time. There are now over 1000 packages available for Nim.
The main update to the new release is the ARC GC (Garbage Collector). The Nim team is describing it as "one GC to rule them all", but say that calling it a GC doesn't do it justice, as it's plain old reference counting with optimizations thanks to move semantics. ARC has a number of advantages over the other more classical GC algorithms that Nim 1.0 shipped with, starting with the fact that ARC is independent of the heap size, and the developers say it works well with tiny and enormous heaps. It is also independent of the stack size, and large arrays on the stack do not cause slowdowns. ARC also offers a shared heap, and works with valgrind and clang's address sanitizers. It should also, according to the Nim team, work better with hot code reloading and DLLs, and with fibers, coroutines or whatever C++ ends up providing. Finally, it should work well with webassembly and Emscripten.
The other main improvement to version 1.2.0 is the introduction of several new macros that should help with writing some common tasks. The first addition is Collect, a macro which helps with writing seq/set/table comprehensions. It replaces the lc (list comprehension), and it is both more idiomatic and more powerful than lc.
The second new macro, Dup, turns an in-place function into one that returns a result without modifying its input. The plan is that future versions of Nim will offer only in-place versions of the functions, so there'll be no more sort and sorted, rotateLeft and rotatedLeft, and so on, In-place macros could be transformed to functions returning a copy via dup.
The final new macro, Capture, can be used when creating a closure in a loop to capture some local loop variables by their current iteration values.
Nim 1.2 is available now from the Nim website.
or email your comment to: email@example.com
|Last Updated ( Tuesday, 14 April 2020 )|