../

Zig

const std = @import("std");

pub fn main() void {
    std.debug.print("Hello, {s}!\n", .{"World"});
}

This is a hello, world program in zig.

Initial reactions

  • The import is being assigned to a constant.
    • import take an arg and finds that file and the items with pub are exported in the LHS
    • The LHS is just a struct
  • It has . notation for functions
  • There is curios pub keyword
  • function is defined using fn
  • The type is given after the function
  • The second arg for print has this ugly .{} notation
    • This is an anonymous struct notation
    • print always takes a struct as it second arg.
    • std.debug.print("Hello, {s}!\n", "World"); won’t work
    • It has this comptime type that is assigned to constants