O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Learning Julia

Book Description

Learn Julia language for data science and data analytics

About This Book

  • Set up Julia's environment and start building simple programs
  • Explore the technical aspects of Julia and its potential when it comes to speed and data processing
  • Write efficient and high-quality code in Julia

Who This Book Is For

This book allows existing programmers, statisticians and data scientists to learn the Julia and take its advantage while building applications with complex numerical and scientific computations. Basic knowledge of mathematics is needed to understand the various methods that will be used or created in the book to exploit the capabilities for which Julia is made.

What You Will Learn

  • Understand Julia's ecosystem and create simple programs
  • Master the type system and create your own types in Julia
  • Understand Julia's type system, annotations, and conversions
  • Define functions and understand meta-programming and multiple dispatch
  • Create graphics and data visualizations using Julia
  • Build programs capable of networking and parallel computation
  • Develop real-world applications and use connections for RDBMS and NoSQL
  • Learn to interact with other programming languages–C and Python—using Julia

In Detail

Julia is a highly appropriate language for scientific computing, but it comes with all the required capabilities of a general-purpose language. It allows us to achieve C/Fortran-like performance while maintaining the concise syntax of a scripting language such as Python. It is perfect for building high-performance and concurrent applications. From the basics of its syntax to learning built-in object types, this book covers it all.

This book shows you how to write effective functions, reduce code redundancies, and improve code reuse. It will be helpful for new programmers who are starting out with Julia to explore its wide and ever-growing package ecosystem and also for experienced developers/statisticians/data scientists who want to add Julia to their skill-set.

The book presents the fundamentals of programming in Julia and in-depth informative examples, using a step-by-step approach. You will be taken through concepts and examples such as doing simple mathematical operations, creating loops, metaprogramming, functions, collections, multiple dispatch, and so on.

By the end of the book, you will be able to apply your skills in Julia to create and explore applications of any domain.

Style and approach

