Nim 2 Released
Written by Alex Denham   
Thursday, 03 August 2023

There's a new release of Nim, the systems programming language, with improvements including ORC memory management as a default.

Nim, formerly called Nimrod, 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

The list of improvements to Nim 2 start with the inclusion of ORC memory managemen by default. ORC was added experimentally in an earlier release of Nim, and was created by combining the existing ARC (Automatic Reference Counting (ARC)) algorithm with a cycle collector.

Describing the technique on nim-lang.github.io, Andreas Rumpf says that reference cycles are handled by a cycle collection mechanism based on "trial deletion". He explains that entire subgraphs are moved between threads, and that the Nim compiler also aggressively optimizes away RC ops and exploits move semantics.

Other improvements to this release include better tuple unpacking. Tuple unpacking for variables is now treated as syntax sugar that directly expands into multiple assignments. In addition, tuple unpacking for variables can now be nested.

There's an improved type inference called top-down inference that has been implemented for a variety of basic cases, and tag tracking now supports the definition of forbidden tags. 

Several library modules have been overhauled, including the os module, where some of its features are available under a new interface that introduces a Path abstraction.

Elsewhere, support for default values for objects means that fields can now have default values inside an object definition.

The developers have added a new experimental switch to guard agains errors introduced by Nim's default initialization rule. When the switch is enabled, variables have to have been given a value explicitly before they can be used.

Nim has also got improved error messages for type mismatch.

Nim 2.0 is available now from the Nim website.

nim

More Information

Nim 2 On GitHub

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


Rust Twice As Productive As C++
03/04/2024

Google director of engineering, Lars Bergstrom, gave a talk at the recent Rust Nation UK conference and claimed that Rust was twice as productive as C++. Given how good Google is at C++, this is quite [ ... ]



Conference Times Ahead
29/03/2024

Following a well-established pattern both Google's and Microsoft's Developer Conferences will take place in May while Apple follows on in June. Here are the dates plus what to expect.


More News

raspberry pi books

 

Comments




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