In this guide we’ll explore installation of Julia Programming Language on CentOS 8 | CentOS 7 Linux systems. Julia is dynamically typed, general-purpose programming language with a clean syntax created for numerical analysis, computational science, and even use in general scripting and web development.

Julia has a powerful set of features, very friendly syntax, and programs written in Julia executes very fast. This programming language integrates well with open-source libraries for analysis, data wrangling, and visualization. The community around it is growing drastically.

Recommended books: Best books to Learn Julia Programming

Install Julia Programming Language on CentOS 8 | CentOS 7

The easiest and recommended method of installing Julia Programming Language on CentOS 8 | CentOS 7 is from publicly provided Julia Linux Binaries.

You’ll need wget tool to download file to your machine.

sudo yum install wget -y

You can then pull the latest Julia Programming language binary archive from the releases download page.

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

Wait for the download to finish then extract the file.

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

Move the folder created from extraction of the archive to the /opt directory.

sudo mv julia-1.5.3 /opt/julia

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

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

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

Source the bashrc file to update the settings.

$ source ~/.bashrc

If you’re on  the Zsh shell update the ~/.zshrc file.

$ source ~/.zshrc

Check current PATH settings.

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/julia/bin

If julia was installed correctly you should be able to check software version:

$ julia --version
julia version 1.5.3

To start Julia shell run the following command in your terminal:

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

Test our installation by printing “hello world” message.

julia> println("hello world")
hello world

All Julia programs have an extension .jl. I’ll create a new function file called myfuctions.jl.

$ vim myfuctions.jl

With 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
end

# 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
end

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

This is how we will execute a Julia program.

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

The Julia samples page contains more informative examples that can help you get started in your Julia programming journey.

Also check:

Best books to Learn Julia Programming

Best Books To Learn Kotlin Programming

Install PyCharm IDE on Ubuntu | Debian

Top 10 Android Applications For Engineering Students

LEAVE A REPLY

Please enter your comment!
Please enter your name here