Abstraction Is Just Topological Sort for Reality

Kai Nguyen

Hatched by Kai Nguyen

Jul 13, 2026

9 min read

92%

0

What if the hard part of computing is not building, but ordering?

Most people think software is about objects, screens, databases, or even algorithms. But at a deeper level, computing is often about something less glamorous and more fundamental: making the world behave like a sequence of safe operations. That is why two ideas that look unrelated at first, abstraction and topological sort, actually point toward the same hidden problem.

Abstraction says: treat many different things as if they share one interface. Topological sort says: when things depend on one another, arrange them in a linear order that respects those dependencies. Put those together and you get a powerful lens on computing, and on life itself: the art of working with complexity is the art of turning a messy web into something you can safely do next.

That is the real question underneath both ideas. How do you act when everything is connected, but not everything can happen at once? How do you simplify without lying? How do you move from a tangled system to a sequence of correct decisions?


The file system lesson: everything is a file, because everything needs a stable interface

The Unix idea that everything is a file sounds almost absurd until you see what it buys you. A keyboard, a document, a network socket, a device, a process output stream, each becomes something you can read from or write to. Not because they are literally the same thing, but because they can be handled through a shared contract.

That shared contract is the real breakthrough. Once you can say, “I know how to read this,” you no longer need to care whether the bytes came from disk, from a terminal, or from a remote machine. The system becomes composable. Tools can be chained. Small programs can cooperate. Complexity does not disappear, but it becomes manageable through a narrow waist of abstraction.

This is why abstraction is not just a convenience. It is a strategy for survival in complex environments. Without it, every component would need intimate knowledge of every other component. With it, each piece can specialize while still fitting into a larger machine.

A good abstraction does two things at once:

  1. It hides irrelevant detail.
  2. It preserves the dependencies that still matter.

That second part is easy to miss. Abstraction is not erasure. It is selective visibility. If you hide too much, the system becomes fragile because hidden dependencies explode later. If you hide too little, the system becomes impossible to think about. Good abstractions are like well designed file interfaces: they give you just enough power to do the next operation correctly.

Abstraction is not the elimination of structure. It is the preservation of essential structure in a simpler form.

That is exactly where topological sort enters the picture.


Why dependency order is the hidden shape of every complex system

A topological sort finds a linear ordering of elements that have dependencies on one another. It turns a partial ordering into a usable sequence. Some nodes have no incoming edge, so they can begin the process. Others have only incoming edges, so they must wait until their prerequisites are complete.

This sounds like a graph algorithm, but it is really a philosophy of action. Any time you have dependencies, you are dealing with a partial order. Some things can happen in parallel, some cannot. Some tasks are sources, some are sinks, and many are somewhere in between.

Think of building a house. You cannot install windows before the walls exist. You cannot paint the walls before the drywall is up. You cannot lay the foundation after the roof. The project is not merely a list of tasks. It is a dependency graph. The builder’s job is to discover an order that respects reality.

The same thing happens in software development. You cannot use a function before you define it, unless you create an abstraction that allows the use to proceed without knowing the implementation. You cannot deploy a service before its database schema exists. You cannot test a feature in isolation if its prerequisite mock contracts are undefined. Even a simple startup sequence, load config, connect to database, initialize cache, start server, is a topological problem disguised as an engineering checklist.

The key insight is this: complexity is often not about quantity, but about dependency. Ten independent tasks are easy. Three tasks with circular dependencies can stall an entire organization.

The moment you see a dependency graph, you stop asking, “What comes first?” and start asking, “What must be true before anything else can be true?”

That shift matters because it changes the unit of reasoning. Instead of thinking in terms of objects or steps, you think in terms of prerequisites, interfaces, and allowable transformations.


Abstraction and topological sort are the same mental move

At first glance, abstraction and topological sorting seem unrelated. One is a design principle, the other is an algorithm. But both solve the same problem from different angles: how to make a complex system tractable without breaking its internal logic.

Abstraction collapses complexity horizontally. It says, “Many different details can be treated as one category because, for this purpose, they behave the same.” Topological sort collapses complexity vertically. It says, “Many dependencies can be arranged into a sequence because some requirements necessarily precede others.”

In other words:

  • Abstraction reduces what you need to know.
  • Topological order reduces when you need to know it.

That distinction is profound.

Suppose you are designing a word processing system. At one level, the screen, the keyboard, and the disk are all files, because they can be handled through a common interface. At another level, the rendering engine depends on the document model, which depends on the parser, which depends on the raw text, which depends on input. You can abstract each layer, but the layers still have a correct order.

