Julia Tutorial
Learn Julia step by step: 40 lessons in 12 chapters with examples, quizzes, diagrams and projects.
Start learning →
of lessons completed
Getting Started
- What Is Julia? Learn what the Julia programming language is, why it was created, how its JIT compiler removes the two-language problem and where Julia is used today.
- Installing Julia and Using the REPL Install Julia with juliaup, learn the four REPL modes (julia>, help?>, shell> and pkg>), run script files and set up VS Code or a notebook.
- Your First Julia Program Write your first Julia program: print with println, add comments, create variables, build strings with interpolation and meet 1-based indexing.
Basics
- Numbers and Math Learn Julia numeric types: Int64, Float64, Rational, Complex and BigInt, literals, division with div and rem, integer overflow and the ^ and .^ operators.
- Strings and Characters Learn Julia strings and chars: String vs Char, byte-based indexing, interpolation, join, split, replace, regular expressions and Unicode handling.
- Control Flow Learn Julia control flow: if/elseif/else, the ternary operator, short-circuit evaluation, for and while loops, break, continue, ranges and begin blocks.
- Functions Learn Julia functions: long and short form, multiple return values, optional and keyword arguments, anonymous functions, do blocks and the ! naming convention.
Collections
- Arrays and Vectors Learn Julia arrays: 1-based indexing, push!, slicing, ranges, comprehensions, views versus copies and column-major memory order, with NumPy stand-ins.
- Matrices and Linear Algebra Learn Julia matrices and the LinearAlgebra standard library: matrix literals, A*B, transpose, the backslash solver, determinants and eigenvalues, with NumPy.
- Broadcasting and the Dot Syntax Understand Julia broadcasting: dot calls on any function, fused loops with @., in-place broadcast!, shape rules and how it differs from NumPy vectorization.
- Tuples and Named Tuples Learn Julia tuples and named tuples: immutability, destructuring, splatting into function calls, keyword arguments from NamedTuple, with Python stand-ins.
- Dictionaries and Sets Learn Julia dictionaries and sets: Dict creation, pairs, get, haskey, iteration order, union, intersect and setdiff, with runnable Python stand-ins.
Types and Dispatch
- The Type System Understand Julia's type system: abstract and concrete types, the type hierarchy, typeof, isa, subtyping with <:, Union types and the special type Any.
- Structs and Custom Types Define your own Julia types with struct and mutable struct, write outer and inner constructors, customize show, and use Base.@kwdef for keyword defaults.
- Multiple Dispatch Learn Julia's core idea, multiple dispatch: functions with many methods, choosing by every argument, ambiguity errors, and extending existing functions.
- Parametric Types and Generic Code Write generic Julia code with parametric types, where clauses and type parameters, understand invariance and Vector{T}, and rely on duck typing safely.
- Interfaces and Iteration Protocols Learn how Julia interfaces work without interface keywords: implement iterate, length and getindex, extend Base methods, and design abstract type contracts.
Modules and Packages
- Modules and Scope Organize Julia code with modules, learn the difference between using and import, export names, and master global and local scope, let blocks and closures.
- Packages and Environments Use Julia's built-in package manager: add packages, read Project.toml and Manifest.toml, activate environments, share reproducible setups and create your own package.
Performance
- How Julia Compiles Code See how Julia's just-in-time compiler specializes methods on argument types, why the first call is slow, and how to inspect the result with @code_warntype.
- Performance Tips Make Julia code fast: keep functions type stable, avoid global variables, preallocate, use views and in-place functions, loop in column-major order and benchmark properly.
- Threads, Tasks and Distributed Computing Run Julia code in parallel: Threads.@threads, tasks and channels, atomics and locks to avoid race conditions, Distributed processes and a short GPU overview.
Metaprogramming
Errors and I/O
- Errors and Exceptions Handle failure in Julia: read common error messages, use throw, error and @assert, catch exceptions with try/catch/finally, define custom exception types.
- Files and I/O Read and write files in Julia: open with do blocks, read and readlines, append mode, IOBuffer, path helpers, and CSV files through packages.
Data and Science
- DataFrames.jl Work with tables in Julia using DataFrames.jl: build, select, filter, sort, groupby and combine, join, handle missing data, and compare with pandas.
- Plotting Make line, scatter and bar plots in Julia with Plots.jl and Makie: labels, legends, multiple series, subplots, saving figures, and the first-plot delay.
- Differential Equations and Optimization Solve ODEs with DifferentialEquations.jl, formulate linear programs with JuMP, and minimize functions with Optim.jl, with Python stand-ins you can run.
- Random Numbers and Statistics Generate random numbers with rand and randn, set seeds for repeatable results, summarize data with Statistics, and use Distributions.jl, with NumPy stand-ins.
Testing and Tooling
- Testing with Test.jl Write tests in Julia with the Test standard library: @test, @testset, @test_throws, approximate equality, test files for packages, and continuous integration.
- Debugging and Profiling Find bugs and slow code in Julia: Revise for fast reloads, Infiltrator and Debugger for stepping, @profile and flame graphs, and tracking allocations.
- Calling Python, C and R Use code from C, Python and R inside Julia: ccall and shared libraries, PythonCall.jl, RCall.jl, type conversion, array layout, and common pitfalls.
Projects
- Project: Numerical Simulation Build two numerical simulations in Julia, a heat equation with broadcasting and an n-body orbit with structs, then check them against a runnable NumPy port.
- Project: A Data Analysis Pipeline Build a small Julia data pipeline: read a CSV, clean missing values, compute revenue, group and summarize with DataFrames.jl, and plot, with a pandas port.
- Project: A Small Generic Package Build a small Julia package from scratch: parametric types, multiple dispatch, constructors, a test suite, docstrings and docs, and how to share it.
- Project: Monte Carlo Estimation Estimate pi and price a stock option with Monte Carlo simulation in Julia: random numbers, standard error, variance reduction and multi-threading.
Practice and Review
- Practice Exercises with Solutions Fifteen Julia exercises on arrays, broadcasting, dispatch, structs, iteration and performance, each with a worked solution and a runnable Python stand-in.
- Common Mistakes and Gotchas The Julia mistakes that cost beginners the most time: slow globals, 1-based indexing, loop order, type instability, aliasing, and Python and MATLAB habits.
- Julia Interview Questions Twenty-two Julia interview questions with model answers: multiple dispatch, type stability, JIT compilation, macros, packages, concurrency and performance.
- Julia Cheat Sheet A one-page Julia cheat sheet: syntax, collections, strings, types, multiple dispatch, broadcasting, performance rules and Pkg commands with short examples.