liveBook · Manning

Composability

As explained in Systems Programming with Zig

Composability is the property of software parts being combineable into larger systems through well-defined interactions.

Composability lets simple, interchangeable software parts combine through well-defined interactions. In Zig, this is presented as a key to scaling beyond a small set of core tools. section 2.1.5

Zig build steps show how composability turns small tasks into a useful workflow:

  • A step can compile code, run a command, or format source files. section 6.3.1
  • Steps can depend on earlier steps: compile tests, run them, then connect the runner to a `test` command. section 6.3.1
Listing 6.3 Making new steps
pub fn build(b: *std.Build) void {
    // ... module code ...

    const tests = b.addTest(.{ #1
        .root_module = test_mod,
    });
    const run_tests = b.addRunArtifact(tests); #2

    const test_cmd = b.step("test", "Run the vm tests"); #3
    test_cmd.dependOn(&run_tests.step); #4
}

The build script connects test compilation and execution to a single command. section 6.3.1

How Systems Programming with Zig covers it

How deep it goes
Defines composability through interchangeable parts and shows dependent build steps, while explicitly leaving the build-system treatment shallow.
Examples
Uses test compilation and execution chained behind a single command as a concrete example.
What you can do after
Operate/configure Zig's build system by chaining test compilation and execution behind a `test` command.
How it connects
Connects modularity, Zig build steps, modules, and test execution.

Also explained in

Compare how 5 books explain composability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Systems Programming with Zig. The section links point to the parts of the book it draws on.