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 is strongly typed and has first class functions. It is object-oriented, but with composition preferred over inheritance. Nim compiles to C as its default, but can be used with different compiler back-ends to produce JavaScript, C++, or Objective-C.

nim

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.

 

nim

More Information

Nim 1.2 Download

Nim Language Site

Related Articles

Nim Reaches 1.0

Nim Reaches Release Candidate Stage 

Nim Improves Async  

Nim 0.15

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Apple Loosens Its Grip On The App Store But By A Tiny Amount
01/09/2021

This isn't the big result that the Epic Games lawsuit or any of the many anti-trust investigations may result in, but a tiny concession given by Apple in the face of a losing court battle.



JetBrains Data Science IDE Now Open To All
20/09/2021

JetBrains is opening up its new IDE for data scientists so anyone can try it out. Until now its only been available for invites to a private early access program. 


More News

square

 



 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 14 April 2020 )