Nowadays, almost everything is done with the help of a computer and a program. And the programs are made through a programming language. That is why it must be efficient languages with new technical features that can be brought to the program and the end-user. Today we will teach you how to install Nim programming language on Debian 10.
To quote the website of this programming language:
Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada, and Modula.
This gives us a pretty good idea that the language meets everything needed to create modern applications.
Like all modern languages, it has versions for Windows, Linux, macOS, and BSD. This makes it possible to run on almost all current systems. This also makes it possible for the programmer to choose the environment where he feels best.
Nim is an object-oriented language with a syntax similar to Python‘s with even similar characteristics.
So, let us get to work.
Installing Nim programming language on Debian 10
In Debian 10 Nim is included in the official repositories. Therefore the installation becomes quite simple and is summarized too in
:~$ sudo apt install nim
However, this method is not recommended because the latest Nim version is not installed.
So there is another method that allows us to install the latest stable version, but also the development version.
To install it, there is a script that we have to download and run but first, we have to install the Debian compilation packages.
So, open a terminal and execute the following command
:~$ sudo apt install build-essential Reading package lists… Done Building dependency tree Reading state information… Done The following additional packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-8 dpkg-dev fakeroot g++ g++-8 gcc gcc-8 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-8-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpfr6 libmpx2 libquadmath0 libstdc++-8-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev patch Suggested packages: binutils-doc cpp-doc gcc-8-locales debian-keyring g++-multilib g++-8-multilib gcc-8-doc libstdc++6-8-dbg gcc-multilib autoconf automake libtool flex bison gdb gcc-doc gcc-8-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan5-dbg liblsan0-dbg libtsan0-dbg libubsan1-dbg libmpx2-dbg libquadmath0-dbg glibc-doc git bzr libstdc++-8-doc make-doc ed diffutils-doc The following NEW packages will be installed: binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-8 dpkg-dev fakeroot g++ g++-8 gcc gcc-8 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-8-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpfr6 libmpx2 libquadmath0 libstdc++-8-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev patch 0 upgraded, 40 newly installed, 0 to remove and 54 not upgraded. Need to get 49.4 MB of archives. After this operation, 185 MB of additional disk space will be used. Do you want to continue? [Y/n]
When the installation is finished, we will be able to execute the installation script.
:~$ curl https://nim-lang.org/choosenim/init.sh -sSf | sh choosenim-init: Downloading choosenim-0.6.0_linux_amd64 Downloading Nim 1.2.0 from nim-lang.org [##################################################] 100.0% 0kb/s Extracting nim-1.2.0-linux_x64.tar.xz Building Nim 1.2.0 Compiler: Already built Tools: Already built Installed component 'nim' Installed component 'nimble' Installed component 'nimgrep' Installed component 'nimpretty' Installed component 'nimsuggest' Installed component 'testament' Switched to Nim 1.2.0 choosenim-init: ChooseNim installed in /home/angelo/.nimble/bin choosenim-init: You must now ensure that the Nimble bin dir is in your PATH. choosenim-init: Place the following line in the ~/.profile or ~/.bashrc file. choosenim-init: export PATH=/home/angelo/.nimble/bin:$PATH
In case curl is not installed you can install it with the following command:
:~$ sudo apt install curl
Then have Nim installed. We have to make it available throughout the system.
So edit the
:~$ nano ~/.profile
And add the following:
"your-home" with your username or home.
Save the changes and close the file.
Appley the change by running:
:~$ nim -v Nim Compiler Version 1.2.0 [Linux: amd64] Compiled at 2020-04-03 Copyright (c) 2006-2020 by Andreas Rumpf active boot switches: -d:release
Testing Nim Installation
Now it is time to test if the installation has worked.
So we’ll create the classic test program by displaying a message. This will serve the purpose.
The code files for the Nim language, they have a nim extension. So we will create one:
:~$ nano hello.nim
And within this file add the following content:
echo "Hi, Osradar"
Save the changes and close the file.
Now, compile the source file to generate the executable binary.
:~$ nim c hello.nim Hint: used config file '/home/angelo/.choosenim/toolchains/nim-1.2.0/config/nim.cfg' [Conf] Hint: system [Processing] Hint: widestrs [Processing] Hint: io [Processing] Hint: hello [Processing] Hint: gcc -c -w -I/home/angelo/.choosenim/toolchains/nim-1.2.0/lib -I/home/angelo -o /home/angelo/.cache/nim/hello_d/stdlib_io.nim.c.o /home/angelo/.cache/nim/hello_d/stdlib_io.nim.c [Exec] Hint: gcc -c -w -I/home/angelo/.choosenim/toolchains/nim-1.2.0/lib -I/home/angelo -o /home/angelo/.cache/nim/hello_d/stdlib_system.nim.c.o /home/angelo/.cache/nim/hello_d/stdlib_system.nim.c [Exec] Hint: gcc -c -w -I/home/angelo/.choosenim/toolchains/nim-1.2.0/lib -I/home/angelo -o /firstname.lastname@example.org /email@example.com [Exec] Hint: [Link] Hint: 14211 LOC; 3.140 sec; 15.887MiB peakmem; Debug build; proj: /home/angelo/hello.nim; out: /home/angelo/hello [SuccessX]
Remember that you have to specify the source file but also the full path.
Then, run it as follows:
So now we know that nim works and you can start working with him.
Programming is very important nowadays, so it requires programming languages to match. Today we have taught you how to install Nim on Debian 10 so you can have an ideal partner to make your applications.
Please share this post and join our Telegram channel.