Skip to content

Installing Julia

I recommend running Julia from a terminal window with Visual Studio Code as editor.

You may have another favorite text editor, but you will lose integration with the Julia language.

Useful guides to getting started:

  • QuantEcon
  • The Julia documentation is really very good. It should be your go-to place for getting started.
  • I find it useful to install a documentation browser (on MacOS that would be Dash). It is faster to interact with the docs this way.

Installation details

  1. Download the binary for your platform.
  2. Follow the instructions in the "help" link for your platform. You should add a path to the Julia binary in the terminal.
  3. Try that you can start Julia by typing julia from a terminal window. You should see the REPL.
  4. If this fails, create a symlink (linux or macos) to the julia binary. The installation instructions describe how to do this, depending on the OS.

Interacting with Julia

At the terminal, type julia to start a Julia session. You will see the REPL, which is similar to Matlab's command line.

At the REPL, you can type any Julia command and see the results displayed. Note the REPL inputs (and all Julia commands) are case sensitive.

? switches to REPL help mode. For example, ?abs will give help on the abs function:

?abs

abs(x)

The absolute value of `x`.

When `abs` is applied to signed integers, overflow may occur, resulting in the return of a negative value. This overflow occurs only when `abs` is applied to the minimum representable value of a signed integer. That is, when `x == typemin(typeof(x))`, `abs(x) == x < 0`, not `-x` as might be expected.

# Examples
[...]

Hint: A documentation browser, such as Dash makes life a lot easier.

After Installation

Once Julia is installed and running, it is useful to install a few helper packages. In the REPL, type

using Pkg;
Pkg.add("OhMyREPL");
Pkg.add("Revise");

This will take some time to execute.

OhMyREPL formats REPL output.

Revise.jl is practically a required package. It massively improves the Julia workflow.

After making changes to installed packages, you should always restart the REPL. Ctrl-D quits the REPL.

Edit "~/.julia/config/startup.jl" and add the line using OhMyREPL, Revise. This ensures that those packages are used every time you start Julia.

Hint: Set the JULIA_EDITOR environment variable to point to your editor. For VSCode:

julia> ENV["JULIA_EDITOR"]
"/usr/local/bin/code"

This allows you to open files by either clicking on file paths in the REPL (if your terminal supports this) or by typing edit(path/to/file.jl).

To check that everything worked correctly, start Julia and type Revise at the REPL prompt. Make sure this does not give an error message.

Configure VSCode

Install the Julia VS Code extension.

Set the julia.executablePath to point to the Julia binary. If you created a symlink as recommended above, that would be /usr/local/bin/julia (on MacOS / Linux).

See also VSCode: the future for Julia development - TechyTok

Check point: Everybody should have

  • Julia 1.6 installed and running.
  • a good text editor with the Julia extension running.