Julia 1.0 Programming Complete Reference Guide
eBook - ePub

Julia 1.0 Programming Complete Reference Guide

Discover Julia, a high-performance language for technical computing

Ivo Balbaert, Adrian Salceanu

Condividi libro
  1. 466 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Julia 1.0 Programming Complete Reference Guide

Discover Julia, a high-performance language for technical computing

Ivo Balbaert, Adrian Salceanu

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Informazioni sul libro

Learn dynamic programming with Julia to build apps for data analysis, visualization, machine learning, and the web

Key Features

  • Leverage Julia's high speed and efficiency to build fast, efficient applications
  • Perform supervised and unsupervised machine learning and time series analysis
  • Tackle problems concurrently and in a distributed environment

Book Description

Julia offers the high productivity and ease of use of Python and R with the lightning-fast speed of C++. There's never been a better time to learn this language, thanks to its large-scale adoption across a wide range of domains, including fintech, biotech and artificial intelligence (AI).

You will begin by learning how to set up a running Julia platform, before exploring its various built-in types. This Learning Path walks you through two important collection types: arrays and matrices. You'll be taken through how type conversions and promotions work, and in further chapters you'll study how Julia interacts with operating systems and other languages. You'll also learn about the use of macros, what makes Julia suitable for numerical and scientific computing, and how to run external programs.

Once you have grasped the basics, this Learning Path goes on to how to analyze the Iris dataset using DataFrames. While building a web scraper and a web app, you'll explore the use of functions, methods, and multiple dispatches. In the final chapters, you'll delve into machine learning, where you'll build a book recommender system.

By the end of this Learning Path, you'll be well versed with Julia and have the skills you need to leverage its high speed and efficiency for your applications.

This Learning Path includes content from the following Packt products:

  • Julia 1.0 Programming - Second Edition by Ivo Balbaert
  • Julia Programming Projects by Adrian Salceanu

What you will learn

  • Create your own types to extend the built-in type system
  • Visualize your data in Julia with plotting packages
  • Explore the use of built-in macros for testing and debugging
  • Integrate Julia with other languages such as C, Python, and MATLAB
  • Analyze and manipulate datasets using Julia and DataFrames
  • Develop and run a web app using Julia and the HTTP package
  • Build a recommendation system using supervised machine learning

Who this book is for

If you are a statistician or data scientist who wants a quick course in the Julia programming language while building big data applications, this Learning Path is for you. Basic knowledge of mathematics and programming is a must.

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Julia 1.0 Programming Complete Reference Guide è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Julia 1.0 Programming Complete Reference Guide di Ivo Balbaert, Adrian Salceanu in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatik e Programmierung. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
2019
ISBN
9781838824679
Edizione
1
Argomento
Informatik

Creating Our First Julia App

Now that you have a working Julia installation and your IDE of choice is ready to run, it's time to put them to some good use. In this chapter, you'll learn how to apply Julia for data analysis—a domain that is central to the language, so expect to be impressed!
We will learn to perform exploratory data analysis with Julia. In the process, we'll take a look at RDatasets, a package that provides access to over 700 learning datasets. We'll load one of them, the Iris flowers dataset, and we'll manipulate it using standard data analysis functions. Then we'll look more closely at the data by employing common visualization techniques. And finally, we'll see how to persist and (re)load our data.
But, in order to do that, first we need to revisit and take a look at some of the language's most important building blocks.
We will cover the following topics in this chapter:
  • Declaring variables (and constants)
  • Working with Strings of characters and regular expressions
  • Numbers and numeric types
  • Our first Julia data structures—Tuple, Range, and Array
  • * Exploratory data analysis using the Iris flower dataset—RDatasets and core Statistics
  • Quick data visualization with Gadfly
  • * Saving and loading tabular data with CSV and Feather
  • Interacting with MongoDB databases

Technical requirements

