Pluto & Julia

In the solution of exercises, we will use an IDE (Integrated Development Environment) called Pluto.jl. This IDE is a package developed for the Julia computing language. This tool is easy to learn, beautiful, and extremely powerful. In the period in which we live, keeping on solving exercises with the help of a small calculator and Excel is like being still in the medieval age in the evolution of humankind. We have to adapt quickly to the age of "Big Data", "Artificial Intelligence", and "Machine Learning", even in teaching tools and course syllabi.

Moreover, all tests in this course will be taken using a computer and the Pluto IDE. It means that tests will be "open book", but students have to know how to use Pluto with basic operations. Pluto's use will be a funny, handy tool for learning, teaching, and conducting the evaluation process. We assure students that Pluto will be the less demanding part of this course but one of its most valuable items.

The installation of the software below will be done in a special Zoom session. This session will take place before classes start and you will receive an email for that purpose.

You do not need more than 500MB of free space in the hard disk of your computer.

If you want to have a go and install it yourself, that will be fine. But go only up to point number 5 in the sequence below. Points 6 to 9 will be covered on our classes.

1. Install Julia. Go to the following address:

  • https://julialang.org/downloads/

  • Download the executable that suits your computer's Operating System (Windows, macOS, Linux)

  • Run the executable file.

  • Allow the executable to install the program in the default directory

  • Click on the small box to make it blue to enable: Add Julia to PATH (see box on the right-hand side). This step is required in Windows, but not in macOS, nor in Linux.

  • The installation will run quite fast.

  • Click on finish. Julia is installed.

2. Set Julia Properties

It is only required for the Windows operating system. The macOS does not require this step.


  • The Julia window is black by default, as seen on the right-hand side figure ( you can change its color).

  • To allow the Copy/Past thing into the Julia window, click on the icon of Julia (those three little circles on the top left-hand corner of the window).

  • Then, a menu with various entries will pop up (see the second figure): click on Properties

  • A new window will appear (see the third figure below). Here, to enable the Copy/Past thing, we have to click on the little box circled with a blue line to activate

Use Ctrl + Shift +C/V as Copy/Past

and, after the small square becomes filled with blue, then choose

OK

That is it. Your Julia window is ready to accept the Copy/Past functionality. However, remember that to copy something, one should click on:

ctrl + C

and to past it into the Julia window, click on:

ctrl + shift + V

3. Start using Julia:

  • Double click on the icon of Julia: 3 little circles

  • A black window will pop up (figure 1 above): this is Julia's window, also called the REPL (you can make it the size you want: larger, taller)

  • Type: 3*4 , then click on enter. If the output is 12, Julia is running.

  • Julia executes under two modes:

    • Julia mode: julia> . This is the default mode, it appears whenever you open Julia. It is in this mode that computation takes place.

    • Package mode: (@v1.7) pkg> . This mode is designed to manage the packages that we want to install, upgrade, or remove.

  • To switch from one mode to the other:

    • Julia mode: start Julia

    • From Julia mode to Package mode: pressing the keyboard ] key

    • From Package mode to Julia mode: on the keyboard click on backspace.


4. Managing packages:

  • At the current time, there are around 8000 packages available.

  • We should only install the packages required for our current work: 26 packages (see next point).

  • The following commands are used to manage the packages' system. Be sure you are in the Package mode: (@v1.7) pkg>

    • add PackageName --> enter : adds a package called PackageName.jl to the Julia environment (obviously, PackageName.jl is an illustration).

    • remove PackageName - -> enter :removes a package called PackageName.jl from the Julia environment. (or use the short name rm)

    • update --> enter :updates the packages installed in the Julia environment to the latest versions. (we can use the short name up)

    • status --> enter : shows all packages installed in the Julia environment. (we can use the short name st)

5. Packages. To install the packages we need:

  • Go to Package mode and type: add PackageName, then click enter (do it one by one, in the list below).

  • These are the packages that we have to install (attention: they are case sensitive and no spaces between package names)

  • To make the installation very easy use the Copy/Past functionality. Go to each line below, highlight the text, click on ctrl + C, then go to the Julia window in package mode (@v1.7) pkg> and past by clicking on ctrl + shift + V , then press enter.

  • Do it for all the packages, one by one.

add LinearAlgebra

add DataFrames

add PlotlyJS

add PlotlyBase

add HypertextLiteral

add Pluto

add PlutoUI

add CSV

add HTTP

add TimeSeries

add RollingFunctions

add Dates

add MonthlyDates

add SparseArrays

add StatsBase

add ColorSchemes

add LaTeXStrings

add NLsolve

add JuMP

add Clp

add GLPK

add Ipopt

add Symbolics

  • If you want also install the three packages below (you may find things on the internet that use them)

add Plots

add Statistics

add Random

6. Start using Pluto:

  • In Julia mode julia> , type: using Pluto ---> enter (note the blank space between using and Pluto)

  • Then type: Pluto.run() ---> enter

  • That's it: Pluto has opened a window in your default browser (Mozilla, Chrome, Edge, or others). That is where you will work with Pluto, using Julia as the engine at the back.

7. Opening a notebook with Pluto:

  • Go to the folder where your notebook is saved and copy the folder's path.

  • To obtain this path, press the mouse's right button on top of that folder, click on Properties, and copy the path in the Location entry.

  • This path will look something like this:

    • Windows: H:\Teaching\MacroI\Week09_Policy

    • Linux: /home/viola/Desktop/Teaching/MacroI/Week09_Policy

    • macOS: /Users/viola/Desktop/Teaching/MacroI/Week09_Policy

  • Past that path to the small box on the image on the right. ------------------------>

  • Inside the small window (in yellow), at the end of the copied path (see arrow number 1 in the second image):

    • add a back-slash \ (if you use Windows)

    • add a forward-slash / (if you use Linux)

    • add a forward-slash / (if you use macOS)

  • Once the slash is added, a small window displays the files in that folder.

  • Click only once on top of the file name you want to run. In this example, the file is "Exercises_Wek09.jl". See arrow number 2. Notice that Pluto can only open Julia files, which have an extension .jl

  • Then, click on "Open", see arrow number 3.

  • Pluto will start our notebook. It takes a while to open the first notebook.

  • The notebook is now ready to use.

8. Saving a notebook with Pluto:

  • When you apply changes to a notebook, a small box displaying ctr+s immediately appears at the top right-hand corner of your monitor. All the changes to the notebook will be saved if you click on it. Or then, to save changes, just press the keyboard keys simultaneously: ctrl s

  • Even easier. When we change a cell or introduce a new cell, if we run this cell, changes will be automatically saved. To run a cell, we can use one of following two options:

    • Click on: ctrl s

    • Click on the small circle as in the image below.

9. Exporting a Pluto notebook:

Notice that you can export a notebook in three other formats:

    • as a "Julia" file

    • as an "HTML" file

    • as a "pdf" file

  • To do that, go to the beginning of your notebook. There is a small icon with the export box at the top right-hand side of the monitor (see image below); click on it.

  • The three alternative ways of saving your notebook are visible at the top of the monitor: .jl .html .pdf