Introduced release of the system programming language Nim 2.4.0. Nim is a statically typed compiled programming language with Python-inspired syntax and Lisp-level metaprogramming capabilities. The language compiles to C, C++, and JavaScript, delivering C-level performance with the expressiveness of high-level languages. The project code is provided under the MIT license.
Nim features include a system of macros running on AST at compile time, support for generic programming with concepts, multiple dispatch, deterministic memory management with support for multiple strategies (ARC/ORC, refc, mark-and-sweep), built-in async/await support for asynchronous programming, and FFI for easy integration with C/C++/JavaScript. Nim is positioned as a system language suitable for development from embedded systems to web servers, with an emphasis on efficiency, memory safety and ease of development.
Main changes:
- Implemented a short-string optimization mode (SSO, Small-String Optimization), enabled via the “–strings:sso” option and resulting in storing small strings directly in the object itself, without separate memory allocation in heap. To effectively use this mode, a new low-level API has been proposed, in which, instead of the “addr myString[offset]” syntax, separate operations for reading and writing (readRawData, readRawDataStable, beginStore and endStore) are proposed. For example, when using the new API, the operations “addr s[i]” and “unsafeAddr s[i]” are replaced by the call “readRawData(s, i)”, and the combination of “setLen” and “addr s[oldLen]” is replaced by “beginStore(s, newLen, start)” followed by “endStore(s)”. # Before: set the length and copy to the address of the string element result.setLen newLen copyMem(addr result[oldLen], buf, buflen) # After: beginStore sets the length, provides unique # ownership, and returns a pointer to the write; endStore ends the recording copyMem(beginStore(result, newLen, oldLen), buf, buflen) endStore(result)
- Implemented support for parallel and incremental assembly, activated via the “–ic:on” option. Parallelization is implemented using multiprocessing rather than multithreading, so macros that use global “.compileTime” variables may require work