Julia cheat sheet
A scannable Julia reference: 14 short snippets across 7 topics, each linking back to the lesson it came from.
At a glance
| Topic | What it covers | |
|---|---|---|
| Multiple dispatch | Methods are selected on the types of all their arguments, which replaces type tags, if/else chains and class | lesson |
| Packages, environments and performance | Reproducible project environments with Pkg, and the handful of rules that separate fast Julia from slow Julia | lesson |
| Installing Julia and the REPL workflow | A Julia release is usually a minor version rather than a patch: packages frequently require 1.10 or newer, and the | lesson |
| Arrays and broadcasting in depth | Julia stores arrays in column-major order, matching Fortran and BLAS. It matters for cache behaviour: iterating down a | lesson |
| Strings, IO and working with files | Build strings with interpolation or join, never by concatenating in a loop. A String is immutable, so each | lesson |
| Modules and organising a Julia project | To add a method to a function owned by another module you must import it, not using it. That rule prevents a stray | lesson |
| Plotting with Plots.jl and Makie | Layouts accept tuples such as (2, 2) or a custom grid with mixed spans through @layout. Build each subplot as a value | lesson |
Quick snippets
Multiple dispatch
One name, many methods
describe(x::Integer) = "an integer: $x"
describe(x::AbstractFloat) = "a float: $x"
describe(x::AbstractString) = "text of length $(length(x))"
describe(x) = "something else: $(typeof(x))"
describe(3) # "an integer: 3"
describe(3.0) # "a float: 3.0"
describe("abc") # "text of length 3"
describe(:sym) # "something else: Symbol"
methods(describe) # the whole method table, with signaturesFull lesson: Multiple dispatch →
Packages, environments and performance
Project environments
using Pkg
Pkg.activate(".") # use the environment defined by Project.toml
Pkg.add("DataFrames")
Pkg.add(name = "CSV", version = "0.10")
Pkg.status()
Pkg.instantiate() # install exactly the versions in Manifest.toml
Pkg.resolve()
Project environments
Pkg.compat("DataFrames", "1.6")
Pkg.status(; outdated = true)Full lesson: Packages, environments and performance →
Installing Julia and the REPL workflow
Install
# juliaup manages versions and keeps them up to date
# macOS / Linux
curl -fsSL https://install.julialang.org | sh
# Windows (PowerShell)
winget install julia -s msstore
juliaup add 1.10 # install a specific release
juliaup status
julia --version
The REPL modes
# in the REPL, press ] for pkg mode
# (@v1.10) pkg> activate .
# (myproject) pkg> add DataFrames CSV
# then from Julian mode
using DataFrames
?DataFrame # the help prompt, also available as a function
varinfo() # what is currently defined in Main
Scripts, include and environments
julia script.jl # run a file, then exit
julia --project=. script.jl # run with the environment in the current folder
julia -e 'println(1 + 1)' # evaluate one expression
julia --project=. -i script.jl # run, then stay in the REPLFull lesson: Installing Julia and the REPL workflow →
Arrays and broadcasting in depth
Building and inspecting arrays
zeros(3) # Vector{Float64}, length 3
ones(Int, 2, 3) # 2x3 Matrix{Int}
fill(7, 4)
[1, 2, 3] # Vector{Int}
[1 2 3] # 1x3 Matrix{Int}
[1 2; 3 4] # 2x2 Matrix
A = reshape(1:12, 3, 4) # column-major: columns fill first
ndims(A), size(A), length(A)
A[2, 3] # row 2, column 3
A[7] # linear index, column-major order
axes(A) # (Base.OneTo(3), Base.OneTo(4))
Views and copies
A = reshape(1.0:12.0, 3, 4)
col = @view A[:, 2]
col[1] = 99.0
A[1, 2] # 99.0 - the view wrote into the parent
copy(col) # an independent array
B = A' # adjoint, not a transposed copy
size(B), typeof(B)
sum(A; dims = 1) # reduce along dimension 1, keeping the dimension
dropdims(sum(A; dims = 1), dims = 1)Full lesson: Arrays and broadcasting in depth →
Strings, IO and working with files
CSV and downloads
using CSV, DataFrames, Downloads
df = CSV.read("data.csv", DataFrame)
CSV.write("out.csv", df)
# types, missing values and delimiters are explicit
df2 = CSV.read("export.psv", DataFrame;
delim = '|', missingstring = "NA", types = Dict(:amount => Float64))
url = "https://example.com/data.csv"
Downloads.download(url, "download.csv")Full lesson: Strings, IO and working with files →
Modules and organising a Julia project
Projects and environments
mkdir MyPkg && cd MyPkg
julia --project=. -e 'using Pkg; Pkg.generate("MyPkg")'
# resulting layout
# MyPkg/
# Project.toml name, uuid, version, [deps], [compat]
# Manifest.toml exact resolved versions and hashes
# src/MyPkg.jl module MyPkg ... end
# test/runtests.jl @testset for the package
Projects and environments
using Pkg
Pkg.activate(".")
Pkg.add(["DataFrames", "CSV"]) # writes into Project.toml and Manifest.toml
Pkg.status()
Pkg.update()
Pkg.instantiate() # install exactly what Manifest.toml records
Pkg.test() # runs test/runtests.jl in a clean environment
Layout and testing
# src/MyPkg.jl
module MyPkg
include("types.jl")
include("operations.jl")
using .Types # a submodule declared inside include files
using .Operations
export transform, Point
endFull lesson: Modules and organising a Julia project →
Plotting with Plots.jl and Makie
Layout and series
p1 = scatter(rand(50), rand(50); title = "scatter", markerstrokewidth = 0)
p2 = histogram(randn(1000); bins = 30, title = "histogram", legend = false)
p3 = bar(["a", "b", "c"], [3, 7, 2]; title = "bar")
grid = plot(p1, p2, p3; layout = (2, 2), size = (900, 700))
savefig(grid, "grid.png")
# a 3D surface
xs = ys = range(-2, 2, length = 50)
p4 = surface(xs, ys, (x, y) -> exp(-(x^2 + y^2)))
savefig(p4, "surface.png")
When to use Makie
using CairoMakie # static, no GPU needed
using GLMakie # interactive window or browser
fig = Figure(size = (800, 500))
ax = Axis(fig[1, 1], xlabel = "angle (rad)", ylabel = "value", title = "sin")
lines!(ax, x, sin.(x); color = :steelblue, linewidth = 2)
scatter!(ax, x[1:20:end], sin.(x[1:20:end]); color = :tomato)
fig[2, 1] = Legend(fig, ax, "series")
save("makie.png", fig)Full lesson: Plotting with Plots.jl and Makie →
FAQ
Is this Julia cheat sheet free to use?
Where do the examples come from?
How do I go deeper than a cheat sheet?
Related cheat sheets
Python 3 NumPy pandas Matplotlib Jupyter Notebook Flask
Last refreshed 2026-09-27.