Type "?" to see how to use this presentation.

Outline

Outline

Introduction

What is Julia?

Julia is a high-level programming language for technical computing.

Another Language?

Why do we need another programming language?

What could Julia offer that Python, Ruby, Matlab, R, C, Go, ... don't?

What is Julia?

Julia is a high-level programming language for technical computing.

It was designed to incorporate the best features of other technical computing tools to create a blazing fast, easy-to-write language.

Motivation

In their inaugural blog post, the authors explained that they created Julia out of greed.

They wanted language that was fast, easy, and usable that would be applicable to their own work. Namely:

  • Scientific computing
  • Machine learning
  • Data mining
  • Large-scale linear algebra
  • Distributed and parallel computing

Language Facts

  • Garbage collected
  • Just-in-time compiled
  • Built on LLVM Compiler Infrastructure
    • The same framework Clang, Rust, and Swift are built on
  • Reuses best-of-the-best libraries from C and Fortran
  • Cross-platform
  • Designed for distributed and parallel computing
  • Supports calls to C and Fortran

Why Julia?

It's High-Level

Like Python or Matlab, its simple syntax makes it easy to get started writing programs in Julia.

Julia is imperative, and language constructs are familiar to Ruby, Python, and Matlab programmers.

Also, it's garbage collected. You don't have to worry about memory unless you want to.

It's So Fast

2012 Study. Performance relative to C. C Performance is 1.0
2012 Study. Performance relative to C. C Performance is 1.0

Packages!

The Julia community is growing and releasing a lot of libraries for you to use. Julia even has a built-in package manager to make using and sharing community packages easy!

Julia Package Registry

Language Features & Batteries

Topics

Functions

Definitions

Julia offers several ways to define functions:

function f(x, y)
    return x + y
end

f(x, y) = x + y

Function Definition Demo

Operators

Operators are just normal functions, but with special calling syntax.

type Complex
    real::Float64
    imag::Float64
end

function +(a::Complex, b::Complex)
  Complex(a.real + b.real, a.imag + b.imag)
end

Operator Demo

Anonymous Functions

Sometimes it's convenient to write functions that will only be used once.

lst = [1, 2, 3, 4]
squared = map(x -> x * x, lst)

Anonymous Function Demo

Multiple Dispatch

What is it?

Developers are free to implement functions with a variety of type signatures to handle different usage.

Julia decides at runtime which version of a function to use.

Multiple Dispatch Demo

Ambiguity

What happens when multiple function signatures fit?

Methods are stored in order of specificity. The function with the more specific type signature will be the one that's used.

If two functions are equally specific, a warning is generated.

Ambiguous Function Matching

Vectors and Matrices

Julia and Linear Algebra

Linear algebra was one of the focuses the authors considered when designing Julia.

If you know Matlab, this should seem familiar

Indexing

Indexing starts at 1.

Vectors / Arrays

Vectors and Arrays Demo

Special Operators

Each of the bracket operators are just shortcuts for other functions.

Vector And Matrix Function Demo

Types

Types

Julia's blazing performance relies heavily on its type system.

It offers several different types that can be defined by developers:

  • Abstract types
  • Bits types
  • Composite types
  • Union types

Abstract Types

Abstract types cannot be instantiated. Their purpose is to give structure to Julia's type hierarchy. The root of the type hierarchy is the Any type. <: can be read as "subtype of."

abstract Number
abstract Real     <: Number
abstract FloatingPoint <: Real
abstract Integer  <: Real
abstract Signed   <: Integer
abstract Unsigned <: Integer

Implicitly, Number is a direct descendant of Any.

Abstract Type Demo

Bits Types

Bits types can be instantiated. They are fixed-width numbers.

If you so choose, you can define your own bits types!

bitstype 16 Float16 <: FloatingPoint
bitstype 32 Float32 <: FloatingPoint
bitstype 64 Float64 <: FloatingPoint

Composite Types

Composite types are like structs in C or Go. Each type has members, and optional constructors.

type MyComplex
    real::Float64
    imag::Float64

    MyComplex(r, i) = new(r, i)
end

Composite Type Demo

Union Types

Union types combine types together. Note that union types are different from subtypes.

StringOrInteger = Union(AbstractString,Integer)

Union Type Demo

Plotting and Drawing

Gadfly

Gadfly is a prettier alternative to make plots in Julia.

However, it takes a minute to start up.

Why is that?

Gadfly Demo

PyPlot

Yet another plotting library. This one is built on top of Python's matplotlib.

Parallel and Distributed Julia

Parallel Julia

When Julia is started, you can specify the number of worker processes to use with $ ./julia -p 2.

Though Julia offers a number of functions for writing parallel code, its set of macros makes it even easier. For example:

  • @spawn - Do something in another process
  • @parallel - Perform a (special) loop in parallel

Parallel Demo

Distributed Julia

Using a ClusterManager, you can launch a series of Julia workers on remote machines.

These workers are used the same way as parallel Julia's workers, but your code runs on other hardware.

Julia also has mechanisms for migrating data from machine to machine to help your application run.

Distributed demo?

Metaprogramming

Metaprogramming

Julia represents its code using Julia data structures.

This makes it convenient to build and evaluate Julia programs... with Julia programs.

Quick Metaprogramming Demo

Getting Julia

Command line

Get the binary from http://julialang.org/downloads/
Get the binary from http://julialang.org/downloads/

Juno

A Julia IDE based on LightTable.

For all your code-completing needs.
For all your code-completing needs.

IJulia

Install Julia, then Pkg.add("IJulia").

using IJulia
notebook()

JuliaBox

Or, run your code in the cloud!

https://next.juliabox.com/
https://next.juliabox.com/

The Future of Julia

Growing Interest

According to a survey done by KDNuggets,

3. Languages with the highest growth in 2014 were

Julia, 316% growth, from 0.7% share in 2013 to 2.9% in 2014
SAS, 76% growth, from 20.8% in 2013 to 36.4% in 2014
Scala, 74% growth, from 2.2% in 2013 to 3.9% in 2014

2013 Survey: 713 Participants
2014 Survey: 719 Participants

What will it take for you to start using Julia?

What will it take for Julia to be successful?

Packages!

Community involvement \(\implies\) Community packages

As the Julia community grows, more users will open source their libraries to http://pkg.julialang.org.

That means developers can spend less time reinventing the wheel and more time being productive.

KDNuggets identified some neat ones for machine learning.

The Tip of the Iceberg

Pretty cool so far

Mind. Blown.
Mind. Blown.

Learning the Rest

Like any programming language, there's more to be learned about Julia.

A myriad of built-in and community-driven libraries are available for a wide range of domains. If you're interested, go see what's out there.

There are plenty of learning resources available.

Find out more