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


OpenAI Releases Swarm
25/10/2024

OpenAI has released an experimental educational framework for exploring ergonomic, lightweight multi-agent orchestration. Swarm is managed by the OpenAI Solution team, but is not intended to be used i [ ... ]



Microsoft Introduces Vector Abstractions Library For .NET
21/11/2024

Microsoft has announced a preview release of the Microsoft Extensions VectorData Abstractions library, which can be used to help integrate vector stores into .NET applications and libraries.


More News

espbook

 

Comments




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

Last Updated ( Tuesday, 14 April 2020 )