This repository contains material for the AAS 241 workshop "An Introduction to the Julia Programming Language"
Date: Saturday, 7 January, 9:00 am - 5:00 pm (In-person)
Note: Registration for this in-person event has already closed.
The Julia programming language can be considered the successor to Scientific Python (SciPy). The language is designed for scientific computing by having built-in multidimensional arrays and parallel processing features. Yet, it can also be used as a general-purpose programming language like Python. Unlike Python, Julia solves the two-language problem by using just-in-time (JIT) compilation to generate machine code from high level expressions. In most cases, Julia is as fast as C, and in some cases faster. Julia is also a composable language, so independent libraries or packages usually work well together without any modification. These important features make Julia a very productive language for scientific software development by reducing the number of lines of code.
The objectives of this tutorial are: (1) to introduce astronomers and software developers to the basic language syntax, features, and power of the Julia programming language, (2) to compare and contrast Julia’s design features to those of C/C++ and Python, and (3) to show that Julia provides an easy migration path from languages such as C/C++, FORTRAN, and Python. In other words, it is not necessary to rewrite all of your code all at once.
The tutorial will begin with simple interactive command-line (REPL) examples that emphasize important concepts and features of the language; namely, unicode characters, multidimensional arrays, data types or structures, functions, multiple dispatch, and namespaces. It will then combine these basic concepts to demonstrate some important features of the language; namely, composability, the two-language problem and benchmarking, the standard library, plotting, interfacing to other languages, symbolic manipulation, package management, and parallel processing and GPUs.
We will be using Julia and Pluto notebooks. Please follow these installation instructions before the start of the workshop. If you run into to difficulties, please feel free to contact the organizers or let us know at the start of the workshop.
Note: Pluto notebooks are not compatible with Jupyter.
Please install the latest stable version of Julia (1.8.4 as of December, 2022) on you computer. Make sure to use the links on the official Julia website linked above, rather than any 3rd party package manager (e.g. homebrew, apt, nuget, etc.).
For more advanced users, JuliaUp can be used to install, update, and switch between versions of Julia.
MacOS Instructions
If you have a new mac with an M1 processor, make sure to select the "M-series Processor" link for improved performance.Windows Instructions
This Microsoft Store link can also be used to install JuliaUp.We strongly recomend you use the Windows Terminal included in Windows 11 or downloadable from this Microsoft Store link. Windows Terminal has improved font and math symbol rendering compared to the antiquated cmd.exe
.
Linux Instructions
After downloading the correct version of Julia for your operating system, expand the archive (e.g.tar -xvf julia-xyz.tar.gz
) and place the binary julia-xyz/bin/julia
in your PATH
.
The versions of Julia included in OS package managers (yum, apt, pacman, etc) frequently have bugs not seen in the offical binaries and should be avoided. For more information, see here.
Docker
Julia runs in lightweight, self-contained environments. It is therefore not usually necessary to install Julia within Docker for the sake of reproducibility.Once you have installed Julia, run the following command in your terminal to install Pluto:
julia -e 'using Pkg; Pkg.add("Pluto")'
Set the desired number of threads Julia should run with using an environment variable:
Windows:
SET JULIA_NUM_THREADS=auto
Mac & Linux:
export JULIA_NUM_THREADS=auto
Then, in the same terminal, start Julia by running:
julia
To start Pluto, run the following from inside Julia:
julia> using Pluto
julia> Pluto.run()
In one section, we will demonstrate how you can use Python libraries inside Julia. You do not have to have a Python installed in advance.
The material for each section is stored as a Pluto notebook.
Copy the link for a given section below and paste it into the "Open a Notebook" box in Pluto.
The morning content is a single notebook, while the afternoon is split into multiple topics.
Topic | Link |
---|---|
1. Introducing Julia | https://github.com/sefffal/AASJuliaWorkshop/raw/main/1-intro-to-julia.jl |
2. Calling Python | https://github.com/sefffal/AASJuliaWorkshop/raw/main/2-calling-python.jl |
3. Using Macros | http://github.com/sefffal/AASJuliaWorkshop/raw/main/3-using-macros.jl |
4. Astronomy Packages | https://github.com/sefffal/AASJuliaWorkshop/raw/main/4-astro-packages.jl |
5. Optimizing Code | https://github.com/sefffal/AASJuliaWorkshop/raw/main/5-optimization.jl |
6. Parallel Computing | https://github.com/sefffal/AASJuliaWorkshop/raw/main/6-parallel_computing.jl |
7. Creating Packages | https://github.com/sefffal/AASJuliaWorkshop/raw/main/7-creating-packages.jl |
8. Questions and Special Topics |