This repo houses the content for the Sunday afternoon Intro to Julia session of the MolSSI workshop to be hosted at CMU on October 20, 2024. Below find the agenda, with relevant notebooks linked and a summary of topics to expect in each section.
Juliaup is a convenient way (and also now the officially recommended one) to install and manage Julia versions. As with most things, the installation process depends on your operating system:
Two options: Either
-
In the command prompt, run
winget install julia -s msstore
Or, if you don't like the Windows command prompt,
-
Go to the Microsoft Store and search for Julia. Install the offering from the official Julia team.
On either platform, you can open a terminal and run
curl -fsSL https://install.julialang.org | sh
As a Mac-only alternative, if you have Homebrew installed, you can also open your terminal and run brew install juliaup
.
Visual Studio Code (VS Code) is now the recommended IDE to use with Julia. To install it:
- Go to the Visual Studio Code website and download the latest version for your operating system.
- Install VS Code by following the platform-specific instructions.
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window, or use the shortcut
Ctrl + Shift + X
(Windows/Linux) orCmd + Shift + X
(macOS). - In the Extensions search bar, type Julia.
- Find the Julia extension by Julia Language Support and click Install.
- VS Code should automatically detect the Julia installation. If not, go to the VS Code settings (
Ctrl + ,
) and set the path for Julia manually by searching for "Julia: Executable Path" and specifying the path to thejulia
binary.
- In VS Code, go to the Extensions view again.
- Search for Jupyter and install the Jupyter extension.
- Once installed, you can open Jupyter notebooks (
.ipynb
files) directly within VS Code and execute Julia code.
NOTE: We will mostly be demonstrating notebooks from within VS Code. If you prefer to run Jupyter notebooks in your browser instead of in VS Code, you can do that too. For this, you will need the IJulia to give Jupyter access to a Julia kernel.
A nice resource to be aware of in this general category is the first post of Modern Julia Workflows, which covers many similar topics: installing Julia, the REPL, IDE setup, environments, etc., as well as a few we likely won't have time to go into in much depth such as debugging tools.
- Making sure everyone completed the pre-setup and has a working environment
- Introduction to the Julia REPL and its various modes, particularly
pkg>
mode for managing environments and packages
- Variables & Types: Declaring variables (including with fun Unicode symbols!), introduction to Julia’s type system, variable scope, and immutability.
- Functions: Defining and calling functions, using multiple return values.
- Loops & Conditionals: Understanding control flow with for, while, if, and else.
- Structs: Creating custom types with struct for more complex data structures.
- Broadcasting: Efficiently applying functions across arrays and other collections.
- File I/O: Basics of reading from and writing to files.
- Why Julia?
- Overview of Julia’s key features: speed, ease of use, and suitability for scientific computing.
- Comparison with other languages like Python and MATLAB in terms of performance and syntax.
- Multiple Dispatch:
- Explanation of Julia’s unique multiple dispatch system, with examples to showcase its flexibility and performance benefits.
- Interfaces (demo, examples)
- Quick look at useful development tools provided by the package manager.
Key Packages:
- LinearAlgebra: Essential functions for matrix operations and linear algebra.
- DataFrames: Handling tabular data, similar to pandas in Python.
- Unitful: Managing physical units in calculations to avoid errors.
- Distributions: Working with statistical distributions for simulations and data analysis.
- DelimitedFiles: for handling file I/O with simple formats such as CSV
Introduction to plotting in Julia using Plots.jl, with examples of common plots and constructs like plot recipes (may be integrated into prior section).
- BenchmarkTools.jl: How to measure code performance accurately.
- Array Views & Memory Allocations: Techniques to reduce memory usage and improve performance.
- Type Stability: Understanding and ensuring type stability for faster execution.
- Basic Parallelization: Introduction to multi-threading in Julia, with simple examples to parallelize loops and tasks.
- Basic GPU Programming: Overview of high-level interfaces for GPU computing, making it accessible without deep GPU programming knowledge.
- Automatic Differentiation (AD):Brief introduction to automatic differentiation and some of its implementations in Julia
What to expect in the rest of the workshop: If time, some teasers of more advanced topics like Molecular Dynamics (using Molly) and Density Functional Theory (using DFTK).