NIM,the newsprung PL

Designed and developed by Andreas Rumpf, NIM (version 0.16.0), formerly called as NIMROD was released on 8th January this year. NIM encapsulates the best features of the programming languages like Oberon, C#, Go, python, Rust. It is a statically typed, imperative programming language that tries to give the programmer ultimate power without compromises on runtime efficiency.

The initial development of NIM began in 2005. The first version of the NIM compiler was written in Pascal. In 2008, a version of the compiler written in NIM was released. The compiler is open source and is being developed by a group of volunteers in addition to Andreas Rumpf.

NIM has a simple syntax similar to python. It is object oriented and uses strong types and first class functions as in Go and Rust. The functions can be generic and they can be overloaded too. Operator overloading too is supported. It supports compile-time metaprogramming features such as syntactic macros and term rewriting macros. NIM includes automatic garbage collection based on deferred reference counting with cycle detection.

The Nim compiler emits optimized C code and defers compiling to an external compiler.

NIM uses Nimble, the package manager to package the NIM modules. NIM’s primary source of repositories is Git.

A NIM program can use any library which can be used in a C program. There are existing bindings for many libraries, for example GTK+2, SDL2, Cairo, OpenGL, WinAPI, zlib, libzip, OpenSSL and cURL. NIM works with PostgreSQL, MySQL and SQLite databases. NIM can interface with the Lua and Python interpreter. The tool c2nim helps to generate new bindings from C code.

Here follows an example NIM program

# This is a comment

echo “What’s your name? “

var name: string = readLine(stdin)

echo “Hi, “, name, “!”

Save this code to the file “greetings.nim”. Then compile and run the program(run command  NIM executes the file automatically after compilation).

nim compile –run greetings.nim


2 thoughts on “NIM,the newsprung PL

Leave a Reply

Your email address will not be published. Required fields are marked *