#MonthOfJulia Day 1: Installation and Orientation

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.

Background Reading

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.

julia-install

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().

julia-default-terminal

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.

julia-pimped-terminal

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().
    julia-help-system

  • You can get immediate access to the system shell by typing ; at the prompt.
    julia-command-shell

  • 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.

The post #MonthOfJulia Day 1: Installation and Orientation appeared first on Exegetic Analytics.