Nim is a programming language that has been with us for some time. Although not so popular, it is a great alternative to other known languages. So, in this post, I will explain some things about Nim programming Language.
What is Nim?
Taking as reference the project website:
Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula.
From the above we can deduce that it is object-oriented and has a syntax similar to Python with concepts taken from C++ or Rust.
An example of the above is that memory management is deterministic and customizable with destructors and move semantics, inspired by C++ and Rust. This makes Nim suitable for use in applications and systems with high workloads.
Nim is also adaptable to many workflows since it has binaries available for Windows, macOS and of course Linux.
Relevant features of Nim
Nim is quite flexible and some of its features are:
- Self-contained: the compiler and the standard library are implemented in Nim
- Open Source: It is a language that everyone can access its source code.
- Flexible: You can use it in applications, scripts, configurations, and even system components. So, the possibilities are very high.
Of course, these are some main features of Nim, but there are many others that you will discover little by little as you use it.
Install Nim programming Language on Linux
In some Linux distributions, such as Debian 11, the language is in the official repositories. However, this is not the case for everyone, so there is a bash script that makes the whole process easier.
First, install the basic package building packages (Debian, Ubuntu and derivatives)
sudo apt install build-essential
Or for RHEL-based distributions
sudo dnf group install "Development Tools".
For OpenSUSE you just need to run:
sudo zypper install -t pattern devel_basis
Now download and run the installation script:
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
Of course, you have to install the
curl package on your distribution to download it.
If you want to contribute to the project, then answer Y when asked about sending statistics to the developers.
The process will continue normally. On the output screen, you will see part of the process and what the script did.
To complete the configuration, we have to add the Nim installation directory to the PATH, so we can use it without problems.
And at the end of the file, add the following
user with the name of your user. Save the changes and close the editor.
To apply the changes, you have to run
Finally, check the installed version:
Nim Compiler Version 1.6.6 [Linux: amd64] Compiled at 2022-05-05 Copyright (c) 2006-2021 by Andreas Rumpf git hash: 0565a70eab02122ce278b98181c7d1170870865c active boot switches: -d:release
Testing Nim installation
To test the Nim installation, the most sensible thing to do is to create a new program and run it. A “Hello World” will suffice.
Create the file
And inside it, add some content. A greeting, for example:
echo "Hi, welcome to unixcop.com"
Save the changes and compile the program
nim c hello.nim
Finally, run it
Hi, welcome to unixcop.com
As you can see, the program works properly and without issues.
Uninstall Nim programming language on Linux
you would rather not to use Nim anymore, the best thing to do is to remove it from the system. To achieve this, delete the installation folder.
rm -r ~/.nimble
And delete the line you have added in the
When you do this, apply the changes
Then there will be no trace of Nim on the system.
Nim is a solid alternative supported by many companies for all kinds of tasks on various systems. Linux is no exception, and it is possible to install it without too many issues.
I hope you liked this post and help to share it.