Setup & the REPL
Everything here is one-time work. Once it is done, every later lesson is just code typed into a session. Work through the sections in order: a correct install makes the REPL lessons trivial, and a sloppy install is the source of most "Julia is broken" reports.
Installing Julia
There are two ways people install Julia: downloading a version-specific archive by hand, or using the juliaup version manager. Use the version manager. It installs Julia, keeps it updated, and lets you switch versions per project with one command — the same convenience rustup gives Rust and nvm gives Node.
Juliaup & the Recommended Installer
The juliaup tool is itself installed by a small platform installer. On Linux and macOS it is a shell script; on Windows it is a Microsoft Store application or a PowerShell one-liner. The official site publishes one command per platform — use the one for your system:
# macOS / Linux — official installer script
curl -fsSL https://install.julialang.org | sh
# Windows (PowerShell) — installs Juliaup from the Microsoft Store
winget install --name Julia --source winget
After the installer finishes, Julia is on your PATH under the command name julia. The version manager is juliaup and it manages channels: release (latest stable), lts (long-term support), beta, and numbered versions.
juliaup add lts # download the LTS line alongside the current release
juliaup default release # make the latest stable the default `julia`
juliaup status # list installed channels and which is default
juliaup update # update every installed channel in place
Verify the Installation
Never start a tutorial on an unverified install. Run the version, the word size, and one arithmetic expression. If all three respond, the compiler is working — arithmetic in Julia is compiled, so a correct 1 + 1 proves more than it looks.
julia --version # prints e.g. julia version 1.11.4
julia -e 'println(Sys.WORD_SIZE)' # 64 on every modern platform
julia -e 'println(sum(1:100))' # 5050 — compiled and executed
The -e flag evaluates an expression and exits; it is the fastest way to smoke-test an install or to use Julia as a one-line calculator from a shell script. If a command is not found, reopen your terminal so the updated PATH is picked up before assuming the install failed.
The Julia REPL
Running julia with no arguments starts the REPL: read, evaluate, print, loop. It is not a toy. The REPL is the primary interface for exploratory work because it keeps every definition you type alive in the same session, so you can develop a function line by line instead of restarting a program.
julia> a = 12
12
julia> b = 5
5
julia> a / b
2.4
julia> ans + 1 # `ans` holds the last result
3.4
Results print automatically; you do not call print to see a value. The variable ans always refers to the previous result, which makes chained calculations painless.
REPL Modes
The prompt is context-sensitive. Typing a special character at the start of a line switches mode; pressing backspace at an empty prompt returns you to the normal Julian mode.
| Prompt | Trigger | Purpose |
|---|---|---|
julia> | default | Evaluate Julia expressions |
help> | ? | Documentation for any function or type |
shell> | ; | Run operating-system commands |
pkg> | ] | Add, remove and inspect packages |
help> sqrt
sqrt(x)
Return the square root of x. Throws DomainError for negative Real.
shell> ls
Project.toml Manifest.toml src
pkg> status
Status `~/.julia/environments/v1.11/Project.toml`
[a93c6f00] DataFrames v1.6.1
Essential REPL Workflow
Three habits separate productive Julia sessions from frustrating ones. First, type the first letters of a name and press Tab: the REPL completes identifiers, and completing a function shows its methods. Second, press ? before a name to read its documentation without leaving the session. Third, know these three keyboard shortcuts, because they replace the "start over" instinct:
- Ctrl+C — interrupt the running computation and return to the prompt.
- Ctrl+L — clear the screen without losing your definitions.
- Ctrl+D — exit Julia cleanly (same as
exit()).
Editor & Tooling
The REPL is where you experiment; an editor is where you keep code. Julia has first-class support in two places: VS Code and notebook environments. Pick one to start — installing both on day one only delays writing code.
VS Code & the Julia Extension
The official Julia extension gives VS Code an integrated REPL, a debugger, a profiler, a plot pane, and full language intelligence. Start the editor from a terminal with code . inside your project so the extension inherits the right environment.
The workflow the extension is built around is send code to the REPL. You write a .jl file, then execute the current line, the current selection, or the whole file without leaving the editor:
# Inside VS Code with the Julia extension installed
# Shift+Enter run the current line / selection in the REPL
# Ctrl+Shift+P > Julia: Start REPL
# Ctrl+Shift+P > Julia: Execute active file in REPL
This combination — a persistent session plus editor-side execution — is the fastest way to develop anything larger than a few lines, because your definitions and your data stay in memory while you edit.
Jupyter & Pluto Notebooks
Notebooks interleave code, output, and prose in one document. Julia supports two mature formats. Jupyter uses the same kernel protocol as Python notebooks and is the familiar choice for reports and teaching. Pluto is Julia-native and reactive: it tracks dependencies between cells, so changing one cell automatically re-evaluates everything that depends on it — which rules out the stale-state bug that plagues long Jupyter sessions.
# Add a Jupyter kernel for Julia (once per Julia version)
using Pkg
Pkg.add("IJulia")
# Pluto runs as a normal Julia package
Pkg.add("Pluto")
using Pluto
Pluto.run() # opens a notebook in your browser
Running Scripts
A script is a plain text file with a .jl extension. Running it is exactly the same act as typing its contents into the REPL, except that the process starts fresh, executes top to bottom, and exits. Nothing survives between runs — which is what you want for anything reproducible.
Script Files
Put the code below in a file named hello.jl and run it with the interpreter. Pass arguments after the filename to reach them through the global ARGS array.
# hello.jl — run with: julia hello.jl
println("Hello, Julia")
if !isempty(ARGS)
println("You passed ", length(ARGS), " argument(s): ", join(ARGS, ", "))
end
julia hello.jl # Hello, Julia
julia hello.jl alpha beta # also prints the two arguments
julia -i hello.jl # run it, then keep the session open
Two flags matter at this stage. -i runs the file and then drops you into the REPL with everything the file defined still in scope — ideal for poking at results. --project activates a project environment before the script runs, which is the subject of the next section.
Dispatching on abspath(PROGRAM_FILE) == @__FILE__ lets the same file act both as a script and as an importable module, a pattern worth copying once you write reusable code:
function main()
println("running as the main program")
end
# Only execute main() when this file is the program, not when it is imported.
if abspath(PROGRAM_FILE) == @__FILE__
main()
end
Project Environments
Julia packages install into environments, each described by a Project.toml file listing the packages you asked for and a Manifest.toml recording the exact resolved versions. Isolating each project in its own environment is what makes a Julia analysis reproducible a year later.
# From the REPL, `]` enters Pkg mode — the same commands also work as functions:
julia> using Pkg
julia> Pkg.activate("myproject") # create/select ./myproject/Project.toml
julia> Pkg.add("DataFrames") # record it as a dependency
julia> Pkg.status() # show what this environment contains
# Or activate an environment for a single command, without changing the session
julia --project=. myscript.jl
Your First Program
Hello, World
Every language teaches something in its first line. In Julia, println is an ordinary generic function like any other — there is no special I/O syntax, no class to instantiate, no import needed. That uniformity is the language's whole personality in miniature.
# First program — type this directly into the REPL
println("Hello, World!")
# Julia is a calculator first: no declarations, no wrapping class.
radius = 2.5
area = pi * radius^2
println("area = ", round(area; digits = 3)) # area = 19.635
Note what did not happen: no var, no type, no semicolon, no import. The value 2.5 is a Float64, pi is a built-in constant, and ^ is the power operator. From here, the natural next experiment is to wrap the calculation in a function and watch it get faster on the second call — the subject of Functions.
Common Setup Pitfalls
Nearly every first-session problem falls into one of four categories. Check these before concluding that Julia itself is broken:
julia: command not foundright after installing. ThePATHchange only applies to new shells. Close the terminal — or the whole editor — and open it again.- Package installs fail behind a firewall. Julia fetches from a git registry. Set your proxy in the environment (
JULIA_PKG_SERVER,HTTPS_PROXY) or install from an offline depot. - Long first-run pauses. The first call to a function, and the first
usingof a large package, compile code. A ten-second pause is compilation, not a hang. - Mixing versions. If
julia --versiondisagrees with what the editor reports, you have two installs on thePATH. Remove the manual one and keepjuliaup.
One more habit pays off later: keep your Julia version pinned in each project. A Manifest.toml plus a recorded Julia version turns "it works on my machine" into "it works everywhere".
You now have a verified install, a working REPL, an editor wired to a live session, and somewhere to put scripts. Next: Julia Syntax covers the grammar those scripts are written in.