Getting started#

Warning

Julia takes backwards compatibility seriously, so code from this book will keep working for years. But the tooling around it moves. The code here targets the stable 1.12 release line. Where the 1.10 LTS behaves differently, I’ll say so. If something here no longer matches what your REPL says, trust the REPL, and please open a GitHub pull request so I can fix it.

Prologue#

There are two ways to start learning a new programming language.

The first is to lean on what you already know and draw parallels between the new language and the concepts you’re comfortable with, essentially bridging the gap between the old and the new.

The second is to start from scratch and meet each concept step by step, like a complete beginner.

Everyone learns differently, and both paths are valid. With Julia, I’d gently push you toward the second one.

Here’s why. Julia’s syntax is friendly enough that a Python or MATLAB programmer can read it on day one and feel at home. That familiarity is a trap. Julia looks like Python, but underneath it is a fundamentally different language — compiled rather than interpreted, organized around multiple dispatch rather than classes and methods, with arrays as a first-class concern rather than a library bolted on top. If you read Julia as “Python with different keywords,” you will write slow Julia and blame the language.

So: familiar enough that you’ll be productive in an afternoon, different enough that you should stay curious for a few weeks. That’s the deal.

One more thing before we start. The official Julia documentation is superb, and it is a reference manual — precise, complete, and organized by topic rather than by learning order. This book is not that. We’ll start with the kind of code that loads data, transforms it, and prints a result, and only reach for the deeper machinery when we actually need it. When you outgrow this book, the manual is waiting.

Installing Julia#

The recommended way to install Julia is juliaup, the official installer and version manager. It handles your PATH, lets you keep several Julia versions side by side, and tells you when a new release lands. Do not install Julia from your Linux distribution’s package manager — those builds are frequently out of date or subtly broken.

macOS and Linux#

curl -fsSL https://install.julialang.org | sh

Close and reopen your terminal afterwards so the julia command lands on your PATH.

Windows#

winget install julia -s msstore

You can also install it directly from the Microsoft Store. Both routes give you the same thing.

Note

Julia runs natively on Windows, macOS (Intel and Apple Silicon), and Linux. There is no WSL requirement — Windows is a first-class platform here.

Check that it worked#

julia --version

You should see something like julia version 1.12.6. If you do, you’re ready.

Managing versions later#

juliaup is worth two minutes of your time now so you never fight it later:

juliaup status          # what's installed, and which is default
juliaup update          # pull the latest release
juliaup add lts         # also install the long-term-support version
juliaup default lts     # make LTS your default

Because different Julia versions live side by side, you can test a package against both the stable and LTS lines without uninstalling anything. Run a specific one with julia +lts.

The REPL: your most important tool#

Type julia with no arguments and you land in the REPL (Read-Eval-Print Loop). Almost every other language has one of these; in Julia it’s not a toy, it’s where you’ll spend a large fraction of your working day.

julia> 2 + 2
4

julia> versioninfo()
Julia Version 1.12.6
...

What makes the Julia REPL special is that it has modes. Press a single key at an empty prompt and the whole prompt changes:

  • ? enters help mode. Type any function name and get its documentation. ?println right now, go on.

  • ] enters package mode, where you install and manage packages. We’ll live here in the Packages chapter.

  • ; enters shell mode, so you can run ls or pwd without leaving Julia.

Press Backspace at an empty prompt to get back to the normal julia> prompt. Press Ctrl-D or type exit() to quit.

Two more REPL habits worth forming on day one:

  • ans always holds the result of the last expression.

  • Ending a line with ; suppresses printing the result. Handy when you’ve just computed a million-element array and don’t want it dumped to your screen.

An editor for Julia#

You can write Julia in any text editor, but I’d use Visual Studio Code with the official Julia extension. It gives you syntax highlighting, autocompletion, inline evaluation (send a line straight to a running REPL with Shift+Enter), a plot pane, a debugger, and a profiler.

Note

A note on notebooks Julia works in Jupyter through the IJulia package, and Google Colab has supported Julia natively since 2025. But do try Pluto.jl, which is a genuinely different idea: a reactive notebook. Change a value in one cell and every cell that depends on it re-runs automatically. There’s no stale state, no “I ran the cells out of order and now nothing makes sense.” For teaching and exploration it’s the nicest notebook experience I’ve used in any language.

Your first Julia program#

Create a file named hello.jl and add:

println("Hello, world!")

Run it:

julia hello.jl

Two things to notice already:

  • There’s no main() function and no boilerplate. A Julia script is just a sequence of statements, executed top to bottom. (You can define an entry point for compiled applications, and we will later, but you don’t need one to run a file.)

  • println prints its argument and adds a newline. Its sibling print doesn’t.

Getting help on anything#

This is the single most useful habit in Julia, so let’s build it now. In the REPL:

julia> ?println

You get the full docstring, including every method signature. Everything in Julia is documented this way — the standard library, and any decent package you install. When you’re not sure what something does, you’re one keystroke from finding out.

A first taste of what makes Julia different#

Before we start properly, here’s a two-minute demo of the thing I want you to keep an eye on for the rest of the book.

julia> f(x) = x^2 + 1
f (generic function with 1 method)

julia> f(3)
10

julia> f(3.0)
10.0

julia> f(3 + 4im)
(-8 + 24im)

One definition. Three completely different calculations: integer arithmetic, floating-point arithmetic, and complex arithmetic. And critically, Julia didn’t do this by checking types at runtime and branching. It compiled three separate specialized machine-code versions of f, one for each type it saw.

You can watch it happen:

julia> @code_llvm f(3)

That prints the LLVM intermediate code Julia generated for the integer version. You don’t need to understand it today. I show it now because it’s the essential fact about this language: the friendly, dynamic, math-like code you write is not being interpreted. It’s being compiled, per type combination, on demand. Everything in the rest of this book — the type system, dispatch, performance advice, all of it — is downstream of that one fact.

The julia command#

The julia command-line tool does more than run files. A few options you’ll reach for early:

  • julia script.jl — run a file.

  • julia — start the interactive REPL.

  • julia --project=. — start using the current directory’s project environment (this becomes important in the Packages chapter, and it’s a good default habit).

  • julia -t auto — start with threading enabled, using all available cores.

  • julia -e 'println("hi")' — evaluate a one-liner and exit.

  • julia --help — show everything available.

Note

Threading changed in 1.12 As of Julia 1.12, asking for multiple threads (-t auto or -t4) also gives you an extra interactive thread in a separate pool, so a long computation can’t freeze your REPL. If you explicitly ask for -t1 you get exactly one thread and nothing extra. On the 1.10 LTS you have to request the interactive pool yourself with -t4,1.

With Julia installed and Hello, world! on the screen, we’re ready to actually learn the language. Next stop: data, types, and variables.