Road to Julia 1: Hello World!

Introduction

Initially released in 2012, the Julia programming language (hereafter referred to as either JuliaLang or simply Julia) is an open-source (MIT licensed) programming language developed for scientific and technical coding. As of writing this post, the most recent stable release of Julia is v1.1.0, for which the official documentation can be found here.

At A Glance

Julia has a simple high-level syntax which caters to programmers of all levels, however it provides the capacity — but not the necessity — to employ lower-level techniques such as type declaration with the intent of allowing performance improvements, giving rise to the unofficial tagline walk like python; run like C. In short, the Julia’s documentation states that

Julia aims to create an unprecedented combination of ease-of-use, power, and efficiency in a single language.

Julia Documentation

Basic Technical Details

Julia files have the file extension .jl, however Julia also supports interactive sessions — known as read-eval-print loops (REPLs) — which are useful for simple programs and are launched with the command julia. Thousands of unicode characters — including emojis — are supported within codes, e.g. ⛲ = 1, which is aided by it also possessing tab-completion. Julia implements a just-in-time (JIT) compiler, which compiles the source code at runtime rather than prior to execution; typically JIT compilers continuously analyse the code being executed in order to identify possible areas wherein recompilation could result in speedup greater than the overheads of the compilation itself.

Setting Up

As with other software, setting up Julia is simple but larger system-dependent. Downloads are available for Windows, macOS, generic Linux binaries, and generic BSD binaries. Alternatively, Julia is available through most Unix package managers, e.g.

macOS

brew cask install julia

Debian/Ubuntu + derivatives

sudo add-apt-repository ppa:staticfloat/juliareleases sudo add-apt-repository ppa:staticfloat/julia-deps
sudo apt-get update sudo apt-get install julia

Arch

$ sudo pacman -S julia

More information on installation can be found here.

Hello World!

With the basics outlined, we can move onto using Julia. There are two standard functions for outputting — println() and print() — the former of which appends the argument with a newline character whereas the latter outputs the argument with no additional formatting. If no output stream is specified for either function, they both default to the standard output (stdout) — typically an on-screen terminal emulator. The first program anyone should write in Julia is hence:

julia> println("Hello world!")
Hello world!

Leave a Reply

Your email address will not be published.