Skip to main content

Section A.1 Getting Started with Julia

This appendix shows how to get started with using Julia. The recommended way is first to install julia as described in Subsection A.1.1. Then follow the steps in Subsection A.1.3 to install Visual Studio Code, an open-source text editor.

Subsection A.1.1 Downloading and Installing Julia

At the top of the main Julia website, click the green Download button, taking you to the downloads page. At the top of this page, you will get a single line to copy paste into Terminal (MacOS or Linux) or PowerShell in Windows. This will install a nice tool called juliaup which is a program that can update julia. Note that all of the commands were run on a Mac (with a M1 chip) in fall 2025. If you run these commands on a different platform at a different time, your results may vary a bit, including the versions that are out at the time.
Running the MacOS version results in
(for accessibility)
Figure A.1.1. Installing Juliaup
continuing with the default installation, hit yes and hopefully you see:
Now installing Juliaup
Checking for new Julia versions
Installing Julia 1.12.0+0.aarch64.apple.darwin14
Checking standard library 
notarization.............................................................done. 
Configured the default Julia version to be 'release'.
Julia was successfully installed on your system.

Depending on which shell you are using, run one of the following
commands to reload the PATH environment variable:

  . /Users/XXXXX/.zshrc
although the default version might be different. There may be instructions to ensure that your system path is set up correctly. Follow the details at the end of the installation process before continuing. Each environment may be a bit different and the install script should detect it correctly and give you the right answers.
You can open the julia REPL (explain in detail below) by typing julia on the command line of Terminal or PowerShell. You should see something like the following.
Julia running in a terminal window
Figure A.1.2. Julia running in a terminal window
Try 2+2 and hit ENTER. You should see 4 and you’re off and running. Although this is way to run julia, it generally isn’t the way most people use it and the next section will show this. Also, the juliaup tool is a powerful way of managing more than one julia version or upgrading your current one. See Subsection A.1.8 for more information.

Subsection A.1.2 Installing the IJulia package

Managing packages will be discussed in depth in Section A.2, but one is needed before we do the next step. Open the REPL by typing julia in a Terminal (on the Mac) or PowerShell (on a window machine). Enter the following two lines:
 1 
using Pkg
Pkg.add("IJulia")
This package allows an interactive (that’s the "I") julia session to be established. If there were no errors, you can exit out of Julia at this point with CTRL-D.

Subsection A.1.3 Installing Visual Studio Code

A nice environment to run Julia in an interactive manner is Visual Studio Code, often shortened to VScode. If you haven’t installed the IJulia package described in the section above, that should be done before installing VScode.
Visual Studio Code is an open-source text editor/integrated development environment (IDE) that has capability of handling many different languages. The download and install is quite simple in that you should visit the VScode website, click the Download button and install the standard way for your platform. Opening the app, you should see something that looks like
(for accessibility)
Figure A.1.3.
and it wouldn’t hurt to go through the Learn the Fundamentals tutorial off the welcome page.
Since VSCode works with files on your local computer, it is fundamental to have a folder that VScode works from. You should have or create a folder that is a project. If you don’t have one currently, use the Finder (MacOS) or Explorer (Windows) to create one inside your Documents folder called My Project. Next, in VScode, go to File, Add Folder to Workspace... and navigate to the folder you just made. You will be asked if you trust this folder.
Although you can use VScode to access the REPL or write files written in Julia, it’s most powerful and flexible by running a notebook file. To do this there are two ways to start a file:
  1. Open a new document (File, then New File...). Then save it somewhere ending with .ipynb for example test.ipynb. You should see a file that looks like
    A test.ipynb file.
  2. Another way to start a file is to click on the top left sidebar button that looks like two file icons. Create a new file inside the project by selecting the directory that you want it to go in. (If nothing is selected it will go in the top-level). Hover over the name of the project and click the icon that looks like a file with a +. It will make a new file which you should name like test.ipynb.
Next, in the upper right corner, you should see "Select Kernel". In this case, select the Julia 1.12 kernel if you installed that. If not, select one that was installed.
In the cell, enter 2+2 or some simple calculation. Click the triangle (play button) or hit SHIFT-ENTER and this will evaluate the cell. You should see the following:
(for accessibility)
Figure A.1.4.

Subsection A.1.4 Installing a VScode Extension

VScode takes on other functionality with extensions. To install a new extension click the four boxes (with the upper right one askew) and there is a box at the top for Search Extensions. Enter julia here as shown:
(for accessibility)
Figure A.1.5.
Clicking on that opens an informational panel in VScode and toward the top, click Install and you will then have some additional support for Julia.
Repeat this for Jupyter which will also VScode to run Jupyter notebooks, which is how we are going to interact with Julia most of the time.

Subsection A.1.5 Running Julia code inside VScode

