16 C
Texas
angeloma
Senior Writer and partner

How to install the V programming Language on Ubuntu 20.04 / Debian 10?

Last year we talked about the V programming language. Now that it is in a more mature phase of development, we will teach you how to install it in Ubuntu 20.04 / Debian 10.

The V Programming Language

In short, this programming language is quite small but surprisingly fast. This does not mean you can’t do interesting things with it. The project website describes it as “Simple, fast, safe, compiled language for developing maintainable software.”

Some of the main characteristics of this language are the following:

  • Secure. Because it does not allow global variables, null values, strange behaviors of functions, nor undefined values.
  • Fast. I think this is V’s main point. It can compile 1.5 Million lines of code per processor core. It is wonderful.
  • Code translation from C. If you have a project from C, you can convert the source code to V, without any problem.
  • Compiler with 0 dependencies. All in just 400 kb.
  • Hot Code Reload. It is not necessary to compile frequently to get the desired changes. Of course, in some cases yes, where there are many lines of codes.

The development of this programming language that can be as fast as C but taking advantage of newer technologies is very active. This has improved in features and stability to date.

- Advertisement -

Now, it is perfectly usable and it is time to install it in Ubuntu 20.04 / Debian 10.

Install the V programming language on Ubuntu 20.04 / Debian 10

From the Github profile of the project, we are told that the best way to install V is by compiling the source code. Something quite simple to do the truth.

First, open a terminal session and install the basic packages for the compilation.

:~$ 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 dirmngr dpkg-dev fakeroot g++ g++-8 gcc gcc-8 gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client
gpg-wks-server gpgconf gpgsm libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libassuan0 libatomic1 libbinutils libc-dev-bin
libc6-dev libcc1-0 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-8-dev libgomp1 libisl19 libitm1 libksba8 liblsan0 libmpc3 libmpfr6 libmpx2 libnpth0
libquadmath0 libstdc++-8-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev patch pinentry-curses
Suggested packages:
binutils-doc cpp-doc gcc-8-locales pinentry-gnome3 tor 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 parcimonie xloadimage scdaemon glibc-doc git bzr libstdc++-8-doc make-doc ed diffutils-doc pinentry-doc
The following NEW packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-8 dirmngr dpkg-dev fakeroot g++ g++-8 gcc gcc-8 gnupg gnupg-l10n gnupg-utils gpg gpg-agent
gpg-wks-client gpg-wks-server gpgconf gpgsm libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libassuan0 libatomic1 libbinutils
libc-dev-bin libc6-dev libcc1-0 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-8-dev libgomp1 libisl19 libitm1 libksba8 liblsan0 libmpc3 libmpfr6 libmpx2
libnpth0 libquadmath0 libstdc++-8-dev libtsan0 libubsan1 linux-libc-dev make manpages-dev patch pinentry-curses
0 upgraded, 54 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.4 MB of archives.
After this operation, 200 MB of additional disk space will be used.
Do you want to continue? [Y/n]
1.- Install the build essentials package
1.- Install the build essentials package

V also requires the C compiler to be installed. You probably already have it installed, but with the previous command, you will have already installed it.

To download the V source code for later compilation, we will clone the entire project. Therefore, you need to have Git installed.

To install Git, just run the following command:

:~$ sudo apt install git

However, you may be interested in installing the latest stable version available, for that you can read our posts:

How to install Git on Debian 10?

How to install Git on Ubuntu 20.04?

Once Git is successfully installed, we proceed to clone the repository.

:~$ git clone https://github.com/vlang/v
Cloning into 'v'...
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 32508 (delta 2), reused 3 (delta 0), pack-reused 32493
Receiving objects: 100% (32508/32508), 12.90 MiB | 50.00 KiB/s, done.
Resolving deltas: 100% (22885/22885), done.
2.- Cloning the repository of V
2.- Cloning the repository of V

A folder called “v” will now be generated at the site where the prompt was located. In this case, it is in the personal folder. You can move it anywhere you want.

Then, access the generated folder and compile the code.

:~$ cd v/
:~$ make
3.- Installing V programming language on Ubuntu 20.04 / Debian 10
3.- Installing V programming language on Ubuntu 20.04 / Debian 10

This will generate an executable called v. It is convenient to make a symbolic link to this file so that it can be used as a command from any location.

:~$ sudo ./v symlink

Now you can verify the use of the command.

:~$ v
For usage information, quit V REPL using `exit` and use `v help`
V 0.1.28 d4f0fe1
Use Ctrl-C or `exit` to exit
>>>
4.- V programming language on Ubuntu 20.04 / Debian 10
4.- V programming language on Ubuntu 20.04 / Debian 10

And to verify that the compiler is doing its job, we can run the “hello world” example from the examples folder that comes with the code clone.

:~$ cd v/examples/
:~$ v hello_world.v && ./hello_world
Hello, World!
5.- Hello world from V
5.- Hello world from V

V is being constantly updated. To update V, simply run:

:~$ v up

So, that is it. Enjoy the V programming language.

Conclusion

The V programming language has many important features such as the speed of compilation. It is the kind of project that only needs a boost to gain many followers. Now that you know how to install it on Ubuntu 20.04 / Debian 10, you can explore all its possibilities.

Please share this post and join our Telegram channel.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article