A new version of the system programming language Nim has been released, which this September marks one year since its first stable version was launched. in September 2021.. The syntax of the language is similar to Python, while its performance is nearly on par with C++. According to FAQ the language borrows heavily from (in order of contribution): Modula 3, Delphi, Ada, C++, Python, Lisp, and Oberon.
It works everywhere thanks to its ability to compile into C/C++/Objective-C/JS. It supports macros, OOP, generics, exceptions, hot code swapping and much more. License — MIT.
The most significant changes include:
-
A new garbage collector ORC has been introduced, utilizing an algorithm from ARC, but specifically handling circular references. It can be enabled with the option —gc:orc. For differences between ARC and ORC, there's a great article.
A strict function definition mode has been added, which activates additional checks for object mutability. It is enabled using the pragma {.experimental: "strictFuncs".} or with the key —experimental:strictFuncs.
The keyword from can now be used as an operator.
The pragma .noalias has been introduced. It corresponds to the C keyword restrict, to enhance performance that can be provided by this keyword.
Specific warnings can now be turned into errors via —warningAsError[X]:on|off.
A new command: nim r main.nim [args…], which compiles and runs main.nim, and includes —usenimcache, so that the result is stored in $nimcache/main$exeExt, using the same logic as nim c -r to avoid recompilation when the sources haven't changed. Example:
nim r compiler/nim.nim —help # compiled for the first time
echo ‘import os; echo getCurrentCompilerExe()’ | nim r — # this works too
nim r compiler/nim.nim —fullhelp # without recompilation
nim r —nimcache:/tmp main # binary saved to /tmp/main
A new hint —hint:msgOrigin has been added, which will indicate where the compiler generated error/warning messages. This helps when it’s not obvious where the message came from.
A flag —backend:js|c|cpp|objc (or -b:js etc.) has been added to change the backend.
A flag —usenimcache has been introduced for outputting binaries into nimcache.
The keys: —oldNewlines, —laxStrings, —oldast, —oldgensym have been removed.
The nimsuggest tool now shows not only the preliminary declaration but also the location of the implementation upon request def.
In addition, many changes have been made to the standard library and numerous bug fixes.
Source: linux.org.ru
