Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to install Nim programming language on Debian 11

Hello, dear readers. Today, you will learn how to install the Nim programming language on Debian 11.

Nim is a programming language that has been inspired by Delphi. Therefore, it is a compiled language that focuses on efficiency, ease of reading source code and flexibility.

Nim combines successful concepts from mature languages like Python, Ada and Modula. In addition to this, it is open source, so we can examine its source code.

We could say that Nim is a new language that promises to incorporate improvements and alternatives to what already exists. For example, it can be integrated for backend functions with Python, C and others.

Another thing that favors Nim is that the installation process is simple. So let’s go for it.

Installing the Nim programming language in Debian 11

The development of the language advances constantly, and it is already present in the Debian repositories. Therefore, you just have to open a terminal and run

sudo apt install nim

This way the compiler will already be installed.

However, before I said that the development of Nim advances and although the previous command is simple and effective, it does not provide us with the latest stable version.

For this, then it is better to use the installation script provided by the developers.

First, install all the packages needed to compile and build packages.

sudo apt install build-essential

Then, download and run the language installation script.

curl https://nim-lang.org/choosenim/init.sh -sSf | sh
1.- Installing Nim Programming Language on Debian 11
1.- Installing Nim Programming Language on Debian 11

During the process, you will see a question about sending data anonymously to the developers to contribute to the development. This is optional, and you can answer Y or N as you wish.

Then the process will continue and at the end you will notice that you are asked to edit the ~/.profile file to add the Nim installation directory to the PATH.

So edit the file

nano ~/.profile

And at the end of the file, add the following line.

export PATH=/home/angelo/.nimble/bin:$PATH

Don’t forget that you have to replace angelo with the name of your user.

Thereafter, apply the changes by running

source ~/.profile

Finally, you will be able to verify the use of the nim command.

nim -v
2.- Nim version
2.- Nim version

So, Nim is installed and working properly.

Creating our first program with the Nim programming language in Debian 11.

The best way to test Nim is to create a small program. So, we will make a “Hello World”.

Create the source file

nano example.nim

And add the following

echo "Hi, welcome to unixcop.com"

Save the changes and close the editor.

Compile the file using this command

nim c example.nim

Now run it:

./example
3.- Compiling a Nim program
3.- Compiling a Nim program

So, Nim is ready, and you can use it now.

Conclusion

Thanks to this post, you learned how to install Nim. This modern programming language aims to give us a flexible alternative to the most popular languages.

1 COMMENT

  1. Of note, that install fail using curl WILL fail if your hardware architecture is ARM, AARCH64, or anything not explicitly supported by the main language maintainers. AARCH64 versions may be available in your REPO, but are likely to be an older release.
    One would think that in 2022 authors would mention such limitations without prompting!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook

x