← All posts
Case studyFeb 22, 2026 · 5 min

Topological sort and the secret life of build systems

Make, Bazel, npm, Cargo — they all rely on the same algorithm you learned in week 4 of your DSA course.

Every modern build tool is, at its core, a graph executor. Files and tasks are nodes; 'depends on' relationships are edges. To compile in the right order, the tool runs a topological sort and walks the resulting list.

The interesting parts come when you add parallelism, caching, and incremental rebuilds — but they all assume the topo sort gives you a valid order to start from.