TExcelTAD
Home › Julia › Julia Get Started

Julia Get Started

You can follow this whole course in the browser, but sooner or later you'll want Julia on your own computer. This lesson shows how to install it, how to use the interactive REPL, and how to run a script.

Installing Julia

The recommended installer is juliaup, a small tool that downloads Julia and keeps it up to date (similar to rustup for Rust).

bash
# Windows (PowerShell or the Microsoft Store)
winget install --name Julia --id 9NJNWW8PVKMN -e -s msstore

# macOS and Linux
curl -fsSL https://install.julialang.org | sh

After installing, open a new terminal and check the version:

bash
$ julia --version
julia version 1.11.2

With juliaup you can install several versions side by side:

bash
juliaup add 1.10        # install the long-term-support release
juliaup default 1.11    # choose the version that `julia` starts
juliaup update          # update everything

The REPL

Typing julia with no arguments starts the REPL (Read-Eval-Print Loop). You type an expression, press Enter, and Julia prints its value:

text
julia> 1 + 2
3

julia> name = "Ada"
"Ada"

julia> uppercase(name)
"ADA"

julia> ans
"ADA"

ans always holds the last result. The REPL has several modes, selected by the first key you press on an empty line:

Key Mode Prompt Used for
(none) Julian julia> Running Julia code
? Help help?> Reading documentation, e.g. ?println
] Pkg pkg> Installing and managing packages
; Shell shell> Running shell commands like ls

Press Backspace on an empty line to return to Julian mode, and Ctrl+D (or type exit()) to quit. Tab completion works for names and even Unicode symbols: type \alpha and press Tab to get α.

Running a script

Julia source files use the .jl extension. Save this as hello.jl:

julia · try it yourself
greeting = "Hello"
for name in ["world", "Julia"]
    println(greeting, ", ", name, "!")
end
Hello, world!
Hello, Julia!

and run it from a terminal:

bash
$ julia hello.jl
Hello, world!
Hello, Julia!

A script can read its command-line arguments from the global ARGS vector of strings. In the playground there are no arguments, so ARGS is empty:

julia · try it yourself
println("Number of arguments: ", length(ARGS))
println("Arguments: ", ARGS)
Number of arguments: 0
Arguments: String[]

You can also load a file into a running REPL with include("hello.jl"), which runs it as if you had typed its contents.

Editors

The most popular setup is Visual Studio Code with the official Julia extension. It gives you syntax highlighting, an integrated REPL, a plot pane, a debugger and inline results. Pluto.jl and Jupyter (via IJulia) are notebook environments popular for teaching and data analysis.

A first program with a function

julia · try it yourself
function greet(name)
    return "Welcome to Julia, $(name)!"
end

println(greet("learner"))
println(typeof(greet("x")))
Welcome to Julia, learner!
String

Tip: In the REPL, a trailing semicolon hides the result: x = rand(1000); stores the value without flooding your screen.

Test yourself

Which key switches the Julia REPL into package mode?

  1. ?
  2. ;
  3. ]
  4. #

What file extension do Julia source files use?

  1. .julia
  2. .jul
  3. .jl
  4. .ju

Where does a Julia script find its command-line arguments?

  1. argv
  2. ARGS
  3. sys.argv
  4. args()