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. 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. More InformationRelated ArticlesNim Reaches Release Candidate Stage 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.
Comments
or email your comment to: comments@i-programmer.info |