# Introduction¶

In this one-day introductory course into Julia, I want to provide a condensed, high-level overview. In my presentation of the material I will focus on discussing key concepts of the language by examples and small exercises (with solutions), which in many cases only scetch the surface. Still, these should provide you with first insight how Julia works, show you what is similar and what is different to programming languages you might know. I hope after the day you will be a little more curious about Julia and well-equipped with pointers and the necessary background to keep exploring for yourself. For this plenty of great Julia teaching material is already available. You can find it either links directly in these notes or on the course website.

For my examples I will mostly draw from my own background in computational chemistry and physics. Especially in these fields one of the challenges is to combine researchers from different backgrounds, an aspect for which Julia is excellently suited in my opinion. But of course that's not the only domain in which Julia is used. Others include data science or mathematical optimisation.

For the course familiarity with key programming concepts such as braching, loops, classes, ... as well as some familiarity with a wide-spread languages such as C++, python, FORTRAN or similar is assumed throughout the course.

## Installing Julia¶

For following the course you will need at least Julia 1.0, but for full compatibility Julia 1.2 or Julia 1.3 is recommended. Julia can be easily obtained in binary form from Julia downloads. Installation instructions specific to your operating systems are available. In general it really just boils down to downloading a tarball and unpacking it.

If you want, compiling Julia from source is possible as well.

## Installing Jupyter and IJulia¶

For the course we will be working with Jupyter notebooks (like the one you are currently reading). For obtaining Jupyter and integrating it with Julia, follow these instructions (or read the more detailed version):

1. Install Jupyter notebook. For Linux choose your favourite package manager, like

apt install jupyter jupyter-notebook


for debian or

pip install jupyter


if you prefer PyPi packages. For Mac use brew install jupyterlab.

2. Install IJulia inside Julia. For this run

/path/to/juliafolder/bin/julia -e 'import Pkg; Pkg.add("IJulia")'


in your terminal, where /path/to/juliafolder is the path into which you unpacked the julia tarball, which you have obtained in the previous step.

## Obtaining the course files¶

The last thing you need for the course are the notebook files themselves. These are available on github and you can easily clone them with git:

git clone https://github.com/mfherbst/course_julia_day


Once this command is finished, you'll have a folder course_julia_day. Just cd into it and start the jupyter notebook:

cd course_julia_day
jupyter notebook .


to fire up a browser ready to work on the course material.

Before we start digging in the lovely world of Julia, let me loose a few words about the language itself.

The idea of Julia is about 10 years old and the project was started by Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman with the desire to create a language, which is both fast and high-level. In this spirit Julia thrives on the idea to end the traditional trade-off between performance and convenience in programming. For this Julia takes ideas from high-level languages like python, MATLAB or Perl, but also from functional languages like Lisp. This year the makers of Julia have been awarded with the James H. Wilkinson Prize for numerical software.

The fundamental difference to many languages including C++ and Python is, that Julia is both high-level and compiled: In Julia types are dynamically inferred at runtime like in scripting languages, but still the first call to a function triggers a compilation of the respective code segment to machine code, running natively on the CPU / GPU. This is called just-in-time compilation (JIT) and is hardly a new concept. Interesting in Julia is, however, the combination with Julia's strong type system and a concept called multiple dispatch with the compilation process. In the latter the idea is to determine the precise functionality of a statement is doing by looking at the types of all the arguments. As we will see in examples later this

• increases code reuse
• allows for strong decoupling of libraries and code segments
• allows the Julia compiler be very clever: Special cases or hardware details can be exploited during compilation.

The latter aspect makes Julia programs behave unusual from time to time in the sense that a code which is for example very fast in Python can be slow in Julia, if written in the same way. So as always: There is no free lunch. Still, from my experience the ratio between coding time versus obtained performance is extremly good in Julia. With respect to performance it sohuld be noted, that Julia is one of the three programming languages which have been scaled to complete supercomputer (the others are C++ and FORTRAN). For details see the blog articles and the website on the celeste project.

A few more key characteristics of Julia in keywords:

• Dynamic-typed language with automatic type-inference
• Stable: Julia 1.0.0 is a long-term support release (until the next dedicated LTS is released)
• Cross-language support: Easily use C++, FORTRAN, python, R, Java ... from Julia (and in some cases the other way round, too)
• Builtin package manager
• Unicode support inside the core language
• Green threading and distributed computing
• Macros are part of the language
• Rich set of packages: GPU, Threading, Distributed computing, Plotting, Visualisation, Optimisation, Automatic differentiation, Machine Learning, PDEs ...