This book demonstrates the basics of Julia along with some data structures and testing tools that will give you enough material to get started with the language from an application standpoint.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Conventions
    5. Reader feedback
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Understanding Julia's Ecosystem
    1. What makes Julia unique?
      1. Features and advantages of Julia
    2. Installing Julia
      1. Julia on Ubuntu (Linux)
      2. Julia on Fedora/CentOS/Red Hat (Linux)
      3. Julia on Windows
      4. Julia on Mac
      5. Building from source
        1. Understanding the directory structure of Julia's source
        2. Julia's source stack
    3. Julia's importance in data science
      1. Benchmarks
    4. Using REPL
      1. Using help in Julia
      2. Plots in REPL
    5. Using Jupyter Notebook
    6. What is Juno?
    7. Package management
      1. Pkg.status() – package status
      2. Pkg.add() – adding packages
      3. Working with unregistered packages
      4. Pkg.update() – package update
      5. METADATA repository
        1. Developing packages
        2. Creating a new package
    8. A brief about multiple dispatch
      1. Methods in multiple dispatch
    9. Understanding LLVM and JIT
    10. Summary
    11. References
  3. Programming Concepts with Julia
    1. Revisiting programming paradigms
      1. Imperative programming paradigm
      2. Logical programming paradigm
      3. Functional programming paradigm
      4. Object-oriented paradigm
    2. Starting with Julia REPL
    3. Variables in Julia
      1. Naming conventions
    4. Integers, bits, bytes, and bools
      1. Playing with integers in REPL
      2. Understanding overflow behavior
      3. Understanding the Boolean data type
    5. Floating point numbers in Julia
      1. Special functions on floating point numbers
      2. Operations on floating point numbers
        1. Computations with arbitrary precision arithmetic
      3. Writing expressions with coefficients
    6. Logical and arithmetic operations in Julia
      1. Performing arithmetic operations
        1. Performing bitwise operations
        2. Operators for comparison and updating
        3. Precedence of operators
        4. Type conversions (numerical)
    7. Understanding arrays, matrices, and multidimensional arrays
      1. List comprehension in Julia
        1. Creating an empty array
      2. Operations on arrays
      3. Working with matrices
        1. Different operation on matrices
        2. Working with multidimensional arrays (matrices)
      4. Understanding sparse matrices
    8. Understanding DataFrames
      1. NA data type in DataArray
        1. The requirement of the NA data type
        2. DataArray – a series-like data structure
      2. DataFrames – tabular data structures
    9. Summary
  4. Functions in Julia
    1. Creating functions
      1. The special !
    2. Function arguments
      1. Pass by values versus pass by reference
      2. Pass by sharing
      3. The return keyword
      4. Arguments
        1. No arguments
        2. Varargs
        3. Optional arguments
      5. Understanding scope with respect to functions
        1. Nested functions
    3. Anonymous functions
    4. Multiple dispatch
      1. Understanding methods
    5. Recursion
    6. Built-in functions
      1. An example using simple built-in functions
    7. Summary
  5. Understanding Types and Dispatch
    1. Julia's type system
      1. What are types?
      2. Statically-typed versus dynamically-typed languages
      3. So, is Julia a dynamically-typed or statically-typed language?
    2. Type annotations
    3. More on types
      1. The Integer type
      2. The Float type
      3. The Char type
      4. The String type
      5. The Bool type
      6. Type conversions
    4. The subtypes and supertypes
      1. The supertype() function
      2. The subtype() function
    5. User-defined and composite data types
      1. Composite types
    6. Inner constructors
    7. Modules and interfaces
      1. Including files in modules
    8. Module file paths
      1. What is module precompilation?
    9. Multiple dispatch explained
    10. Summary
  6. Working with Control Flow
    1. Conditional and repeated evaluation
      1. Conditional evaluation in detail
      2. Short-circuit evaluation
      3. Repeated evaluation
      4. Defining range
      5. Some more examples of the for loop
      6. The break and continue
    2. Exception handling
      1. The throw() function
      2. The error() function
      3. The try/catch/finally blocks
    3. Tasks in Julia
    4. Summary
  7. Interoperability and Metaprogramming
    1. Interacting with operating systems
      1. Filesystem operations
      2. I/O operations
        1. Example
    2. Calling C and Python!
      1. Calling C from Julia
      2. Calling Python from Julia
    3. Expressions and macros
      1. Macros
      2. But why metaprogramming?
    4. Built-in macros
    5. Type introspection and reflection capabilities
      1. Type introspection
      2. Reflection capabilities
    6. Summary
  8. Numerical and Scientific Computation with Julia
    1. Working with data
      1. Working with text files
      2. Working with CSV and delimited file formats
      3. Working with DataFrames
        1. NA
        2. DataArrays
        3. DataFrames
    2. Linear algebra and differential calculus
      1. Linear algebra
      2. Differential calculus
    3. Statistics
      1. Simple statistics
      2. Basic statistics using DataFrames
      3. Using Pandas
      4. Advanced statistics topics
        1. Distributions
        2. TimeSeries
        3. Hypothesis testing
    4. Optimization
      1. JuMP
      2. Convex.jl
    5. Summary
  9. Data Visualization and Graphics
    1. Basic plots
      1. Bar graphs
      2. Histograms
      3. Pie charts
      4. Scatter plots
      5. 3-D surface plots
    2. Vega
      1. Area plots
      2. Aster plots
      3. Choropleth map
      4. Heatmaps
      5. Ribbon plots
      6. Wordcloud
      7. Scatter plots
    3. Gadfly
      1. Interacting with Gadfly using the plot function
      2. Plotting DataFrames with Gadfly
    4. Summary
  10. Connecting with Databases
    1. How to connect with databases?
    2. Relational databases
      1. SQLite
      2. MySQL
    3. NoSQL databases
      1. MongoDB
    4. Introduction to REST
      1. What is JSON?
      2. Web frameworks
    5. Summary
  11. Julia’s Internals
    1. Under the hood
      1. Femtolisp
      2. The Julia Core API
    2. Performance enhancements
      1. Global variables
      2. Type declarations
        1. Fields with abstract types
        2. Container fields with abstract type
        3. Declaring type for keyword arguments
      3. Miscellaneous performance tweaks
    3. Standard library
    4. LLVM and JIT explained
    5. Parallel computing
      1. Focusing on global variables
      2. Running loops in parallel
    6. TCP sockets and servers
      1. Sockets
    7. Creating packages
      1. Guidelines for package naming
      2. Generating a package
    8. Summary