When you create a new jupyter notebook (those with a .ipynb suffix), you are making a julia interactive notebook. In short, this file format mixes text and code together and is quite easy to use and share with others.
If you have the notebook file that you made above, we’ll keep working on that or you can make a new file (make sure it’s suffix is .ipynb).
In an empty cell enter a=3, hit SHIFT-ENTER and then in a blank cell, enter b=4 and then SHIFT-ENTER. In yet another blank cell, enter a+b and you should see 7. Visually, this should look (this is in dark mode) like:
(for accessibility)
Figure A.1.6.
A few things to note about a julia notebook in VScode:
  • Each cell can have either a single or multiple lines of code.
  • The output from the cell is visually below the cell.
  • If there are multiple lines of code in a single cell, only the last command is echoed out.
  • You can run (or rerun a cell) with either the triangle play button or if you are inside the cell or it is selected SHIFT-ENTER on the keyboard.
  • Notice that each cell has a number in [ ]. This is the order that the cells were evaluated and can help with troubleshooting. The green check indicates that the cell has been run successfully.
  • You can evaluate cells in different order and go back and rerun cells. Try switching the top cell to a=9, re-evaluate it, then re-evaluate the bottom cell and the output should be 13.
There are also many things that can be done with the notebook.
  • To create a new cell, you can hover the mouse above and below cells and get a few buttons pop up.
    (for accessibility)
    • The + Code button adds a new cell that has code style, where the code language corresponds to the current kernel, which we selected when we first opened the file.
    • The + Markdown will make a Markdown cell. This is very useful for entering text, mathematics or other code that you don’t want to run. This will be explain below.
    • The Generate button will open a AI chat window to ask a question (generally to Co-pilot).
  • If you highlight a cell (note: don’t click inside the cell, but on the outside), you’ll see the left side highlighted in blue:
    (for accessibility)
    At this point, there are options on the upper right to shift. These are:
    • Triangle with up arrow: run all cells above (but not including) this cell
    • Triangle with down arrow: run all cells below (and including) this cell.
    • triple dots: lots of options.
    • trash can: delete this cell.
  • Once highlighted a cell can be dragged up and down as well.
  • There are a number of keyboard shortcuts that can be done on a highlighted cell. This page has quite a few helpful ones. The page discusses jupyter notebook and jupyter lab (which is independent of VScode), but should work the same way.

Subsection A.1.6 Using the Julia REPL

Although once you get everything set up, performing some actual work (mathematics) is easier to do in a jupyter notebook, there are times that the REPL can be helpful. You can either open it up in Terminal (MacOS) or PowerShell (Windows), or directly in VScode.

Subsubsection A.1.6.1 Opening a Julia REPL in VScode

