# MonthOfJulia Day 1: Installation and Orientation

2015-08-31 Andrew B. Collier

As a long-term R user I’ve found that there are few tasks (analytical or otherwise) that R cannot immediately handle. Or be made to handle after a bit of hacking! However, I’m always interested in learning new tools. A month or so ago I attended a talk entitled Julia’s Approach to Open Source Machine Learning by John Myles White at ICML in Lille, France. What John told us about Julia was impressive and intriguing. I felt compelled to take a closer look. Like most research tasks, my first stop was the Wikipedia entry, which was suitably informative.

And so I embarked on a Month of Julia. Over the next 30 days (give or take a few) I will be posting about my experiences as a new Julia user. I’ll start with some of the language basics and then dig into a few of the supplementary packages. Today I’ll start with installation and a quick tour of the interpreter.

If you have the time and patience you’ll find it instructive to read these:

But, if you’re like me, then you’ll get half way through the first paper and have the overpowering urge to start tinkering. Don’t delay. Tinker away.

You should undoubtedly read the papers in their entirety once the first wave of tinkering subsides.

## Installation

I’m running Ubuntu 15.04, so this will be rather specific. Installation was extremely simple (handled entirely by the package manager) and it looks like other platforms are similarly straightforward (check the Downloads page). I will be using Julia version 0.3.10.

I’m not quite sure why I was in the Pictures folder when I kicked off the install, but this is by no means a requirement!

The Julia interpreter is launched by typing julia at the command prompt. At launch it displays a nice logo which, incidentally, can be reproduced at any time for your amusement and pleasure using Base.banner().

The default colours in the interpreter are not going to work for me, so I tracked down the configuration file (~/.juliarc.jl) and made some changes. Ah, that’s better.

Update (2018/07/21): The above approach will not work with contemporary Ubuntu. Here’s what you should do instead:

1. Go to https://julialang.org/downloads/ and download a generic Linux binary appropriate for your machine. In my case this was an archive named julia-0.6.4-linux-x86_64.tar.gz.
2. Extract the archive.

$cd /opt/$ sudo tar -zxvf ~/Downloads/julia-0.6.4-linux-x86_64.tar.gz
3. Link the resulting executable into the PATH. The path to the Julia executable will likely be different depending on the version.

$cd /usr/bin/$ sudo ln -s /opt/julia-9d11f62bcb/bin/julia
4. Start Julia.

$julia ## Interacting with the Julia Interpreter The Julia REPL is designed for interaction. I will pick out a few of the key features (you can find further details here). • By default the value of an expression is echoed back as the “answer”. You can suppress this behaviour by ending the expression with a semicolon. • The value of the previous expression can be retrieved with the ans variable. • You activate the help system by typing ? at the prompt or by using help(). • You can also search through the help documents using apropos(). • You can get immediate access to the system shell by typing ; at the prompt. • You can search back through your command history using the “normal” Ctrl-r shell binding. • Ctrl-l will clear the contents of the console. • Use Ctrl-d to exit the interpreter. • Tab completion rocks: use it! (It works with Unicode too, by some sort of strange magic! Check out the table of Tab completion sequences. Then try typing x\^2 followed by Tab. When I first saw that this worked I almost wet my pants.) If you’re like me then you’ll want to put your code into script files. Julia scripts normally have a “.jl” extension and are executed in the interpreter either by specifying the script name on the command line like this: $ julia test-script.jl

or from within the interpreter using

julia> include('test-script.jl')

## Keeping Up to Date

To ensure that you have the most recent released version of Julia (not necessarily available through the default Ubuntu repositories), you can add specific PPAs.

$sudo add-apt-repository ppa:staticfloat/juliareleases$ sudo add-apt-repository ppa:staticfloat/julia-deps
\$ sudo apt-get update

## Code Samples

I’ll be posting code samples on GitHub.

More to come tomorrow. In the meantime though, do yourself a favour and watch the videos below.