Downloading the code accompanying the book.
Packt Publishing distributes the sources on their GitHub website, and for this book, the sources can be found at https://github.com/PacktPublishing/Mastering-Julia-Second-Edition
These can be viewed using a web browser and can be downloaded using the git clone <git-url
> command which will create a copy of the sources named Mastering-Julia-Second Edition
.
As this is somewhat unwieldy, I have renamed this as MJ2
on my computer(s), and this is used in the text throughout the book and in the Julia scripts.
To clone the sources may require using the built-in git command, although it is possible to use an editor such as Visual Studio Code of a GIT IDE. Whether git
is available from the command line depends on which operating system is being used.
- macOS doesn’t have a built-in version of Gi; however, it’s included as part of Xcode or else installed via using homebrew or by choosing an IDE such as GitHub Desktop.
- Most Linux distros have the git command already built in.
- For Windows binaries can be downloaded from the main
git
website using https://git-scm.com/download; in fact, this page includes sources for all three operating systems plus links to several popular git clients.
The source accompanying this book is arranged as a set of code folders, one per chapter denoted from Code01 through to Code11, containing all the Julia source code relating to the chapter. For example, the Code01 folder contains the relevant script named as: Chp02.jl
. There may be additional sources and in particular those corresponding to Jupyter and Pluto notebooks. The sources in each folder are described in the markdown file(s) README.md or the equivalent README.txt file.
Additionally, there is a Project.TOML
and a Manifest.TOML
file for each chapter plus a script (setup.jl
) which can be used to create these from scratch rather than using the ones provided.
These can be utilized by switching to the specific project via the package manager via
julia> import Pkg; Pkg.activate(".")
Possibly when first cloned it may be sensible to also include: Pkg.instantiate()
It will be found to be necessary to work with individual chapter projects rather than adding all Julia modules to the general registry, which otherwise will get extremely clogged, with probable conflicts arising. However, in addition to building up manifests, the reader may find setup.jl
useful in getting started with some of the earlier code samples in the book, rather than just adding them individually in the REPL
Additionally, there are two other directories: Alice and DataSources
- Alice has a set of files, from the Alice books and others of Lewis Carroll’s works, which are used in some text processing routines.
- DataSources is split into subfolders containing datasets, such as those in CSV and TSV formats, and files necessary for the sections working with SQL-based and other databases.
As an example ENV["HOME"]*"/MJ2/DataSources"
is used as a reference to the location of the data sources directory, since ENV["HOME"]
is an alias to my user home directory and I have added the GitHub sources as a folder directly under it.
Note that on Windows this alias is now ENV["HOMEPATH"
]. So the construct joinpath
(ENV["HOMEPATH"],"MJ2","DataSources")
may be preferred as it does not depend on the directory separator, though in my experience either “\\
” or “/
” can be used in Julia when on Windows.