3  The Julia programming language

I will do my best to mirror what’s in the text. I will touch on many of the same higher-level concepts as the chapter on R does. However, Julia does have some differences. As a result, I sometimes deviate from the text to highlight some of the language’s unique features.

3.1 Get the software

Go install Julia on your computer. Go to https://julialang.org/ and follow the instructions. If you are curious about the history of Julia, go check out https://julialang.org/blog/2012/02/why-we-created-julia/, a blog post by the language developers. I also highly recommend this as well as this Youtube video for a brief explanation of the motivation behind the Julia language. I make also make use of a variety of add-on packages in this project. You can install them all by executing this code block.

using Pkg

dependencies = [
    "Turing",           #https://turing.ml/stable/
    "AbstractMCMC",     #https://github.com/TuringLang/AbstractMCMC.jl
    "MCMCChains",       #https://github.com/TuringLang/MCMCChains.jl
    "DataFrames",       #https://dataframes.juliadata.org/stable/
    "DataFramesMeta",   #https://juliadata.github.io/DataFramesMeta.jl/stable/
    "Distributions",    #https://juliastats.org/Distributions.jl/stable/
    "Gadfly",           #http://gadflyjl.org/stable/
    "StatsPlots",       #https://github.com/JuliaPlots/StatsPlots.jl
    "Optim",            #https://julianlsolvers.github.io/Optim.jl/stable/
    "IJulia",           #https://github.com/JuliaLang/IJulia.jl
    "Revise"            #https://timholy.github.io/Revise.jl/stable/#Introduction-to-Revise-1
]

Pkg.add(dependencies)
Warning

Sometimes installing dependencies right into your immediate environment can cause a headache later. Instead, consider creating a project for your code from this book. A project is Julia’s way of tracking the versions of packages used and is the best practice for managing the range of competing dependencies from the spread of packages. For more information, check out the documentation at https://pkgdocs.julialang.org/v1/environments/.

3.2 A look at VS Code

Visual Studio Code, also commonly referred to as VS Code, is an Integrated development environment (IDE) developed by Microsoft. VS Code has consistently been ranked one of the most popular IDEs. Due to its popularity, the support from the user base has made VS Code an excellent choice for developing in Julia. To get all the features for running Julia within VS Code, check out the documentation: https://code.visualstudio.com/docs/languages/julia. You are, of course, free to use any IDE you see fit.

3.3 A simple example of Julia in action

3.4 Basic commands and operators in Julia

3.5 Variable types

3.6 Loading and saving data

3.7 Some utility functions

3.8 Programming in Julia

3.9 Graphical plots: Opening and saving