Zig by Example: Hello World

To kick things off, let’s print the classic “Hello, World!” message.

const std = @import("std");
pub fn main() anyerror!void {
    std.debug.print("Hello, World!\n", .{});

To run this Zig program, use zig run.

$ zig run hello-world.zig
Hello, World!

To compile this Zig program, use zig build-exe.

$ zig build-exe hello-world.zig
$ ./hello-world
Hello, World!

Next example: Assignment.