Semantic Compression

Revision as of 12:11, 25 November 2026 by Cadrgtsecond (talk | contribs) (Created page with "Semantic compression is an approach to designing abstractions. Traditionally, techniques like Object Oriented Programming focus on designing the structure of a program first, and then filling in the implementation. Most of the focus is on abstract notions of concern, intent, expression etc. Semantic Compression is based on a different approach # Solve the problem in the stupidest and simplest way possible. ctrl-C ctrl-V is your friend. # Then, look through the code...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Semantic compression is an approach to designing abstractions.

Traditionally, techniques like Object Oriented Programming focus on designing the structure of a program first, and then filling in the implementation. Most of the focus is on abstract notions of concern, intent, expression etc.

Semantic Compression is based on a different approach

  1. Solve the problem in the stupidest and simplest way possible. ctrl-C ctrl-V is your friend.
  2. Then, look through the code and identify which portions actually repeat, and pull those out.

A few caveats

  • There is often more than one way to pull out Code Duplication, see Programming Patterns. It is preferable to use weaker more constrained techniques such as Boolean Flags instead of more powerful techniques like VTables. This leads to the simplest abstraction that can get the job done.
  • It is not necessary that the entire process happens in one session, or is even done by one person. It's possible that one person does the first step, leaves the code alone for several months(because nothing needs to be changed or worked on), and later on, someone comes along and performs step 2.

One very nice property of semantic compression is that the abstractions derived from it end up being very practical, without the need for Cat and Dog examples.

Semantic Compression was coined in the following blog post by Casey Muratori. As mentioned above, Casey demonstrates his idea with a practical example, the Witness debug UI

The following blogs are also useful material. They continue the work on the debug UI system.