Getting Started

Estimated time: 1-1.5 hours on your own machine, most of it spent downloading packages and waiting for Julia’s first-run compilation. Doing it in advance is worth it, and the taught slot is 45 minutes.

Introduction

This course uses Julia for all code examples and exercises. This page helps you set up your computing environment before the course begins.

ImportantJulia compiles code on first use

Unlike R or Python, Julia compiles functions the first time you call them. This means:

  • First-time install triggers precompilation — Pkg.add (or any dependency change) precompiles the whole dependency tree, which can take several minutes for large packages like Turing
  • After that, using a package is faster — precompilation results are cached on disk and persist across sessions, though large packages still take a few seconds to load
  • First call to a function can be slow — Julia needs to compile for the specific argument types you pass
  • Subsequent calls are fast — compiled code is cached for the rest of the session

This “time to first plot” or “TTFX” latency is much improved in recent Julia versions but still noticeable with large packages. The payoff is that your code runs much faster once compiled. During the course:

  • Expect the first MCMC sample to take longer than subsequent ones
  • If something seems stuck, wait a minute before assuming it’s broken

Three ways to engage with the course:

  1. Web only: Read the materials online without running code. Fine for an overview, but you’ll learn more by doing.
  2. Local installation: Install Julia and run everything on your own machine. Recommended for the full experience.
  3. Cloud option: Open the course in GitHub Codespaces, which gives you a browser-based VS Code with Julia and the course packages already installed. Nothing to download onto your own machine, and it is there if a local installation will not cooperate. You need a GitHub account, and the codespace runs on your own free GitHub allowance, which is many times what this course uses. The packages are prebuilt, so it opens in about a minute with everything installed. Skip the rest of this page and go to Running code.
TipIf the local installation will not work

You do not have to fix it, and you do not have to fall back all the way to reading the website. In order of preference:

  • Julia will not install, or the packages will not build. Open a codespace and connect to it from the VS Code already on your machine: the ☰ menu in the browser, then Open in VS Code Desktop. Julia runs in the cloud and your editor is the one you are used to, with the keyboard shortcuts you expect.

  • You do not have VS Code either, or would rather not install it. Use the same codespace in the browser and nothing else is needed. Run code by clicking the Run Cell link above each block; see the warning under Running code about why the keyboard shortcuts may not respond there.

Either way you are working with the real course materials and can edit and re-run them.

Two things to know about a codespace. Closing the browser tab does not stop it: it keeps running, and keeps using your allowance, until it times out after thirty minutes idle. Stop it yourself from github.com/codespaces using the menu next to it, which is also where you go to reopen it later. Your files survive stopping and restarting, including anything you have edited, but a codespace is deleted after thirty days unused, so push or copy out anything you want to keep.

Local installation

Step 1: Install Julia

Install Julia using juliaup, the official version manager. Open a terminal (on Windows: search for “PowerShell”; on macOS: open Terminal from Applications/Utilities) and run:

  • Windows: winget install --name Julia --id 9NJNWW8PVKMN -e -s msstore
  • macOS/Linux: curl -fsSL https://install.julialang.org | sh

juliaup handles downloading the right version and makes future upgrades easy (juliaup update).

After installation, open a terminal and verify Julia is working:

julia --version

You should see julia version 1.12.x. The course requires 1.12, and the packages will not install on 1.11.

Step 3: Get the course materials

Unpack the ZIP wherever you keep your work. It creates a folder called mfiidd-main, and that folder is what the rest of this page calls the course folder.

If you already use git you can clone the repository instead, which makes it easier to pick up corrections while the course runs:

git clone https://github.com/mfiidd/mfiidd.git
cd mfiidd

That gives a folder called mfiidd. Neither Windows nor macOS comes with git, and on macOS typing git prompts you to install Apple’s command line tools, which is a large download in itself, so take the download above unless you have git already.

Then open the course folder in VS Code: run File → Open Folder and navigate to it, or run code followed by the folder name from the terminal.

Step 4: Install Julia packages

With the course folder open in VS Code, start the Julia REPL from the menu: View → Command Palette, then type “Julia: Start REPL” and press Enter. The keyboard shortcut for the palette is Ctrl+Shift+P, or Cmd+Shift+P on macOS, but some systems claim that combination for themselves, so the menu is the route that always works. The REPL should open in the bottom panel showing a julia> prompt.

Now activate the project environment and install packages:

using Pkg
Pkg.activate(".")
Pkg.instantiate()

Pkg.activate(".") tells Julia to use the course’s own set of packages rather than your global installation — think of it as a self-contained library that ensures everyone has the same package versions. Pkg.instantiate() then reads Project.toml and Manifest.toml to download and install those exact versions.

WarningExpect a long wait on first run

Package installation typically takes 15-30 minutes depending on your internet connection and computer speed. The process downloads ~1GB of packages and then precompiles them. This is a good time to get a coffee or read ahead in the course materials. If installation takes more than 45 minutes, check your internet connection or see the Troubleshooting section below.

