Julia Lab Examples
julia file.jl, then change one thing and run it again — that second run is where the learning happens.
Every example is self-contained: no package to install, no project to activate, nothing but the standard library. Where a lesson introduced a concept — implicit types, multiple dispatch, the type tree, lexical scope — there is a program here that shows it working, and one line you can break to see what happens when it is wrong.
Foundations
Variables, expressions, and the ways Julia decides what to do next. Start here: these files introduce the values (Int, Float64, Bool, String, Char) that every later example uses.
| # | Description | Link |
|---|---|---|
| 1 | Variables and implicit types | View |
| 2 | Literals and operators | View |
| 3 | Boolean values and logic | View |
| 4 | Single-branch conditional | View |
| 5 | Comparison and branching on input | View |
| 6 | Character input with an if/elseif ladder | View |
| 7 | Conditional loop with while | View |
| 8 | Counting loop with continue | View |
| 9 | Nested iteration over two ranges | View |
Functions & Scope
A function is the unit of reuse and the unit of method dispatch. These four programs show declaration, a declared return type, and the difference between global, local, and let-block scope — the rule that explains most "why is my variable nothing?" questions.
| # | Description | Link |
|---|---|---|
| 10 | Declaring and calling a function | View |
| 11 | A function with a declared return type | View |
| 12 | Global versus local variables | View |
| 13 | Nested let blocks | View |
Collections & Types
Arrays, tuples, dictionaries, and the type machinery underneath them: abstract and primitive types, composite structs, and parametric types. Run these with the REPL open and inspect typeof(x) after each line.
| # | Description | Link |
|---|---|---|
| 14 | Arrays: one and two dimensional | View |
| 15 | Tuples: indexing and destructuring | View |
| 16 | Dictionaries: keys to values | View |
| 17 | The type tree: abstract and primitive types | View |
| 18 | Composite types with mutable struct | View |
| 19 | Parametric types: Point{T} | View |
Errors & Files
Two programs about failure: how to guarantee a file is closed when something throws, and how to catch an error and return a useful value instead of crashing. Delete the try in either one and watch the behaviour change.
| # | Description | Link |
|---|---|---|
| 20 | Opening and closing a file with try/finally | View |
| 21 | Recovering from an error with try/catch | View |
julia roadmap/julia/demo/01_variables.jl — or open it in the code viewer and copy it out. Files 5 and 6 read from standard input, so they expect you to type a character and press Enter. Nothing here needs a package, which makes this folder a good place to practise without touching a project environment.
Larger, multi-file programs follow in Study Projects.