Nim (programming language)

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level system programming language,[9] designed and developed by a team around Andreas Rumpf.

Nim is designed to be "efficient, expressive, and elegant",[10] supporting metaprogramming, functional, message passing,[11] procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

[13] Nim includes multiple tunable memory management strategies, including tracing garbage collection, reference counting, and fully manual systems, with the default being deterministic reference counting with optimizations via move semantics and cycle collection via trial deletion.

[15][Nim] ... presents a most original design that straddles Pascal and Python and compiles to C code or JavaScript.

[23] The compiler is free and open-source software, and is being developed by a community of volunteers working with Andreas Rumpf.

On August 1, 2023, version 2.0 of Nim was released, signifying the completion, stabilization of, and switch to the ARC/ORC memory model.

With the goal of improving upon its influence languages, even though Nim supports indentation-based syntax like Python, it introduced additional flexibility.

Nim is almost fully style-insensitive; two identifiers are considered equal if they only differ by capitalization and underscores, as long as the first characters are identical.

The Nim compiler can also emit C++, Objective-C, and JavaScript code to allow easy interfacing with application programming interfaces (APIs) written in those languages;[9] developers can simply write in Nim, then compile to any supported language.

The list of packages is stored in a JavaScript Object Notation (JSON) file which is freely accessible in the nim-lang/packages repository on GitHub.

This JSON file provides Nimble with a mapping between the names of packages and their Git or Mercurial repository URLs.

[21]: 130–131 c2nim is a source-to-source compiler (transcompiler or transpiler) meant to be used on C/C++ headers to help generate new Nim bindings.

[40] The output is human-readable Nim code that is meant to be edited by hand after the translation process.

It downloads any Nim stable or development compiler version from the command line, enabling easy switching between them.

It supports many image formats, blending, masking, blurring, and can be combined with the boxy library to do hardware accelerated rendering.

nimterop is a tool focused on automating the creation of C/C++ wrappers needed for Nim's foreign function interface.

Language bindings exist for many libraries, including GTK,[50][51] Qt QML,[52] wxWidgets,[53] SDL 2,[54][55] Raylib,[56] Godot,[57] UE5,[58] Cairo,[59] OpenGL,[60] Vulkan,[61] WinAPI,[62] zlib, libzip, OpenSSL and cURL.

There are open source tools of various degree of support that can be used to interface Nim with Lua,[64] Julia,[65] Rust,[66]

program in Nim: Another version of "Hello World" can be accomplished by calling the write function with the stdout stream:

[77]Despite being primarily an imperative and functional language, Nim supports various features for enabling object-oriented paradigms.

Objects may be made public on a per-field basis, providing for encapsulation.Static dispatch is preferred, more performant, and standard even among method-looking routines.

Nim macros are powerful and can operate on the abstract syntax tree before or after semantic checking.

Both C++ and Objective-C are based on and compatible with C, but JavaScript is incompatible, as a dynamic, client-side web-based language.

An example of an asynchronous HTTP server:Nim has an active community on the self-hosted, self-developed official forum.

[85] There are also official online chat rooms, bridged between IRC, Matrix, Discord, Gitter, and Telegram.

It was held digitally due to COVID-19, with an open call for contributor talks in the form of YouTube videos.

[87] The conference began with language overviews by Nim developers Andreas Rumpf and Dominik Picheta.

Presentation topics included talks about web frameworks, mobile development, Internet of things (IoT) devices, and game development, including a talk about writing Nim for Game Boy Advance.

[89] NimConf 2021 occurred the following year, was also held digitally, and included talks about game development, REPLs, real-time operating systems, Nim in the industry, object-relational mapping (ORM), fuzzing, language design, and graphics libraries.

[91][92][93] Four speakers represented Nim at FOSDEM 2020, including the creator of the language, Andreas Rumpf.