Julia is an excellent JIT-compiled, dynamically typed language with a clean syntax designed from the ground for high performance. Julia is a general-purpose programming language ideal for computational science, numerical analysis and even use in web development and scripting. We have an article on Best Julia Books to read.

In this article we will be discussing how you can install Julia on Linux Mint Desktop and any Ubuntu system. Linux Mint is a derivative of Ubuntu and the dependencies should be same. Julia is known to work well with powerful open-source libraries for analysis, data wrangling, and visualization.

Because of its friendly syntax, powerful features, and speed Julia has attracted a growing number of adopters from R, Python, R, and Matlab, and it keeps raising the bar for modern scientific and general computing.

Install Julia Programming Language on Linux Mint | Ubuntu

Binary packages of Julia are available for easy installation on any Linux system. I recommend you visit  Julia Linux Binaries page to check the latest release before downloading. Let’s now start to install Julia on Linux Mint | Ubuntu.

If you don’t have wget install it.

sudo apt update
sudo apt install wget -y

With wget installed use it to pull the latest release of Julia binary package.

wget https://julialang-s3.julialang.org/bin/linux/x64/1.5/julia-1.5.3-linux-x86_64.tar.gz

Extract the file downloaded using tar command line tool.

tar xvf julia-1.5.3-linux-x86_64.tar.gz

Move the folder that was created from extractions to the /opt directory.

sudo mv julia-1.5.3 /opt/julia

Add /opt/julia/bin directory to your PATH.

# For Bash
$ vim ~/.bashrc
export PATH=$PATH:/opt/julia/bin

# For Zsh
$ vim ~/.zshrc
export PATH=$PATH:/opt/julia/bin

Source the bashrc file to update the settings. If you’re using zshrc the file to be modified should be ~/.zshrc

$ source ~/.bashrc
# Or for Zsh
$ source ~/.zshrc

Validate your current PATH settings.

$ echo $PATH

Confirm julia binary file is executable from your shell terminal session.

$ julia --version
julia version 1.5.3

Start Julia shell by running the following command:

$ julia
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.3 (2020-11-09)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

Let’s print Hello World message on the terminal.

julia> println("hello world")
hello world

Julia programs should end with extension .jl. I’ll create a new function file called myfuctions.jl.

$ vim myfuctions.jl

The file have below contents.

# [function](https://docs.julialang.org/en/v1/manual/functions/#man-functions-1) to calculate the volume of a sphere
function sphere_vol(r)
    # julia allows [Unicode names](https://docs.julialang.org/en/v1/manual/unicode-input/#Unicode-Input-1) (in UTF-8 encoding)
    # so either "pi" or the symbol π can be used
    return 4/3*pi*r^3

# functions can also be defined more succinctly
quadratic(a, sqr_term, b) = (-b + sqr_term) / 2a

# calculates x for 0 = a*x^2+b*x+c, [arguments types](https://docs.julialang.org/en/v1/manual/functions/#Further-Reading-1) can be defined in function definitions
function quadratic2(a::Float64, b::Float64, c::Float64)
    # unlike other languages 2a is equivalent to 2*a
    # a^2 is used instead of a**2 or pow(a,2)
    sqr_term = sqrt(b^2-4a*c)
    r1 = quadratic(a, sqr_term, b)
    r2 = quadratic(a, -sqr_term, b)
    # multiple values can be returned from a function using tuples
    # if the [return](https://docs.julialang.org/en/v1/manual/functions/#The-return-Keyword-1) keyword is omitted, the last term is returned
    r1, r2

vol = sphere_vol(3)
# @printf allows number formatting but does not automatically append the \n to statements, see below
using Printf
@printf "volume = %0.3f\n" vol 
#> volume = 113.097

quad1, quad2 = quadratic2(2.0, -2.0, -12.0)
println("result 1: ", quad1)
#> result 1: 3.0
println("result 2: ", quad2)
#> result 2: -2.0

Then run the file on command prompt or terminal with the command:

$ julia myfuctions.jl
volume = 113.097
result 1: 3.0
result 2: -2.0

We hope this guide helped you to install Julia on Ubuntu and Linux Mint Desktop machine. For more examples go through the Julia samples page which captures standard concepts to get you started.

More articles:

Best Books To Learn Kotlin Programming

Install PyCharm IDE on Ubuntu | Debian

Top 10 Android Applications For Engineering Students


Please enter your comment!
Please enter your name here