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


ZLUDA Ports CUDA Applications To AMD GPUs
18/04/2024

ZLUDA is a translation layer that lets you run unmodified CUDA applications with near-native performance on AMD GPUs. But it is walking a fine line with regards to legality.



Huawei Intends To Challenge iOS and Android
24/04/2024

Huawei has just changed its mind and decided to push its HarmonyOS to the rest of the world. A challenger to iOS and Android would be nice, but it is possible?


More News

raspberry pi books

 

Comments




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