Brief: This article guide takes us through the necessary steps needed to install and configure Julia programming language on Ubuntu 22.04/20.04 systems. The article also demonstrates how to get started with Julia by running a simple Julia program.
Julia is a considerably new, fast, and high-level programming language intended to unriddle scientific and highly advanced computation problems. It is famous in scientific research, machine learning, data science, visualization, and also for more general-purpose application building.
The official site offers a live demo of Julia language to try out, but for efficient use and development, you will need to install it onto your Linux system.
In a nutshell, Julia programming language is associated with the following features:
- Fast – With high performance being one of its prioritized design objectives, LLVM (compiler backend) makes it possible to efficiently compile Julia programs for multiple platforms from native code.
- Dynamic – Julia gives its users an interactive feel due to its dynamically typed attribute that gives the perception of a scripting language.
- Reproducible – With pre-built binaries, users are able to each time recreate an already-existing Julia environment (reproducible environments).
- Composable – Functional and object-oriented programming patterns are easily expressed in Julia via the multiple dispatch paradigms. This paradigm has proven to be unreasonably effective.
- General – Julia makes it possible to build entire Microservices and Applications via its provision of package manager, logging, metaprogramming, profiling, debugging, and asynchronous I/O functional features.
- Open Source – With 1000+ contributors associated with this open-source project, the MIT license covers Julia’s source code available on the Github platform.
Step 1 – Installing Julia in Ubuntu
It is highly advised to use the official pre-compiled binaries (current stable release) to install Julia on Linux systems.
The following wget command will download the latest version of Julia in your current directory, then extract and install it as shown.
$ wget https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.2-linux-x86_64.tar.gz $ tar zxvf julia-1.8.2-linux-x86_64.tar.gz $ cd julia-1.8.2
Think of this directory as your primary Julia installation directory. Deleting it is the same as uninstalling Julia from your system.
Step 2 – Adding Julia to System Path
For your Ubuntu system to find Julia’s executable, the PATH environment variable file ~/.bashrc should contain the full path to Julia’s bin directory (julia-1.8.2/bin):
$ ls -l $HOME/Downloads/julia-1.8.2/bin
Open the ~/.bashrc file using the nano editor or your preferred text editor:
$ nano ~/.bashrc
and add Julia’s bin directory path at the bottom:
export PATH="$PATH:$HOME/Downloads/julia-1.8.2/bin"
Update the ~/.bashrc file for the Ubuntu system to be able to trace Julia’s executable.
$ source ~/.bashrc
Step 3 – Running the Julia REPL
To confirm Julia’s correct configuration on your Ubuntu system, we need to initiate an interactive REPL (Read Evaluate Print Loop) session by executing its binary file:
$ julia _ _ _ _(_)_ | Documentation: https://docs.julialang.org (_) | (_) (_) | _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help. | | | | | | |/ _` | | | | |_| | | | (_| | | Version 1.8.2 (2022-09-29) _/ |\__'_|_|_|\__'_| | Official https://julialang.org/ release |__/ | julia>
From the julia shell session, we can even perform some simple arithmetic to test its validity:
julia> 34+56 90
Use Ctrl+D
to exit the julia session.
Step 4 – Testing a Simple Julia Program
Julia files/programs have the .jl
file extension. We can create a sample Julia program in the following manner:
$ nano my_julia.jl
and add the text:
println("Hello and welcome to LinuxShellTips tutorial on installing Julia on Ubuntu 22.04")
If we run the file, we should be able to see some output:
With Julia installed on your Ubuntu system, you should now be able to explore its full potential under a Linux ecosystem when it comes to data science and application building.