Introduction to Julia

By Guillaume Dalle

This website contains a series of notebooks illustrating the use of the Julia programming language. It was originally designed as teaching material for students of École des Ponts ParisTech, but it is accessible to a much wider audience.

All of the links in the menu point to notebooks that can be visualized in your browser without any prerequisites. To edit or run a notebook, click on Edit or run this notebook and follow the instructions given there. You will need to install Julia and the Pluto package. I sometimes had issues with Pluto in Firefox, so you may want to try Google Chrome / Chromium instead.

While these notebooks are great for interactive exploration of short code snippets, they have serious downsides when it comes to larger tasks. We strongly advise you to choose another tool for more ambitious projects, ideally an IDE such as VSCode (more on this below).

The basics

What is Julia?

Maybe the solution to the two-language problem (see this Nature article):

  • User-friendly syntax for high-level programming
  • C-level speed (when done right) for high-performance computing

Learning Julia

The Julia website has a great list of resources for beginners, as well as many free tutorials contributed by the community. The MIT course Introduction to Computational Thinking is also very beginner-friendly.

If you just need a quick refresher about syntax, this cheat sheet is the place to go. For more involved questions, the primary source of knowledge is the Julia manual.

If you want to go further, here is a list of quality books and tutorials:

And for the ultimate list of Julia resources, go to Julia.jl.

Coding environment

When developing in Julia, you want to select a comfortable IDE. Here are a few good choices:

If you want something a bit lighter, here are two browser-based options:

  • Jupyter Lab is a browser-based IDE and notebook for Julia, Python and R
  • Pluto is a Julia-based reactive notebook server

Getting help

The Julia community is very active and welcoming, so don’t hesitate to ask for help in the following venues:

Creating a package

Discovering packages

Before coding something, you want to make sure that someone else hasn’t already coded it better and faster than you. For that, you may need to search for packages on a dedicated database: that’s what JuliaObserver and JuliaHub are here for.

In addition, Julia packages are often gathered into GitHub “groups” or organizations, which are listed here.

If a Julia package doesn’t exist:

…or code / wrap it yourself in Julia and contribute to the community!

Package manager

One of the main assets of Julia is a built-in package manager called Pkg, which handles installation and updates of every library you may need. Pkg also makes it possible to create separate environments for each one of your projects. The full documentation of this utility is a must-read.

Getting started

The PkgTemplates.jl package enables you to create packages in a standardized way. It takes care of the file structure for you, and even integerates with GitHub Actions or Travis CI to set up a continuous integration workflow.

Workflow

Some workflow tips can be found in the manual. In particular, you should check out the following packages:

Style

Julia has no universally agreed-upon style guide like Python. The main official guidelines can be found here.

For an exhaustive style reference, have a look at the unofficial (but widely used) BlueStyle by Invenia.

Unit testing

Julia has built-in support for unit testing. This allows you to check that recent modifications did not modify the expected behavior of your code.

Documentation

Non-documented code is useless code. You should write documentation as you code (not after), and the best place to put it is in your .jl files using docstrings. Julia docstrings are written in Markdown, see this reference for general guidelines.

If you want to automatically generate a nice HTML documentation website, harnessing the power of Documenter.jl is the way to go. This pakcage also enables testing from within the documentation itself. Inside a docstring, you can put examples of REPL input and expected output, which will be run again and checked for correctness every time the documentation is updated. These code examples are called doctests.