How to install Nim programming language on FreeBSD 12?

Windows Articles

OpenSUSE 15.2 available

Well, another one has come into the family. A new version of OpenSUSE has recently been released. The community distribution under the...

How to install and configure Vagrant in Windows 10

Hello! Vagrant is a free, multi-platform command-line tool, which makes it easy to create reproducible and shareable development environments. Additionally, it creates...

Ubuntu Rolling Release? It is possible with Rolling Rhino

Throughout the Linux community, there are always expectations about when Ubuntu decides to have a Rolling Release. This, at least, since the...

How to recover files deleted with Windows File Recovery

Hello! Deleting files by accident is one of the biggest fears of users. Indeed, unintentionally deleting documents, music or photos can be...

How to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10?

This is a short post in which I will show you how to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10...
angeloma
angeloma
Senior Writer and partner

We recently installed Nim programming language on Debian 10. Now it is FreeBSD 12’s turn.

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 FreeBSD 12.

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 FreeBSD 12

Nim is available in the official FreeBSD 12 repositories, but the latest stable version is not available. So it is recommended that you download the source code and compile it.

However, if you want to install it without any problems, just run the following command:

:~$ sudo pkg install nim

And now you can start working.

However, in this tutorial, what we are looking for is to install the latest stable version. So to do this, you have to download the source code of the language.

To do this, I will use a tool called wget. Then, the first step is to install it.

:~$ sudo pkg install wget
Password:
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 3 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
libidn2: 2.3.0_1
libunistring: 0.9.10_1
wget: 1.20.3

Number of packages to be installed: 3

The process will require 6 MiB more space.
1 MiB to be downloaded.

Proceed with this action? [y/N]:
1.- Install wget on FreeBSD 12
1.- Install wget on FreeBSD 12

When the installation is finished, we can start the download using it. At the time of writing this post, the latest stable version of Nim is 1.2.0.

:~$ wget -c https://nim-lang.org/download/nim-1.2.0.tar.xz
--2020-04-10 06:47:52-- https://nim-lang.org/download/nim-1.2.0.tar.xz
Resolving nim-lang.org (nim-lang.org)... 104.28.18.79, 104.28.19.79, 2606:4700:3036::681c:134f, ...
Connecting to nim-lang.org (nim-lang.org)|104.28.18.79|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5869428 (5.6M) [application/octet-stream]
Saving to: 'nim-1.2.0.tar.xz'
nim-1.2.0.tar.xz 100%[=====================================================================================>] 5.60M 84.4KB/s in 50s
2020-04-10 06:48:43 (115 KB/s) - 'nim-1.2.0.tar.xz' saved [5869428/5869428]
2.- Download Nim on FreeBSD 12
2.- Download Nim on FreeBSD 12

After the download, we have to decompress the file.

:~$ tar xvfj nim-1.2.0.tar.xz

This will generate a folder called nim-1.2.0. Access it and start compiling Nim.

Access it and start compiling Nim.

:~$ cd nim-1.2.0
:~$ sh build.sh
3.- Building the Nim programming language
3.- Building the Nim programming language

Then, the Nim package must be further built to generate the binary for FreeBSD 12.

:~$ bin/nim c koch
4.- Building Nim package
4.- Building Nim package

So, finish the creation of the package with this last command:

~$ ./koch tools
5.- Installing Nim programming language on FreeBSD 12
5.- Installing Nim programming language on FreeBSD 12

Now yes, Nim is installed on FreeBSD 12.

The compiler and tool binaries live inside the bin directory. To test it, access the folder and display the current version.

:~$ cd nim-1.2.0/bin/
:~$ ./nim -version
6.- The Nim version
6.- The Nim version

Testing Nim programming language on FreeBSD 12

Before testing the installation, make Nim available as a command from any location.

To do this, it is advisable to first rename the folder to a simpler one.

:~$ cd ~
:~$ mv nim-1.2.0 nim

If you want you can move it to a more discreet directory. In my case, I’ll leave it right here.

Now to make it available as a command, edit the user profile file.

:~$ nano ~/.profile

And add the following content:

export PATH=/home/angelo/nim/bin:$PATH

Remember to modify the route where Nim is located. In this case, that’s the way it looks to me.

Then log out and log back in.

Now, create a new test file called hello.nim and add the following code:

:~$ nano hello.nim
echo "Hi, Osradar"

Save and close the file.

Then compile it with the following command:

:~$ nim c hello.nim

And run it:

~$ ./hello
7.- Nim working on FreeBSD 12
7.- Nim working on FreeBSD 12

So, Nim is ready for you to use it in your system.

Conclusion

Programming is very important nowadays, so it requires programming languages to match. Today we have taught you how to install Nim on FreeBSD 12 so you can have an ideal partner to make your applications.

Please share this post and join our Telegram channel.

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

OpenSUSE 15.2 available

Well, another one has come into the family. A new version of OpenSUSE has recently been released. The community distribution under the...

How to install and configure Vagrant in Windows 10

Hello! Vagrant is a free, multi-platform command-line tool, which makes it easy to create reproducible and shareable development environments. Additionally, it creates...

Ubuntu Rolling Release? It is possible with Rolling Rhino

Throughout the Linux community, there are always expectations about when Ubuntu decides to have a Rolling Release. This, at least, since the...

How to recover files deleted with Windows File Recovery

Hello! Deleting files by accident is one of the biggest fears of users. Indeed, unintentionally deleting documents, music or photos can be...

How to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10?

This is a short post in which I will show you how to install Vivaldi Web Browser on Ubuntu 20.04 / 19.10...