BioJuliaDocs

Installing Development Tools

Julia REPL

A REPL, or read-eval-print loop, represents a language "shell" or program that allows the user to communicate with the programming language interactively with immediate feedback. This allows for exploring the language more deeply than via a script, with rapid prototyping being much quicker and easier to perform.

The Julia REPL is included by default in every Julia installation and boasts a number of features to the point that it alone can almost be considered a proper IDE. It should appear the moment you enter julia into your terminal:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.2 (2023-07-05)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> 

Not every feature that the REPL provides will be shown, however here is a quick list that most Julia users should know to make the most of this shell:

Prompt Key binding
julia> None (default mode)
help?> ? or ?? (extended help)
(@v1.x) pkg> ]
shell> ;
(reverse-i-search): ^R
(forward-i-search): ^S

::: warning Warning

One common gotcha with the Julia REPL is that there are currently certain code changes that cannot be performed without restarting your session, such as redefining structs (see the example below). You can mitigate this by adding the Revise package, although restarting the session is the simplest option.

julia> struct Point
        x::Int 
        y::Int 
       end

julia> struct Point
        x::Int
        z::Int
       end
ERROR: invalid redefinition of constant Point
Stacktrace:
[1] top-level scope
@ REPL[2]:1

:::

To learn more, see the The Julia REPL section in the Julia manual.

Visual Studio Code extension

The Julia organization officially supports the julia-vscode extension which, together with VSCode, provides a complete solution for developing in Julia similar to a fully integrated development environment (IDE). This boasts a number of advantages compared to a pure REPL-driven solution:

To install vscode, follow the instructions on how to install the official binary for your development machine from the official website. Next, click on the Extension icon in the side Activity Bar and search for "Julia". The official Julia extension should be the first extension available. You can also install Julia within the Quick Open input panel by pressing Ctrl + P and entering ext install julialang.language-julia.

Install the extension and restart vscode. We also recommend installing some additional extensions that will further improve the development experience:

You can experiment with Julia extension features in the Quick Open panel by writing Julia and consulting the available options. To learn more, visit the Julia in Visual Studio Code page or the Julia extension's official website.

Alternative Editor/IDE extensions {#Alternative-Editor/IDE-extensions}

Although julia-vscode is the only officially supported extension, community extensions are available for a range of code editors/IDEs:

Certain editors/IDEs, such as GodBolt and Replit, already support Julia without extensions. Finally, many editors, like micro, natively include support for basic features such as code highlighting or simple autocomplete.

Notebooks

A reactive notebook is an interactive environment that combines elements of a code editor and a REPL into one solution. One writes code in executable blocks of "cells" that can be mixed with text and other assets to create a reproducible document that is shareable and easily manipulable. Notebooks are especially useful for scientific exploration since code can be rapidly prototyped in an isolated environment that can be both visualized and documented in the same file.

There are two standard methods for working with Julia in notebooks:

IJulia (Julia kernel for Jupyter)

The Julia organization officially supports the IJulia kernel, or backend, for Jupyter notebooks, which is the most popular web-based notebook solution.

To install IJulia/Jupyter and run the notebook server:

::: tip Note

Instead of loading Pkg, one can simply activate pkg mode with the ] key and enter (@v1.9) pkg> add <package name here>

:::

  1. Install Julia via any method mentioned in the Installing Julia section

  2. Open the Julia REPL by entering julia into your terminal

  3. Add the IJulia package via the built-in package manager: julia> using Pkg;Pkg.add("IJulia")

  4. Load IJulia and launch the notebook server: julia> using IJulia; notebook() (run notebook(detached=true) if you wish that the notebook, and notebook(dir="/some/path") if you wish to open a notebook in a ) server sruns in the background even if the Julia session is closed)

  5. Enter y to install Jupyter via Conda if you have not done so already on your machine

The notebook dashboard should open within your web browser. If you already have jupyter installed (Installing Jupyter), you can enter n when prompted by the Julia REPL and instead run jupyter notebook from the terminal. Visit the Running IJulia section in the official IJulia docs for more information.

Pluto notebooks

Pluto.jl is an alternative notebook solution built with Julia in mind. It integrates well with the language and boasts a number of features that are not available or are difficult to achieve with the Jupyter solution:

To install and run the Pluto server:

  1. Install Julia via any method mentioned in the Installing Julia section

  2. Open the Julia REPL by entering julia into your terminal

  3. Add the Pluto package via the built-in package manager: julia> using Pkg;Pkg.add("Pluto")

  4. Load Pluto and launch the notebook server: julia> using Pluto; Pluto.run()

  5. Copy/paste the given URL (http://localhost:…) into your web browser

A number of featured notebooks are available online that include basic tutorials and powerful demonstrations achieved with Pluto.