5 min read

Yesterday, the Nim team announced the release of Nim version 0.20.0. Nim is a statically typed compiled systems programming language, which successfully combines the concepts from mature languages like Python, Ada and Modula.

This is a massive release from Nim, with more than 1,000 commits. Nim version 0.20.0 is effectively Nim 1.0 RC1. The team has also mentioned that the stable release 1.0 will either be, the Nim 0.20.0 being promoted to 1.0 status or another release candidate, as there will be no more breaking changes. Also, version1.0 will be a long-term supported stable release and will only receive bug fixes and new features in the future, as long as it doesn’t break backwards compatibility.

New Features

  • not is always a unary operator
  • Stricter compile time checks for integer and float conversions
  • Tuple unpacking for constant and for loop variables
  • Hash sets and tables are initialized by default
  • Better error message for case-statements
  • The length of a table must not change during iteration
  • Better error message for index out of bounds

Changelog

  • The Nim version 0.20.0 includes many changes affecting backwards compatibility. One of the changes is that strutils.editDistance has been deprecated, instead editdistance.editDistance or editdistance.editDistanceAscii to be used instead.
  • One of the breaking changes in the standard library includes osproc.execProcess now also takes a workingDir parameter and std/sha1.secureHash will now accept openArray[char], and not string.
  • There are few breaking changes in the compiler too. One of the main changes is that the compiler now implements the “generic symbol prepass” for when statements in generics.

Library additions

There are many new library additions in this release. Some of them are mentioned below:

  • stdlib module std/editdistance as a replacement for the deprecated strutils.editDistance.
  • stdlib module std/wordwrap as a replacement for the deprecated strutils.wordwrap.
  • Added split, splitWhitespace, size, alignLeft, align, strip, repeat procs and iterators to unicode.nim.
  • Added or for NimNode in macros
  • Added system.typeof for more control over how type expressions can be deduced.

Library changes

Many changes have been made in the library. Some of them are mentioned below:

  • The string output of macros.lispRepr proc has been tweaked slightly. The dumpLisp macro in this module now outputs an indented proper Lisp, devoid of commas.
  • Added macros.signatureHash that returns a stable identifier derived from the signature of a symbol.
  • In strutils empty strings now no longer match as substrings
  • The Complex type is now a generic object and not a tuple anymore.
  • The ospaths module is now deprecated, use os instead. Note that os is available in a NimScript environment but unsupported operations produce a compile-time error.

Language additions

There have been new additions to the language as well. Some of them are mentioned below:

  • Vm support for float32<->int32 and float64<->int64 casts was added.
  • There is a new pragma block noSideEffect that works like the gcsafe pragma block
  • User defined pragmas are now allowed in the pragma blocks
  • Pragma blocks are no longer eliminated from the typed AST tree to preserve pragmas for further analysis by macros.

Language changes

  • The standard extension for SCF (source code filters) files was changed from .tmpl to .nimf.
  • Pragma syntax is now consistent. Previous syntax where type pragmas did not follow the type name is now deprecated. Also pragma before generic parameter list is deprecated to be consistent with how pragmas are used with a proc.
  • Hash sets and tables are initialized by default. The explicit initHashSet, initTable, etc. are not needed anymore.

Tool changes

  • jsondoc now includes a moduleDescription field with the module description. jsondoc0 shows comments as its own objects as shown in the documentation.
  • nimpretty: –backup now defaults to off instead of on and the flag was undocumented; use git instead of relying on backup files.
  • koch now defaults to build the latest stable Nimble version unless you explicitly ask for the latest master version via –latest.

Compiler changes

  • The deprecated fmod proc is now unavailable on the VM
  • A new –outdir option was added
  • The compiled JavaScript file for the project produced by executing nim js will no longer be placed in the nimcache directory.
  • The –hotCodeReloading has been implemented for the native targets. The compiler also provides a new more flexible API for handling the hot code reloading events in the code.
  • The compiler now supports a –expandMacro:macroNameHere switch for easy introspection into what a macro expands into.
  • The -d:release switch now does not disable runtime checks anymore. For a release build that also disables runtime checks use -d:release -d:danger or simply -d:danger.

The Nim version 0.20.0 also contains many bug fixes.

Most developers are quite delighted with the release of Nim version 0.20.0.

A user on Hacker News states that “It’s impressive. 1000 commits! Great job Nim team!”

Another user comments, “I’ve been full steam on the Nim train for the past year. It really hits a sweet spot between semantic complexity and language power. If you’ve used any mainstream language and understand types, you already understand 80% of the semantics you need to be productive. But more advanced features (generics, algebraic data types, hygienic macros) are available when needed. Now that the language is approaching 1.0, the only caveat is a small ecosystem and community. Nim has completely replaced Node as my language of choice for side projects and prototyping.”

While there are some users who still prefer Python, for its strong command language, a user says that “It seems to me that the benefits of Nim over Python are far smaller than the benefits of Python’s library ecosystem. I’m pretty happy with Python though. It seems like Nim’s benefits couldn’t be that big. I consider Python “great”, so the best Nim could be is “great-er”, as a core language I mean. I’ve been rooting for Nim, but haven’t actually tried it. And my use case is pretty small, I admit.”

These are select few updates. More information on the Nim blog.

Read Next

Containers and Python are in demand, but Blockchain is all hype, says Skill Up developer survey

Apple releases native SwiftUI framework with declarative syntax, live editing, and support of Xcode 11 beta

Storm 2.0.0 releases with Java enabled architecture, new core and streams API, and more

A born storyteller turned writer!