Nim programming language release 1.6.0

After a year of development, the release of the Nim 1.6 system programming language has been published, which uses static typing and was created with an eye on Pascal, C ++, Python and Lisp. Nim source code is compiled into a C, C++, or JavaScript representation. Subsequently, the resulting C/C++ code is compiled into an executable file using any available compiler (clang, gcc, icc, Visual C++), which allows you to achieve performance close to C, if you do not take into account the cost of running the garbage collector. Similar to Python, Nim uses indentation as block separators. Metaprogramming tools and capabilities for creating domain-specific languages ​​(DSLs) are supported. The project code is supplied under the MIT license.

Notable changes in the new release include:

  • Added class iterable[T] with type implementation for iterators. template sum[T](a: iterable[T]): T = var result: T for ai in a: result += ai result assert sum(iota(3)) == 0 + 1 + 2 # or 'iota( 3).sum'
  • Added experimental support for ".effectsOf" annotations for selective application of effects. when defined(nimHasEffectsOf): {.experimental: "strictEffects".} else: {.pragma: effectsOf.} proc mysort(s: seq; cmp: proc(a, b: T): int) {.effectsOf: cmp. }
  • A new import syntax "import foo {.all.}" has been proposed, which allows you to import not only public, but also private symbols. To access private fields of objects, the std/importutils module and the privateAccess API have been added. from system {.all.} as system2 import nil echo system2.ThisIsSystem import os {.all.} echo weirdTarget
  • Added experimental support for operators starting with a dot that can be used to implement dynamic fields. import std/json template '.?'(a: JsonNode, b: untyped{ident}): JsonNode = a[astToStr(b)] let j = %*{"a1": {"a2": 10}} assert j.?a1.?a2.getInt == 10
  • It is allowed to specify additional parameters in block arguments. template fn(a = 1, b = 2, body1, body2) = discard fn(a = 1): bar1 do: bar2
  • Implemented support for user-defined literals (eg "-128'bignum'"). func `'big`*(num: cstring): JsBigInt {.importjs: "BigInt(#)".} assert 0xffffffffffffff'big == (1'big shl 64'big) - 1'big
  • The compiler implements the "-eval:cmd" command to directly run Nim commands from the command line, for example, 'nim --eval:"echo 1"'.
  • Provided support for creating custom extensions for the nimscript backend.
  • Error messages have been greatly expanded to show the context associated with the error. Implemented custom compiler warnings.
  • Significantly improved performance of "--gc:arc" and "--gc:orc" garbage collectors.
  • In all backends, the accuracy and performance of the code for parsing integers and floating point numbers has been improved.
  • Improved compatibility of JS, VM and nimscript backends with modules that previously only worked with the C backend (for example, the std/prelude module). Established testing of stdlib modules with C, JS and VM backends.
  • Added support for Apple Silicon/M1 chip, 32-bit RISC-V, armv8l and CROSSOS systems.
  • Added modules std/jsbigints, std/tempfiles and std/sysrand. Significant improvements have been made to the system, math, random, json, jsonutils, os, typetraits, wrapnils, lists, and hashes modules.

Source: opennet.ru

Add a comment