Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Julia 1.0 Programming

You're reading from   Julia 1.0 Programming Dynamic and high-performance programming to build fast scientific applications

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher
ISBN-13 9781788999090
Length 196 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Ivo Balbaert Ivo Balbaert
Author Profile Icon Ivo Balbaert
Ivo Balbaert
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Installing the Julia Platform FREE CHAPTER 2. Variables, Types, and Operations 3. Functions 4. Control Flow 5. Collection Types 6. More on Types, Methods, and Modules 7. Metaprogramming in Julia 8. I/O, Networking, and Parallel Computing 9. Running External Programs 10. The Standard Library and Packages 11. Other Books You May Enjoy

Packages

Most of the standard library in Julia (which can be found in /share/julia/base and /share/julia/stdlib, relative to where Julia was installed) is written in Julia itself. The rest of Julia's code ecosystem is contained in packages that are simply GitHub repositories. They are most often authored by external contributors, and already provide functionality for such diverse disciplines such as bioinformatics, chemistry, cosmology, finance, linguistics, machine learning, mathematics, statistics, and high-performance computing. A package listing can be found at http://pkg.julialang.org.

Julia's installation contains a built-in package manager, Pkg, for installing additional packages that are written in Julia. Version and dependency management is handled automatically by Pkg.

Pkg has a REPL mode, which can be started from within the Julia REPL by entering the ] key, which is often called the REPL's package mode. The Pkg mode is shown as a blue prompt, like this: (v1.0) pkg>.

From this mode, we can start all functions of Pkg. To return to the normal REPL mode, press Backspace or Ctrl + C.

To initialize your environment, enter the init command, which creates an empty Project.toml file in your Julia installation folder.

Adding a new package

Before adding a new package, it is always a good idea to update your package database for the already installed packages with the up command. Then, add a new package by issuing the add PackageName command, and execute it by using PackageName in the code or in the REPL.

For example, to add 2D plotting capabilities, install the Plots package with add Plots in the Package mode by first typing ]. This installs the Plots package and all of its dependencies, building them when needed.

To make a graph of 100 random numbers between 0 and 1, execute the following commands:

using Plots 
plot(rand(100))

The rand(100) function is an array with 100 random numbers. This produces the following output:

A plot of white noise with Plots

After installing a new Julia version, update all the installed packages by running up in the Pkg REPL-mode.

You have been reading a chapter from
Julia 1.0 Programming - Second Edition
Published in: Sep 2018
Publisher:
ISBN-13: 9781788999090
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image