This document covers two ways to get started using Julia. We'll use the most recent release, which is currently v0.6.2
The vast majority of computing is performed on *nix operating systems, the most familiar of which include Linux, OpenBSD, and MacOS. A common feature on all these systems is the bash shell, often via a terminal. If you aren't already familiar with the bash shell, use this course as an opportunity to get started - it will open up all sorts of computing resources to you. This class will assume that you are using such a system.
To Windows users: Julia can be installed on Windows, but for the purposes of this course, you are encouraged to choose one of the following options:
- [likely easiest] Use Ubuntu (a Linux distribution) inside Windows 10 - see here
- Obtain a Linux virtual machine. You can try installing this on your computer, but many departments at Stanford offer them to students.
- SSH into a *nix computing resource, such as Farmshare 2. For example, see here for some options.
- Dual boot your Windows machine with a *nix operating system.
If you have significant development experience on Windows, you may be able to navigate the course with Julia on Windows. However, the instructor will not be very useful for the purposes of troubleshooting any problems.
Don't worry - you don't need much for this course. Many references can be found online, but here's one quick reference.
Once you can navigate the filesystem using the commands ls, cd, pwd, mkdir, rmdir
, you should be able to follow the instructions below.
We will be using the latest stable release of Julia in this class (at the time of writing, Julia 1.2.0).
The easiest and recommended option is to download Julia for your machine here.
On Macs, download the Julia .dmg file at this link. Open the disk image and copy the Julia executable to your Applications folder. Double click the application to launch Julia. Once here, you may add a symlink to this executable so that you can call Julia from the command line-- use the command
sudo ln -s /Applications/Julia-1.2.app/Contents/Resources/julia/bin/julia /usr/local/bin/julia
Download the correct file for your system at the download link. Extract the contents to a known folder on your computer (I suggest creating a folder at ~/app
.) Once you have extracted the contents of the archive, open Terminal and run the magic words
cd /usr/local/bin
sudo ln -s {folder you extracted Julia to}/julia-1.2.0/bin/julia .
to create a symlink on the terminal. To run Julia, type julia
into Terminal.
For advanced users, another option is to install from source. This will get you started using git version control, and if you want to contribute to Julia down the road you'll be half way there. In earlier versions of Julia compiling your own copy of Julia would give you compiler optimizations not present in the official binaries: this is typically no longer the case though.
Instructions can be found on the Julia GitHub page
- [recommended] if you don't already have one, set up a GitHub account - much of the Julia ecosystem lives on GitHub, and if you ever want to contribute you'll need an account
- Open up a terminal on your machine
- Create/choose a directory you would like your Julia build to live in, and clone the Julia repository
cd /your/path/
git clone git://github.com/JuliaLang/julia.git
- checkout the current latest version
cd julia
git checkout v1.2.0
- [optional] Configure Julia's build
- build julia
make -j 4 # parallelizes build
The path to the Julia executable is now
/your/path/julia/julia
- [optional] Edit your
.bashrc
file to allow you to start Julia from anywhere in your terminal. There are several ways to achieve this, but one way is using an alias, e.g. see here
You may have a lab or department cluster you'd like to use. Here we'll cover how to start Julia on Stanford's community computing cluster Farmshare 2
- ssh into Farmshare 2
ssh <suid>@rice.stanford.edu
Where <suid>
is replaced by your stanford ID. Follow the login prompts
- The default version of Julia on rice is v0.5.2. Since we want the most up-to-date version, we'll load the Julia module
module load julia
- Launch Julia using
julia
When you call the julia
command from the terminal or run the executable, you enter the interactive REPL (Read/Evaluate/Print/Loop). You can read more here
Remember, we're going to use the current version (v1.2.0)
- You can determine this from the command line using
julia --version
- When the REPL launches you can see version information in the start-up splash.
- Julia has a command for displaying version information:
versioninfo()
Now that you can start the Julia REPL, you may wish to be able to close it. This can be done using exit()