The Julia REPL is where you enter single julia statements. A REPL is short for Read-Eval-Print-Loop and is often a interpretative shell where you can enter commands in some language. To get started, click on the REPL in VScode, either go to Terminal, new Terminal or CTRL-` or CMD-J. This starts up julia and you should see:
REPL inside of VScode
Figure A.1.7. REPL inside of VScode
Notice that it’s ready for you to enter something with the julia> prompt.
We will enter a few commands to get started. All julia commands throughout the book will be written in a monospace font and it is a good idea to type along at the same time.
Enter a=2 at one prompt and b=3 at another prompt. You will see the response of 2 and 3 as well. Now enter a+b in a prompt and you should see the result 5.

Subsubsection A.1.6.2 Opening a REPL in Terminal or PowerShell

Alternatively, if you just want julia running and don’t need the full VScode environment, use Terminal (on MacOS) or PowerShell (on windows). Generally search for these programs to open them or find the icon.
Once Terminal or PowerShell is open, type julia and this should look the same as above. Try the same commands as in the previous section.

Subsection A.1.7 The kernel

With the discussion about running Julia in this chapter, there are two main ways that we have discussed passing commands to Julia: using the REPL and using a jupyter notebook in VScode.
In many ways, julia is a program like any other that you run on your computer, however because of the nature of it parsing statements and then giving output, you have to think about it a bit differently. When you start julia, we often will say that you are starting the kernel, which is a basic state which you can feed variables and statements to julia and get output. In both the REPL and a jupyter notebook, there are statements sent to a program (the kernel) and there is a response.
The REPL is actually a simple interface to the kernel in which the commands and output appear on consecutive lines of the window. In contrast, the jupyter notebook separates the input into cells and the output below each cell. As we well see, the output can also contain plots and scrollable tables in a jupyter notebook.
The kernel stores variables, functions and modules in memory and accessing the variables with commands will, in short, answer the questions you’re interested in solving. The kernel doesn’t have a way of removing variables, functions or modules, whereas often we will need to do so. The best way is to restart the kernel, which basically means to shut down julia and restart. It depends on how this you run julia.

Subsubsection A.1.7.1 Restarting the Kernel in the julia REPL

This is probably the simplest. If you opened julia by launching the app by double-clicking an icon, just close the window and you stop the program. Note: you lose everything that you have done, which is another reason why I don’t use this often. Then restart by reopening julia.
If you started julia from a terminal or PowerShell, quit julia using CTRL-D. Then restart julia with the command julia.

Subsubsection A.1.7.2 Restarting the Kernel in VScode

To restart the kernel in VScode click the Restart button at the top of the document. Unfortunately there is not indication that anything happens, but reevaluating a cell should indicate that it has been restarted. Note that the cells are numbers and should restart at 1.

Subsection A.1.8 More juliaup features

We used the problem juliaup install julia on a machine. Short for “julia update”, it is a script that helps you install and update julia. We can check what version of julia is running with juliaup status and after the install as above, we get:
 2 
Recall that this section of the text was updated in Fall of 2025. If you are reading this at a later date, your install version may differ.
 Default  Channel  Version                          Update 
-----------------------------------------------------------
   *    release  1.12.0+0.aarch64.apple.darwin14         
This shows all of the channels/versions that are installed and the * shows that the release channel (official current version). As is common with software that manages versions, there are different channels available for julia. We saw above that by default we installed the release channel. This one is that julia developers feel is the current release.
There are a few other channels that can be installed:
beta
This channel is the version of julia that is almost ready to be released. It is often used for developers to test their packages or other users to test new features of a version.
lts
For users that need a very stable version of julia, the lts or long-term support channel is useful. This version will often be quite stable and only get bugfixes over it’s lifetime.
nightly
For users that want the bleeding edge, then the nightly channel will provide a version of julia with all new code checked in the previous day.
1.x or 1.x.x
You can also grab a particular version, say 1.11 or 1.10.7 of julia this way.

Subsubsection A.1.8.1 Adding another Channel

Let’s add one more channel to see how things work. Perhaps we feel that 1.12 is a little buggy and we want to install 1.11. Then we can do:
juliaup add 1.11
and you should see that 1.11 is being downloaded. Once finished, checking the status with juliaup status results in
 Default  Channel  Version                              Update 
---------------------------------------------------------------
          1.11     1.11.7+0.aarch64.apple.darwin14         
   *      release  1.12.0+0.aarch64.apple.darwin14              
and this shows that there is now a 1.11 channel and the release channel is still default. Note that there is no update. If there was, you would see what version was available. There are many other versions and channels available. If you want to include the beta channel to see what’s coming out next. If you enter juliaup add beta and check the status then
 Default  Channel  Version                              Update 
---------------------------------------------------------------
          1.11     1.11.7+0.aarch64.apple.darwin14         
          beta     1.12.0+0.aarch64.apple.darwin14 
   *      release  1.12.0+0.aarch64.apple.darwin14              
And noticed that both beta and release are both using the same version—this is common.
Checkpoint A.1.8.
Install the lts channel of julia. What version is current for lts?

Subsubsection A.1.8.2 Updating Channels

If you enter juliaup status and get something like:
 Default  Channel  Version                          Update                                              
--------------------------------------------------------------------------------------------------------
          1.11     1.11.7+0.aarch64.apple.darwin14                                                      
          beta     1.12.0+0.aarch64.apple.darwin14  Update to 1.12.1+0.aarch64.apple.darwin14 available 
       *  release  1.12.0+0.aarch64.apple.darwin14  Update to 1.12.1+0.aarch64.apple.darwin14 available 
Where notice that there is something in the update column then that channel can be updated. If this is the case, then juliaup update will update any channel to the current version in that channel. The output will download and do some checking. Here’s some possible output:
Checking for new Julia versions
Updating channel release
Installing Julia 1.12.1+0.aarch64.apple.darwin14
Checking standard library notarization.................................................
Precompiling packages  ╺━━━━━━━━━━
Precompiling SuiteSparse finished.
  1 dependency successfully precompiled in 2 seconds
............done.
Updating channel beta
Removed Julia 1.12.0+0.aarch64.apple.darwin14
This took about 1 minute to do on a fast internet connection. If you enter juliaup status the result is now:
 Default  Channel  Version                          Update 
-----------------------------------------------------------
          1.11     1.11.7+0.aarch64.apple.darwin14         
          beta     1.12.1+0.aarch64.apple.darwin14         
       *  release  1.12.1+0.aarch64.apple.darwin14
And notice in this example, that both the beta and release channels are now at version 1.12.1.

Subsubsection A.1.8.3 Running a particular version of Julia

If we run julia, as shown above, then we should get the 1.12 version. Remember to use CTRL-D to get out of it. If instead, we want to switch to the 1.11 version, then juliaup default 1.11. After doing this, entering julia should show:
Julia running in a terminal window
Figure A.1.9. Julia running in a terminal window
There is an alternative to running a julia REPL without switching the default version in juliaup and that is to pass the version to julia.
julia +1.11
will give a REPL running 1.11 as well.
 3 
The feature of running more than one julia version is perhaps most helpful for developers of packages so they can be able to test their code in different versions of julia. However, I sometimes am interested in new features and jump on beta versions to play with these features.
There are other features of juliaup. Entering juliaup --help gives quite a list of the options.