This is the secret behind robust systems architecture. Good systems do not merely hide complexity. They organize complexity into layers where each layer has a stable contract and a valid dependency direction.

If that direction becomes cyclic, the system begins to rot. A parser that depends on the renderer, which depends on the parser, creates a circular dependency. A business team that waits on legal, legal waits on product, product waits on engineering, and engineering waits on business has created an organizational cycle. A circular dependency is not just inconvenient. It is a structural dead end.

A topological sort is impossible in a graph with a cycle. That is not just a graph theory fact. It is a diagnostic tool. It tells you when your system has asked for the impossible: to do everything first, while also needing everything else first.

This is where abstraction becomes more than a convenience. It becomes a way to break cycles. A clean interface allows one layer to proceed without knowing the internals of the next. That is how sources and sinks become manageable. A source can act because it has no unmet prerequisites. A sink can receive because it does not need to output further obligations downstream. Well designed abstractions create more sources and fewer hidden cycles.


The real test of design: can your system be ordered?

One of the most useful questions you can ask about any process, codebase, or team is this: Can it be topologically ordered?

Not literally, always. But conceptually. Can you identify the prerequisites for each step? Can you separate what is truly sequential from what is merely habitually sequential? Can you make independent work independent enough to run in parallel? Can you expose the sources clearly and keep the sinks from swallowing the whole pipeline?

A system that cannot be ordered is often a system that has hidden coupling. For example:

  • A class that knows too much about every other class has lost abstraction.
  • A deployment process that requires manual tribal knowledge has hidden dependencies.
  • A team whose decisions keep bouncing between people with no final owner has created a cycle.
  • A project that cannot begin until every detail is decided is over coupled to uncertainty.

Now consider the opposite. A well ordered system does not necessarily make things easy, but it makes them legible. You can see what must happen first. You can see what can happen simultaneously. You can see where the bottlenecks are. You can see the sources of value and the sinks of complexity.

This is why strong abstractions are so powerful in engineering. They do not just make code prettier. They make dependency order visible. A file interface, an API boundary, a module contract, each reveals where you can safely connect and where you must wait.

Here is a useful mental model:

Abstraction is the map. Topological order is the route.

The map tells you what categories exist. The route tells you how to move through them without violating constraints. Without a map, you cannot understand the terrain. Without a route, you cannot traverse it.

That is why mature systems, and mature thinkers, constantly ask two questions:

  1. What can be treated as the same thing?
  2. What must happen before something else can work?

The first question creates simplicity. The second creates correctness.


Key Takeaways

  1. Look for dependencies before looking for steps. When a process feels confusing, draw the dependency graph first. Many problems become obvious once you see what depends on what.

  2. Use abstraction to hide detail, not structure. A good interface removes noise while preserving the order that reality demands.

  3. Treat cycles as design warnings. If two parts keep needing each other before either can move forward, you do not have a coordination problem. You have a structural problem.

  4. Separate what must be sequential from what merely feels sequential. Many workflows are slower than they need to be because people have not identified the sources that can start immediately.

  5. Ask whether your system can be topologically ordered. If it can, you probably understand it. If it cannot, there is likely hidden coupling, unclear ownership, or a missing abstraction.


A deeper way to think about building things

We often talk about abstraction as a way to simplify and topological sort as a way to schedule. But the deeper connection is that both are answers to the same human limitation: we cannot hold every detail of a complex world in our heads at once.

So we invent layers. We invent interfaces. We invent sequences. We make the world processable.

The most elegant systems are not the ones with the fewest parts. They are the ones where the parts are arranged so well that the whole becomes thinkable. That is what “everything is a file” gestures toward. It is not just a technical trick, it is a promise that wildly different things can still be governed by a common grammar. And topological sort reminds us that a common grammar is not enough. The grammar must also respect order.

The best design, then, is not merely abstraction or merely sequencing. It is abstraction with dependency awareness. A system that exposes the right interface and also the right order. A mind that sees both sameness and precedence. A team that knows what can be parallelized and what must be waiting at the source.

To make complexity usable, you must do two things at once: compress what is similar and respect what is prerequisite.

That is a surprisingly broad principle. It explains good software, good architecture, good project planning, and even good thinking. If you can learn to see the world this way, you stop asking only how to build faster, and start asking how to build in the only order that reality will allow.

And that may be the most important abstraction of all: not that everything is a file, but that every system has an interface, and every interface has an order. Learn to see both, and complexity stops being a wall. It becomes a path.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