What to expect in the console:

  Downloading artifact: LLVM...
  Downloading artifact: GR...
    Updating registry at `~/.julia/registries/General.toml`
   Resolving package versions...
  Downloaded Turing ─ v0.35.0
  Downloaded DifferentialEquations ─ v7.15.0
  ...many more packages...
Precompiling project...
  ✓ Distributions
  ✓ OrdinaryDiffEq
  ...many more...
  72 dependencies successfully precompiled in 342 seconds

Warnings about “precompilation may be incomplete” are usually harmless. The process is complete when you see the julia> prompt again.

Step 5: Verify the installation

ImportantRun this before the course starts

Don’t skip this step. Package installation can succeed while something is still broken. Run the verification code below to confirm everything works. If you hit errors, you’ll have time to troubleshoot before the course begins.

Test that core packages load correctly by copying the code below into your Julia REPL (the julia> prompt from step 4). You can paste the whole block at once — Julia will run each line in order:

using Turing
using DifferentialEquations
using Plots

# Quick test: sample from a simple model
@model function coin_flip(n)
    p ~ Beta(1, 1)
    k ~ Binomial(n, p)
end

chain = sample(coin_flip(10) | (; k = 7), NUTS(), 100)
println("Installation successful!")

The first time you run this, expect it to take a minute or two as Julia compiles the packages (see the note about compilation above). If it completes without errors and prints “Installation successful!”, you’re ready for the course. If you see errors, check the Troubleshooting section below.

Troubleshooting

“Package X not found”

Make sure you’ve activated the project environment:

using Pkg
Pkg.activate(".")  # Note the dot - this activates the current directory
Pkg.status()       # Should show course packages, not your global environment

Slow package loading

Julia compiles code on first use. The first using Turing in a session takes longer than subsequent calls. This is normal. For faster startup during development, consider PackageCompiler.jl or Revise.jl.

Windows-specific issues

  • Long path errors: Enable long paths in Windows settings or use a shorter installation path
  • Firewall prompts: Allow Julia through your firewall for package downloads

macOS Apple Silicon

Julia runs natively on Apple Silicon, and juliaup installs the right build for your machine, so there is nothing to choose. If you installed Julia some time ago by downloading it by hand, you may be running an Intel build under Rosetta, which is noticeably slower. Check with Sys.ARCH at the Julia prompt: it should print aarch64, and if it prints x86_64 then reinstalling through juliaup will fix it.

Keeping up to date

If you installed everything days or weeks ago, refresh it before you start. First update the materials, from the folder you cloned or unpacked:

git pull

If you downloaded the ZIP rather than cloning, download it again and replace the folder.

Then match the package versions the course was tested with:

using Pkg
Pkg.activate(".")
Pkg.instantiate()
Pkg.precompile()

Pkg.instantiate() installs exactly the versions recorded in Manifest.toml, which is what you want. Pkg.update() would resolve fresh versions instead and can pull in a release the course has not been run against, so reach for it only if something is broken.

During the course

We fix things as we find them, so the materials may change under you while the course runs. To pick up a change, download the materials again and replace your folder, or run git pull if you cloned, then restart the Julia REPL.

If Project.toml or Manifest.toml changed, run Pkg.instantiate() again as well. Nothing else needs reinstalling, and Julia will not need to precompile from scratch a second time.

Working with the materials

Quarto documents (.qmd)

Course sessions are Quarto documents (.qmd) combining text and executable Julia code. If you’ve used RMarkdown before, Quarto is its successor — same idea, but language-agnostic. To render a session:

quarto preview sessions/introduction.qmd

Or render the entire site:

quarto preview

Running code

Open a session, for example sessions/introduction.qmd, and look just above any block that starts ```{julia}. There is a small Run Cell link there. Click it, and the block runs in the Julia REPL, which starts by itself the first time. Work down the session that way, reading the prose between the blocks.

Clicking is the route that always works, so it is the one to learn first.

WarningKeyboard shortcuts are not reliable everywhere

In desktop VS Code you can press Shift+Enter to run a block and move to the next one, which is quicker once you are going. In a browser, which is what a codespace gives you, the browser and the operating system take some key combinations before VS Code sees them, and Shift+Enter may do nothing at all. Nothing is broken when that happens. Use the Run Cell link instead, or open the codespace in desktop VS Code through the ☰ menu.

You can also copy code into the Julia REPL, which is what to do if you are reading the sessions on the website rather than running them from a local copy.

The Julia extension for VS Code activates the course’s project environment automatically when you start a REPL from the workspace, which .vscode/settings.json in the repository pins for you. If you ever see ERROR: ArgumentError: Package X not found in current path, the REPL is in Julia’s default environment instead: run using Pkg; Pkg.activate(".") and check with Base.active_project(), which should end in mfiidd/Project.toml. If you use another editor, start Julia from the repository root with julia --project=. (or julia --project=@. from any subdirectory) so it picks up the course packages.

Session checklist

Before starting, verify you can:

If all boxes are ticked, you’re ready. Head to the Course Structure for an overview, or jump straight to the Introduction.