2  Installation and Getting Started with Julia

2.1 Installation

Julia can be installed from its website. The installation process is straightforward and the website provides detailed instructions for all operating systems. Here we provide a brief overview of the installation process as of September 2024 that relies on the Julia version manager Juliaup.

2.1.1 Windows

Install the latest Julia version from the Microsoft Store by running this in the command prompt:

> winget install julia -s msstore

2.1.2 MacOS and Linux

Install the latest Julia version by running this in your terminal:

$ curl -fsSL https://install.julialang.org | sh

2.1.3 Juliaup

Once installed julia will be available via the command line interface.

The command juliaup is also installed, which will automatically install Julia and help keep it up to date. To install different Julia versions see juliaup --help.

2.2 Getting Started

To start Julia, simply type julia in the command line. This will open the Julia REPL (Read-Eval-Print Loop), which is a command line interface for Julia. Here you can type Julia code and see the results immediately.

julia> 1 + 1
2

To exit the REPL, type exit().

2.3 Julia Packages

2.3.1 Package Manager

Julia has a ever expanding ecosystem of packages that can be installed using the built-in package manager. To install a package, type ] in the Julia REPL to enter the package manager mode, and then type add followed by the package name.

pkg> add Plots

Alternatively, you can install a package using the Pkg module.

julia> using Pkg
julia> Pkg.add("Plots")

2.3.2 Using Packages

To use the package, type using followed by the package name.

julia> using Plots

This will load the package and make its functions available in the current session.

2.4 Project Environment

2.4.1 Creating a Project

Julia has a built-in project environment that allows you to manage the dependencies of your project. To create a new project, type ] in the Julia REPL to enter the package manager mode, and then type generate followed by the project name.

pkg> generate MyProject

This will create a new project folder with a Project.toml file that lists the dependencies of the project.

2.4.2 Activating a Project

To activate the project, type activate followed by the project name.

pkg> activate MyProject

This will activate the project environment, and any packages installed will be installed in the project environment.

2.4.3 Reproducing the Project Environment

To reproduce the project environment, you can use the instantiate command.

pkg> Pkg.instantiate()

This will install the packages listed in the Project.toml file in the project environment. This is useful for reproducibility, as it allows you to install the exact versions of the packages used in the project. Hence, when you share the Project.toml file with others, they can install the exact same versions of the packages used in the project.

We recommend using the Project.toml provided in the book’s repository to create the same project environment as the one used for the code in this book.

2.5 Integrated Development Environment (IDE)

We recommend using VSCode with the Julia extension for development. The Julia extension provides a rich set of features, including syntax highlighting, code completion, and debugging.

2.6 Resources