Getting Started with Julia

Introduction

This course uses Julia as the primary programming language for assignments and projects. Julia is a high-level, high-performance programming language for technical computing. Julia is designed for numerical and scientific computing, and it is fast, flexible, and expressive.

This short guide will help you get set up with Julia and start writing and running your first programs.


1. Installing Julia

1.2 Direct Installation

Alternatively, you can install Julia directly from the official Julia website. Download the appropriate installer for your operating system, follow the installation prompts, and then run the julia executable.


2. Using Julia in VS Code

Visual Studio Code is a popular editor for Julia:

  1. Install VS Code from the official website.
  2. Add the Julia extension:
    • Open VS Code, go to the Extensions tab (left-hand side), and search for “Julia”.
    • Install the Julia extension.
  3. Configure Julia Path (if needed):
    • Press Ctrl + Shift + P (or Cmd + Shift + P on macOS) and type “Julia: Select Julia executable path”.
    • Select the path to your Julia installation.

You can now open a .jl file, and VS Code will automatically provide syntax highlighting, inline execution, debugging features, and more!


3. Running Julia in a Jupyter Notebook

Jupyter notebooks allow you to mix code, results, and explanations in one place:

  1. Install Jupyter (if you have Python/Anaconda):

    pip install jupyter
  2. Add the IJulia package in Julia:

    using Pkg
    Pkg.add("IJulia")
  3. Launch Jupyter from your shell/command prompt:

    jupyter notebook
  4. Create a new Julia notebook from the Jupyter interface.

You can now write and run Julia code in Jupyter cells!


4. Experimenting with Pluto

Pluto.jl is a reactive notebook environment for Julia:

  1. Install Pluto:

    using Pkg
    Pkg.add("Pluto")
  2. Start Pluto:

    using Pluto
    Pluto.run()
  3. Follow the link that appears in the Julia REPL to open a new Pluto notebook in your browser.

Pluto notebooks reactively update outputs whenever you modify a cell, making it easy to experiment and visualize results quickly.

5. Report Writing Tools

These tools can help you write reports and documents in Julia. Once setup, they are easy to use and can generate beautiful documents:


Final Tips

  • Julia REPL: Press ? at the Julia REPL for help on any function (e.g., ?println).

  • Package Manager: Press ] in the REPL to enter package mode. For example:

    ] add LinearAlgebra
    ] status
  • Official Documentation: Visit docs.julialang.org for the complete Julia manual, tutorials, and more.

  • Discourse Forum: The Julia Discourse forum is a great place to ask questions and learn from the community.

Enjoy exploring Julia for computational optimization! If you have any questions, please reach out on our class forum.