Getting Started with Julia Programming Table of Contents Getting Started with Julia Programming Credits About the Author About the Reviewers www.PacktPub.com Support files, eBooks, discount offers, and more Why subscribe? Free access for Packt account holders Preface What this book covers What you need for this book Who this book is for Conventions Reader feedback Customer support Downloading the example code Errata Piracy Questions The Rationale for Julia The scope of Julia Julia’s place among the other programming languages A comparison with other languages for the data scientist MATLAB R Python Useful links Summary Installing the Julia Platform Installing Julia Windows version – usable from Windows XP SP2 onwards Ubuntu version OS X Building from source Working with Julia’s shell Startup options and Julia scripts Packages Adding a new package Installing and working with Julia Studio Installing and working with IJulia Installing Sublime-IJulia Installing Juno Other editors and IDEs How Julia works Summary Variables, Types, and Operations Variables, naming conventions, and comments Types Integers Floating point numbers Elementary mathematical functions and operations Rational and complex numbers Characters Strings Formatting numbers and strings Regular expressions Ranges and arrays Other ways to create arrays Some common functions for arrays How to convert an array of chars to a string Dates and times Scope and constants Summary Functions Defining functions Optional and keyword arguments Anonymous functions First-class functions and closures Recursive functions Map, filter, and list comprehensions Generic functions and multiple dispatch Summary Control Flow Conditional evaluation Repeated evaluation The for loop The while loop The break statement The continue statement Exception handling Scope revisited Tasks Summary Collection Types Matrices Tuples Dictionaries Keys and values – looping Sets Making a set of tuples Example project – word frequency Summary More on Types, Methods, and Modules Type annotations and conversions Type conversions and promotions The type hierarchy – subtypes and supertypes Concrete and abstract types User-defined and composite types When are two values or objects equal or identical? Multiple dispatch example Types and collections – inner constructors Type unions Parametric types and methods Standard modules and paths Summary Metaprogramming in Julia Expressions and symbols Eval and interpolation Defining macros Built-in macros Testing Debugging Benchmarking Starting a task Reflection capabilities Summary I/O, Networking, and Parallel Computing Basic input and output Working with files Reading and writing CSV files Using DataFrames Other file formats Working with TCP sockets and servers Interacting with databases Parallel operations and computing Creating processes Using low-level communications Parallel loops and maps Distributed arrays Summary Running External Programs Running shell commands Interpolation Pipelining Calling C and FORTRAN Calling Python Performance tips Tools to use Summary 10 The Standard Library and Packages Digging deeper into the standard library Julia’s package manager Installing and updating packages Publishing a package Graphics in Julia Using Gadfly on data Summary A List of Macros and Packages Macros List of packages Index Getting Started with Julia Programming L libraries about / Standard modules and paths LightTable URL / Installing Juno linter tool / Tools to use list comprehension about / Map, filter, and list comprehensions LLVM JIT compiler backend about / Generic functions and multiple dispatch local keyword / Scope revisited local scope / Scope revisited M macros / Macros defining / Defining macros and functions, differences / Defining macros hygienic macro / Defining macros built-in macros / Built-in macros @printf / Macros @sprintf / Macros @which / Macros @time / Macros @elapsed / Macros @task / Macros @assert / Macros @test / Macros @test_approx_eq / Macros @test_approx_eq_eps / Macros @show / Macros @timed / Macros @allocated / Macros @async / Macros @data / Macros @spawnat / Macros @sync / Macros @spawn / Macros @everywhere / Macros @parallel / Macros @windows / Macros @unix / Macros @linux / Macros @osx / Macros @inbounds / Macros @profile / Macros macros, built-in testing / Testing debugging / Debugging benchmarking / Benchmarking task, starting / Starting a task map about / Map, filter, and list comprehensions maps / Parallel loops and maps matrices about / Matrices method about / Generic functions and multiple dispatch methods / Parametric types and methods modules about / Standard modules and paths multiple dispatch about / Generic functions and multiple dispatch example / Multiple dispatch example N names function / Using DataFrames naming conventions about / Variables, naming conventions, and comments O object-oriented (OO) languages about / Generic functions and multiple dispatch Open Database Connectivity (ODBC) about / Interacting with databases operations about / Elementary mathematical functions and operations operators about / First-class functions and closures optional keyword arguments about / Optional and keyword arguments optional positional arguments about / Optional and keyword arguments OS X installation for / OS X overloading about / Generic functions and multiple dispatch P packages about / Packages, Julia’s package manager URL / Packages, Adding a new package, Julia’s package manager, Publishing a package new package, adding / Adding a new package installing / Installing and updating packages updating / Installing and updating packages publishing / Publishing a package MATLAB / List of packages Rif / List of packages PyCall / List of packages Winston / List of packages IJulia / List of packages PyPlot / List of packages ZMQ / List of packages Jewel / List of packages Dates / List of packages TimeZones / List of packages ImmutableArrays / List of packages Compat / List of packages DataFrames / List of packages DataArrays / List of packages RDatasets / List of packages JSON / List of packages LightXML / List of packages YAML / List of packages HDF5 / List of packages IniFile / List of packages ODBC / List of packages Cpp / List of packages Clang / List of packages Lint / List of packages TypeCheck / List of packages ProfileView / List of packages Gadfly / List of packages parallel operations and computing / Parallel operations and computing processes, creating / Creating processes low-level communications, using / Using low-level communications parametric type about / Parametric types and methods paths about / Standard modules and paths performance tips / Performance tips Personal Package Archive (PPA) URL / Ubuntu version pipelining about / Pipelining processes creating / Creating processes profiler tool / Tools to use ProfileView package URL / Tools to use project example / Example project – word frequency PyPlot about / Graphics in Julia Python calling / Calling Python Q quote operator / Expressions and symbols R ranges and arrays / Ranges and arrays rational and complex numbers about / Rational and complex numbers read(STDIN, Char) command / Basic input and output Read Evaluate Print Loop (REPL) / Windows version – usable from Windows XP SP2 onwards recursive functions about / Recursive functions reflection about / Reflection capabilities RegexMatch object, properties match / Regular expressions offset / Regular expressions offsets / Regular expressions captures / Regular expressions regular expressions about / Regular expressions URL / Regular expressions remote calls / Using low-level communications remote references / Using low-level communications repeated evaluation about / Repeated evaluation for loops / The for loop while loops / The while loop break statement / The break statement continue statement / The continue statement rethrow() statement / Exception handling round off error / Floating point numbers S SageMath project URL / Other editors and IDEs scope about / Scope and constants, Scope revisited sets about / Sets of tuples, creating / Making a set of tuples shell commands running / Running shell commands single dispatch about / Generic functions and multiple dispatch slice / Ranges and arrays splice operator (splat) / How to convert an array of chars to a string standard input (stdin) / Basic input and output standard library about / Digging deeper into the standard library standard output (stdout) / Basic input and output stream-oriented about / Basic input and output string interpolation about / Interpolation strings about / Strings and formatting numbers / Formatting numbers and strings array of chars, converting to / How to convert an array of chars to a string Sublime-IJulia installing / Installing Sublime-IJulia URL / Installing Sublime-IJulia Sublime Text URL / Installing Sublime-IJulia subtypes function / The type hierarchy – subtypes and supertypes super function / The type hierarchy – subtypes and supertypes T tasks about / Tasks, Starting a task TCP servers working with / Working with TCP sockets and servers TCP sockets working with / Working with TCP sockets and servers Transmission Control Protocol (TCP/IP) / Working with TCP sockets and servers tuples about / Tuples set, creating / Making a set of tuples type annotations about / Type annotations and conversions type conversions about / Type conversions and promotions type hierarchy about / The type hierarchy – subtypes and supertypes supertypes / The type hierarchy – subtypes and supertypes subtypes / The type hierarchy – subtypes and supertypes type parameters about / Parametric types and methods types about / Types type unions about / Type unions U Ubuntu version, Julia OS X / OS X Julia, building from source / Building from source user-defined type about / User-defined and composite types objects / When are two values or objects equal or identical? values / When are two values or objects equal or identical? multiple dispatch, example / Multiple dispatch example V variables about / Variables, naming conventions, and comments vector about / Matrices Vim URL / Other editors and IDEs W while loops about / The while loop Windows version, Julia about / Windows version – usable from Windows XP SP2 onwards, Ubuntu version URL / Windows version – usable from Windows XP SP2 onwards Winston about / Graphics in Julia URL / Graphics in Julia Z 7zip extractor program URL / Windows version – usable from Windows XP SP2 onwards ... Getting Started with Julia Programming Table of Contents Getting Started with Julia Programming Credits About the Author About the Reviewers... List of Macros and Packages Macros List of packages Index Getting Started with Julia Programming Getting Started with Julia Programming Copyright © 2015 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system,... The Rationale for Julia The scope of Julia Julia’s place among the other programming languages A comparison with other languages for the data scientist MATLAB R Python Useful links Summary Installing the Julia Platform