The Julia package ecosystem is under continuous development and new package versions are released on a daily basis. Most of the times this is great news, as new releases bring new features and bug fixes. However, since many of the packages are still in beta (version 0.x), any new release can introduce breaking changes. As a result, the code presented in the book can stop working. In order to ensure that your code will produce the same results as described in the book, it is recommended to use the same package versions. Here are the external packages used in this chapter and their specific versions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
In order to install a specific version of a package you need to run:
pkg> add [email protected] 
For example:
pkg> add [email protected]
Alternatively you can install all the used packages by downloading the Project.toml file provided with the chapter and using pkg> instantiate as follows:
julia> download("https://github.com/TrainingByPackt/Julia-1-Programming-Complete-Reference-Guide/tree/master/Chapter11/Project.toml", "Project.toml")
pkg> activate .
pkg> instantiate

Defining variables

We have seen in the previous chapter how to use the REPL in order to execute computations and have the result displayed back to us. Julia even lends a helping hand by setting up the ans variable, which automatically holds the last computed value.
But, if we want to write anything but the most trivial programs, we need to learn how to define variables ourselves. In Julia, a variable is simply a name associated to a value. There are very few restrictions for naming variables, and the names themselves have no semantic meaning (the language will not treat variables differently based on their names, unlike say Ruby, where a name that is all caps is treated as a constant).
Let's see some examples:
julia> book = "Julia v1.0 By Example" julia> pi = 3.14 julia> ANSWER = 42 julia> my_first_name = "Adrian" 
You can follow along through the examples in the chapter by loading the accompanying Jupyter/IJulia notebook provided with this chapter's support files.
The variables, names are case-sensitive, meaning that ANSWER and answer (and Answer and aNsWeR) are completely different things:
julia> answer ERROR: UndefVarError: answer not defined 
Unicode names (UTF-8-encoded) are also accepted as variables names:
julia> δ = 130 
Remember that you can type many Unicode math symbols by typing backslash (\) then the name of the symbol and then the Tab key. For example, \pi[Tab] will output π.
Emojis also work, if your terminal supports them:
julia> 
= "apollo 11"
The only explicitly disallowed names for variables are the names of built-in Julia statements (do, end, try, catch, if, and else, plus a few more):
julia> do = 3 ERROR: syntax: invalid "do" syntax 
julia> end = "Paris" ERROR: syntax: unexpected end
Attempting to access a variable that hasn't been defined will result in an error:
julia> MysteryVar ERROR: UndefVarError: MysteryVar not defined 
It's true that the language does not impose many restrictions, but a set of code style conventions is always useful—and even more so for an open source language. The Julia community has distilled a set of best practices for writing code. In regard to naming variables, the names should be lowercase and in just one word; word separation can be done with underscores (_), but only if the name would be difficult to read without them. For example, myvar versus total_length_horizontal.
Given that the degree of difficulty in reading a name is a subjective thing, I'm a bit split about this naming style. I normally prefer the crystal-clear clarity of separating at word boundaries. But nevertheless, it is better to follow the recommendation, given that function names in the Julia API adhere to it. By adhering to the same conventions, your code will be consistent throughout.

Constants

Constants are variables that, once declared, can't be changed. They are declared by prefixing them with the const keyword:
julia> const firstmonth = "January" 
Very importantly in Julia, constants are not concerned with their value, but rather with their type. It is a bit too early to discuss types in Julia, so for now it suffices to say that a type represents what kind of a value we're dealing with. For instance, "abc" (within double quotes) is of type String, 'a' (within single quotes) is of type Char , and 1000 is of type Int (because it's an integer). Thus, in Julia, unlike most other languages, we can change the value assigned to a constant as long as the type remains the same. For instance, we can at first decide that eggs and milk are acceptable meal choices and go vegetarian:
julia> const mealoption = "vegetarian" 
And we can change our mind later on, if we decide to go vegan. Julia will let it slide with just a warning:
julia> mealoption = "vegan" WARNING: redefining constant mealoption "vegan"  
However, attempting to say that mealoption = 2 will result in an error:
julia> mealoption = 2 ERROR: invalid redefinition of constant mealoption 
This makes sense, right? W...

Indice dei contenuti