typestar

The program shape in Zig

The smallest Zig program: one import, a public main, two prints.

// @import wires in the standard library at compile time.
const std = @import("std");

pub fn main() void {
    std.debug.print("Gull Rock light: keeper on duty\n", .{});
    std.debug.print("Visitors welcome at {s} tide\n", .{"low"});
}

How it works

  1. const std = @import("std") wires in the standard library at compile time.
  2. pub fn main() void is the entry point the start code looks for.
  3. std.debug.print takes a format string and an anonymous tuple .{} of arguments.

Keywords and builtins used here

The run, in numbers

Lines
7
Characters to type
229
Tokens
54
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 43 seconds.

Type this snippet

Step 1 of 3 in Values, step 1 of 27 in Language basics.

Next →

The program shape in other languages