This article contains affiliate links. See my affiliate disclosure for more information.
Need to get up and running with Julia fast?
This guide walks you through setting up a professional Julia development environment step-by-step. You'll learn how to:
- Install Julia with
- Set up the Julia VS Code extension.
- Create a shared dev environment with common development tools.
- Write a
startup.jlfile to automatically load the shared environment every time Julia launches.
Open up your terminal, and let's dive in.
Install Julia With
You could download a Julia binary from julialang.org, but that's boring.
All the cool kids use
juliaup, a Julia "version multiplexer" inspired by the
rustup project. With
juliaup, you can install multiple Julia versions and switch between them from the command line. It'll even notify you in your terminal when a new Julia version is available.
juliaup, execute the command below that corresponds to your operating system:
curl -fsSL https://install.julialang.org | sh
winget install julia -s msstore
juliaup status to see every Julia version installed by
juliaup. The latest version is already installed:
$ juliaup status Default Channel Version Update ---------------------------------------------------------- * release 1.8.5+0.aarch64.apple.darwin14
You can learn more about
juliaup from the project's README on GitHub.
Set Up The Julia VS Code Extension
You can use Julia with your preferred code editor. But if you want an IDE experience, your best option is VS Code. The same folks behind
juliaup maintain the official Julia VS Code extension.
Download and install VS Code if you haven't already. Then, open VS Code and click on the Extensions tab in the Activity Bar:
Type julia into the search bar. The first result should be the official Julia extension, published by a verified account named julialang:
Click on Install to install the extension:
Unless you changed the location of your Julia install with
juliaup — something that isn't covered in this guide — the extension will find Julia automatically.
To test this, create a
hello_world.jl file somewhere on your computer, open it with VS Code, add the line
print("Hello, world") and save the file, then press the play button in the top right-hand corner of the window:
VS Code executes the script and displays the output in a new Julia REPL window at the bottom of the editor window.
julia.executablePathsetting. See the Julia VS Code extension docs for more information.
The Julia VS Code extension provides language support, Intellisense, linting and formatting tools, and everything else you need to dive into your first Julia project.
Advanced: Create A Shared Dev Environment
The Julia ecosystem has some fantastic developer productivity tools, including:
- Revise.jl for using code changes from the REPL without restarting Julia.
- OhMyREPL.jl for REPL syntax highlighting and bracket matching.
- BenchmarkTools.jl for performance tracking and benchmark analysis.
These three packages turn the Julia REPL into a simple-yet-powerful development environment. It'd be great if you could access these tools no matter which project you're working on. Thanks to Julia's support for stacked environments, you can.
Start by creating a new directory somewhere for the dev tools environment. I keep mine in a folder called
cd into this directory and run Julia:
$ mkdir -p ~/.julia-environments/tools $ cd ~/.julia-environments/tools $ julia
After the REPL starts, press
] to enter the package manager mode:
julia> ] (@v1.8) pkg>
(@v1.8) to the left of
pkg> indicates the base (or global) environment for Julia version 1.8 is currently active. You may see a different version number.
There are two reasons I don't do this:
1. I've been conditioned by years of Python programming to avoid global environments.
2. Julia's global environment lives in
~/.julia/environments/, which is managed by Julia itself. I want my tools environment to live somewhere I know it won't suddenly change (and I can version control).
Create a new environment in the current directory by executing
activate . in the REPL:
(@v1.8) pkg> activate . Activating new project at `~/.julia-enironments/tools` (tools) pkg>
add command to install the
(tools) pkg> add Revise OhMyREPL BenchmarkTools Updating registry at `~/.julia/registries/General.toml` Resolving package versions... Updating `~/.julia-enironments/tools/Project.toml` [6e4b80f9] + BenchmarkTools v1.3.2 [5fb14364] + OhMyREPL v0.5.13 [295af30f] + Revise v3.5.0 Updating `~/.julia-enironments/tools/Manifest.toml` [6e4b80f9] + BenchmarkTools v1.3.2 [da1fd8a2] + CodeTracking v1.2.0 [a8cc5b0e] + Crayons v4.1.1 ... (output truncated) (tools) pkg>
Two files are created in the
Project.tomlcontains the names and hashes for the three packages you installed with the
Manifest.tomldescribes the fully-resolved dependency graph for the packages in
~/.julia-environments/tools/ directory and
Manifest.toml files formally define a Julia environment. But you'll have to explicitly activate the environment each time you want to use it.
Let's change that.
Advanced: Write a
Press Ctrl + D to close the Julia REPL. Then,
cd into the
~/.julia/ was created automatically when you installed Julia with
juliaup. It contains, among other things, global environments, package registries, logs, and configuration files.
Create a file
~/.julia/config/startup.jl with the following contents (cheers to Tim Holy for including a template for loading packages in
startup.jl in the Revise.jl docs):
# ~/.julia/config/startup.jl # Stack the tools environment on top of the currently active environment. # See: https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_LOAD_PATH # Remove the line below if you installed tools in your global environment push!(LOAD_PATH, Base.Filesystem.homedir() * "/.julia-environments/tools/") # Import the tools, or display a warning if something goes wrong try @eval using OhMyREPL catch e @warn "Error initializing OhMyREPL" exception=(e, catch_backtrace()) end try @eval using Revise catch e @warn "Error initializing Revise" exception=(e, catch_backtrace()) end try @eval using BenchmarkTools catch e @warn "Error initializing BenchmarkTools" exception=(e, catch_backtrace()) end
~/.julia/config/directory on a fresh Julia install.
Now, every time you start Julia — even from VS Code —
BenchmarkTools are safely and automatically loaded on top of the active environment without having to install and import them in every project.
Pretty nifty if you ask me!
Here are a few other handy packages to consider installing in your tools environment and importing in your
- JuliaFormatter.jl for auto-formatting your code.
- PkgTemplates.jl for quickly scaffolding new Julia packages.
- Term.jl for improved logging, error, and repr styling.
- AbbreviatedStackTraces.jl for improved stack traces.
And don't miss this long-running thread on the Julia Discourse with many other use cases for
If you're interested in getting started with Julia to work with data, I highly recommend Bogumił Kamiński's book Julia For Data Analysis. It's also got one of the best introductions to Julia for experienced programmers I've seen.
Get instant access from Manning. A Kindle version is available from Amazon.
Want more like this?
One email, every Saturday, with one actionable tip.
Always less than 5 minutes of your time.