Software installation: Julia and Visual Studio Code

Software installation: Julia and Visual Studio Code#

Introduction to programming#

Why Julia?#

  • Fast

  • Easy to learn

  • Dynamic

  • Reproducible

  • Composable

  • General

  • Open source

using Images, FileIO, ImageView, Plots
load("images/benchmark.png")

Alt Text

Installing Julia#

Download and install Julia

load("images/julia1.png")

After installing, make sure that you can run Julia.

load("images/julia2.png")

Choose an IDE#

¿Julia REPL (Read-Evaluate-Print-Loop), Jupyter or Visual Studio Code?

  • Julia has an interface (REPL) where we can directly execute operations (e.g., 2+2) or codes (e.g., code1.jl).

  • In this course, we will use Visual Studio Code, where we can work directly with Julia’s REPL or through a notebook file (.ipynb).

  • It is also possible to work in other IDEs like Jupyter, for which it is recommended to work with Anaconda (or Miniconda).

load("images/ide1.png")

From the following link, you can download Visual Studio Code (VSCode): https://code.visualstudio.com/

Alt Text

Using Packages#

Pkg

Pkg is Julia’s builtin package manager, and handles operations such as installing, updating and removing packages. (https://docs.julialang.org/en/v1/stdlib/Pkg/)

Pkg can be used in two ways:

  1. By calling the package (using Pkg) and then using a command (Pkg.add(“IJulia”))

  2. Accessing Pkg by pressing ] and then entering the command (add “IJulia”)

Try installing the IJulia package, which we will continue to use in the course.

load("images/julia5.png")

The following commands are useful:

  • Pkg.rm(“package name”): Removes a package.

  • Pkg.build(“package name”): Rebuilds a package from its binary files.

  • Pkg.status(): Provides a list of the installed packages.

  • Pkg.update(): Updates the installed packages.

IJulia

Once VSCode is installed, you can install the Julia extension.

IJulia is a Julia-language backend combined with the Jupyter interactive environment (also used by IPython). This combination allows you to interact with the Julia language using Jupyter/IPython’s powerful graphical notebook, which combines code, formatted text, math, and multimedia in a single document. It also works with JupyterLab, a Jupyter-based integrated development environment for notebooks and code. JuliaLang/IJulia.jl

Julia in VSCode

At this point, you should have installed:

  1. Julia

  2. VSCode

  3. IJulia package

Next, you need to install the Julia extension in VSCode, which will be quite useful (syntax highlighting, integrated Julia REPL, and others).

The Julia extension for Visual Studio Code includes built-in dynamic autocompletion, inline results, plot pane, integrated REPL, variable view, code navigation, and many other advanced language features.

https://code.visualstudio.com/docs/languages/julia

In Extensions search Julia and install (from julialang).

load("images/julia4.png")

Test Julia Kernel

load("images/kernel.png")

Test the code in .jl file using the REPL (in VSCode) and .ipynb in VSCode

print("Hello world")
Hello world