ON AIRTerminal of Tinsel

Night 1 · Light the Tree

📺 "Good evening, and welcome to the first night of Night School. I'm Auntie Aerial, and behind door number one there is nothing at all: an empty folder and a terminal. By bedtime it will hold a program that says one line. Every tree starts with a single light, and somebody has to find the plug."

Tonight you'll learn

Where we are: an empty folder.

Why Rust for a terminal program?

Rust compiles to a single program file with no runtime to install beside it. You build terminal-of-tinsel, give the file to a friend with the same kind of computer, and it runs. It starts in milliseconds, which matters for something you run forty times an evening.

Rust is also strict. The compiler checks things most languages leave until the program is running: that every value has one clear owner, that nothing is used after it's gone, that every error has somewhere to go. The first few nights that strictness will feel like being marked by a teacher with a very fine pen. By the second week you'll find that when the program compiles, it usually works.

Over 24 nights we build Terminal of Tinsel: a program about the creatures of Christmas folklore, presented by a television host. For the first ten nights you type every line. From Night 11 the program is too big for that, so the lessons quote the finished code in this repository.

Install Rust

You install Rust with rustup, a small tool that fetches the compiler and keeps it up to date. On macOS or Linux:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

On Windows, download and run rustup-init.exe from rustup.rs. It will ask to install Microsoft's C++ build tools if you don't have them. Say yes, because Rust uses their linker.

Then open a new terminal and check:

rustc --version
cargo --version

You need Rust 1.88 or newer. If you already had Rust and it's older, rustup update brings it up to date.

You've installed three things worth knowing by name:

A place for the creatures

In the folder where you keep your projects, run:

cargo new terminal-of-tinsel
cd terminal-of-tinsel

Use this exact name, so that the commands and paths in the lessons match yours. cargo new makes a folder with four things in it:

Open Cargo.toml:

[package]
name = "terminal-of-tinsel"
version = "0.1.0"
edition = "2024"

[dependencies]

Rust calls a project like this a package, and the thing it compiles a crate. The name is what the program file will be called. The version starts at 0.1.0, and on Night 2 the program will learn to print it.

The edition is which dialect of Rust the code is written in. Every few years the language makes changes that would break old code, such as new keywords, and bundles them into an edition: 2015, 2018, 2021 and 2024. Your code opts in by naming one, and old code keeps compiling under its old edition. We use 2024, the newest.

[dependencies] is where libraries will be listed. It's empty tonight.

The first program

cargo new wrote a program for you that prints "Hello, world!". Open src/main.rs and change it to this:

fn main() {
    println!("🎄 The tree is lit.");
}

Three things to know:

A string in Rust is always UTF-8, so the tree emoji needs no special handling. If your terminal shows a box instead of a tree, its font has no emoji, and the program is still correct.

Run it:

cargo run
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/terminal-of-tinsel`
🎄 The tree is lit.

cargo run compiles the program if anything has changed, then runs it. The first two lines are Cargo talking, and the last is your program. (The path and the time will be your own.) Add -q, for quiet, and Cargo keeps its remarks to itself:

cargo run -q
🎄 The tree is lit.

Where the program went

cargo run left the compiled program on disk, in the target folder:

./target/debug/terminal-of-tinsel

On Windows it's .\target\debug\terminal-of-tinsel.exe.

This is a debug build, which is quick to compile, slow to run and full of information for debuggers. cargo build makes the same file without running it. When you want the one you'd give to somebody, ask for a release build:

cargo build --release
./target/release/terminal-of-tinsel

The release build takes longer to compile because the compiler spends the time optimising. On Linux tonight's debug program is about four megabytes and the release one about 450 kilobytes, though yours will differ. Either file is the whole program, and nothing else needs installing to run it.

The target folder is disposable. Delete it (or run cargo clean) and the next build makes it again. That's why .gitignore lists it.

You'll also find a new file beside Cargo.toml called Cargo.lock. It records the exact version of every library the build used, so that the next build, on any machine, uses the same ones. It's short tonight, because there are no libraries yet. For a program, commit it.

Save your work

cargo new already made the repository, so:

git add .
git commit -m "feat: light the tree"

The commit message follows a convention called Conventional Commits: a type (feat, fix, docs, test, chore), a colon and a short description. On Night 24 a tool will turn these messages into a changelog, so it pays to start now.

Try it

🎄 Festive fact

Editions are a promise as well as a setting. A crate written in the 2015 edition and a crate written in the 2024 edition can be used in the same program, because the edition only changes how each crate's own source is read, and every edition compiles to the same thing underneath. The 2024 edition arrived with Rust 1.85 in February 2025, and code from 2015 still compiles with today's compiler.

🕯️ Before morning

Make the program print a three-line title card:

==========================
    TERMINAL OF TINSEL
==========================

Hint: "=".repeat(26) makes the rule, and you can print it with println!("{}", "=".repeat(26));. Do it twice without typing it twice: put the rule in a variable with let rule = "=".repeat(26); and print {rule}, with the name inside the braces.

📺 "One light, and it's on. Tomorrow night we give the programme a running order, because a show that only does one thing is an advert. Sleep well."

Index · Night 2 →