Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning Julia
  • Table Of Contents Toc
Learning Julia

Learning Julia

By : Anshul Joshi, Lakhanpal
3 (2)
close
close
Learning Julia

Learning Julia

3 (2)
By: Anshul Joshi, Lakhanpal

Overview of this book

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.
Table of Contents (11 chapters)
close
close
8
Data Visualization and Graphics

Installing Julia

As mentioned earlier, Julia is open source and is available for free. It can be downloaded from the website at http://julialang.org/downloads/.

The website has links to documentation, tutorials, learning, videos, and examples. The documentation can be downloaded in popular formats, as shown in the following screenshot:

It is highly recommended to use the generic binaries for Linux provided on the julialang.org website.

As Ubuntu and Fedora are widely used Linux distributions, a few developers were kind enough to make the installation on these distributions easier by providing it through package manager. We will go through them in the following sections.

Julia on Ubuntu (Linux)

Ubuntu and its derived distributions are one of the most famous Linux distributions. Julia's deb packages (self-extracting binaries) are available on the website of JuliaLang, mentioned earlier. These are available for both 32-bit and 64-bit distributions. One can also add Personal Package Archive (PPA), which is treated as an apt repository to build and publish Ubuntu source packages. In the Terminal, type the following commands:

$ sudo apt-get add-repository ppa:staticfloat/juliareleases
$ sudo apt-get update

This adds the PPA and updates the package index in the repository. Now install Julia using the following command:

$ sudo apt-get install Julia

The installation is complete. To check whether the installation is successful in the Terminal, type the following:

$ julia --version

This gives the installed Julia's version:

$ julia version 0.5.0

To uninstall Julia, simply use apt to remove it:

$ sudo apt-get remove julia

Julia on Fedora/CentOS/Red Hat (Linux)

For Fedora/RHEL/CentOS or distributions based on them, enable the EPEL repository for your distribution version. Then, click on the link provided. Enable Julia's repository using the following:

$ dnf copr enable nalimilan/julia

Or copy the relevant .repo file available at:

/etc/yum.repos.d/

Finally, in the Terminal type the following:

$ yum install julia

Julia on Windows

Go to the Julia download page (https://julialang.org/downloads/) and get the .exe file provided according to your system's architecture (32-bit/64-bit). The architecture can be found on the property settings of the computer. If it is amd64 or x86_64, then go for 64-bit binary (.exe), otherwise go for 32-bit binary. Julia is installed on Windows by running the downloaded .exe file, which will extract Julia into a folder. Inside this folder is a batch file called julia.exe, which can be used to start the Julia console.

Julia on Mac

Users with macOS need to click on the downloaded .dmg file to run the disk image. After that, drag the app icon into the Applications folder. It may prompt you to ask if you want to continue, as the source has been downloaded from the internet and so is not considered secure. Click on Continue if it was downloaded from the official Julia language website. Julia can also be installed using Homebrew on a Mac, as follows:

$ brew update
$ brew tap staticfloat/julia
$ brew install julia

The installation is complete. To check whether the installation is successful in the Terminal, type the following:

$ julia --version

This gives you the Julia version installed.

Building from source

Building from source could be challenging for beginners. We assume that you are on Linux (Ubuntu) right now and are building from source. This provides the latest build of Julia, which may not be completely stable. Perform the following steps to build Julia from source:

  • On the downloads page of the Julia website, download the source. You can choose Tarball or GitHub. It is recommended to use GitHub. To clone the repo, GitHub must be installed on the machine. Otherwise, choose Download as ZIP. Here is the link: https://github.com/JuliaLang/julia.git.
  • To build Julia, it requires various compilers: g++, gfortran, and m4. We need to install them first, if not installed already, using the $ sudo apt-get install gfortran g++ m4 command.
  • Traverse inside the Julia directory and start the make process, using the following command:
      $ cd julia
$ make
  • On a successful build, Julia can be started up with the ./julia command.
  • If you used GitHub to download the source, you can stay up to date by compiling the newest version using the following commands:
      $ git pull 
$ make clean
$ make

Understanding the directory structure of Julia's source

Julia's source stack

Let's have a look at the directories and their content:

Directory Contents
base/

Julia's standard library

contrib/

Miscellaneous set of scripts, configuration files

deps/

External dependencies

doc/src/manual

Source for user manual

doc/src/stdlib

Source for standard library function help text

examples/

Example Julia programs

src/

Source for Julia's language core

test/

Test suits

test/perf

Benchmark suits

ui/

Source for various frontends

A brief explanation about the directories mentioned earlier:

  • The base/ directory consists of most of the standard library.
  • The src/ directory contains the core of the language.
  • There is also an examples directory containing some good code examples, which can be helpful when learning Julia. It is highly recommended to use these in parallel.

On the successful build on Linux, these directories can be found in the Julia's folder. These are usually present in the build directory.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning Julia
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon