Caching: Abstraction, Not Optimization

2025-07-04
Caching: Abstraction, Not Optimization

The conventional wisdom is that caching speeds up software. The author argues this is only part of the story. After working with data movement between object storage, disk, and memory, the author posits that caching's more crucial role is simplifying software. The article explores the limitations of pre-baked caching algorithms (LRU, LFU, etc.) and suggests caching acts more as an abstraction layer, hiding the underlying storage details, freeing programmers from worrying about data tier location. Database and OS caching mechanisms exemplify this abstraction. While caching can have issues, like OS page cache and fsync misuse, this doesn't necessitate abandoning caching but rather understanding and using it better.

Read more
Development

The Loneliness Epidemic: A Call to Leave the House

2025-06-29
The Loneliness Epidemic: A Call to Leave the House

This article tackles the pervasive issue of loneliness in modern society, arguing that leaving the house is key to combating it. The author uses their experience with a dog and community engagement at a dog park as a prime example of building connections. They highlight the importance of urban infrastructure, like sidewalks, in fostering community. The piece criticizes late-stage capitalism for profiting from and exacerbating loneliness, urging readers to actively participate in community life and experience human connection.

Read more
Misc

Solving LinkedIn Queens with SMT: Easier Than SAT!

2025-06-12
Solving LinkedIn Queens with SMT: Easier Than SAT!

This post details solving the 'LinkedIn Queens' puzzle—a variation of the classic N-Queens problem with added regional constraints—using the SMT solver Z3. The author demonstrates that expressing the problem in SMT, leveraging integer variables and constraints, is significantly simpler than the equivalent SAT formulation which requires many boolean clauses. While SMT solvers might be slower than highly optimized SAT solvers like Glucose, the ease of encoding makes SMT preferable for many. The post includes complete code and helpful sanity checks to verify the model's correctness. This provides a compelling explanation for the industry's preference for tools that compile to SAT rather than using SAT directly.

Read more
Development SMT solver

Undecidability: The Programmer's Pandora's Box

2025-05-28
Undecidability: The Programmer's Pandora's Box

This article provides a clear explanation of the concept of "undecidability" in computer science. Using accessible language and concrete examples (like determining if a number is the sum of two primes), the author explains decision problems and the role of Turing machines. The key takeaway is that undecidability doesn't mean it's impossible to tell if a program will halt, but rather that there's no universal algorithm to determine the halting behavior of all programs. This makes many problems (such as verifying program properties) require significant effort and may be unsolvable, highlighting the necessity of fields like formal verification and program analysis.

Read more
Development

Property-Based Testing: Why it Trumps Unit Testing for Complex Inputs

2025-05-21
Property-Based Testing: Why it Trumps Unit Testing for Complex Inputs

This article debates the merits of property-based testing (PBT) versus traditional unit testing. The author argues that while unit tests suffice for functions with single inputs, the combinatorial explosion of edge cases in multi-input functions makes PBT, with its randomized input generation, superior at uncovering hidden boundary errors. However, PBT has a learning curve; mastering complex input generation strategies is crucial. Most PBT examples are too simplistic to showcase its true power in handling complex input spaces.

Read more

The USPS's E-Mail Gamble: The Rise and Fall of E-COM

2025-05-14
The USPS's E-Mail Gamble: The Rise and Fall of E-COM

Facing the threat of email, the US Postal Service launched E-COM in 1982, a service that printed emails and delivered them via mail carriers. Initially successful, E-COM ultimately failed in 1985 due to high costs, cumbersome processes, and lack of flexibility, resulting in over $40 million in losses. However, E-COM inadvertently popularized the term "email" and highlighted the USPS's attempts to adapt to technological change.

Read more
Tech

America's Food Safety: A Battle Against Lies and History

2025-04-30
America's Food Safety: A Battle Against Lies and History

This article interviews science journalist Deborah Blum, exploring the current state and history of food safety in the US. Blum points out that amidst rampant misinformation and government deregulation, American citizens face food safety risks, with issues similar to 19th-century food adulteration resurfacing. She uses her book, "The Poison Squad," to illustrate the birth of the 1906 Pure Food and Drug Act and how chemist Harvey Wiley exposed food safety problems through a 'poison squad' experiment. Blum calls for public attention to food safety and criticizes the individualistic approach that blames consumers for foodborne illnesses, emphasizing the government's responsibility to guarantee basic rights.

Read more

Requirements Change Until They Don't: Formal Methods and System Evolution

2025-04-28
Requirements Change Until They Don't: Formal Methods and System Evolution

This article explores how to handle constantly changing requirements in software development. While extensive upfront formal modeling might be impractical with frequent changes, the author argues that formal methods become crucial when systems reach scale or undergo architectural shifts (phase transitions). Formal specification and verification ensure that improvements don't break existing functionality. Using the example of switching from synchronous to asynchronous updates, the author demonstrates how formal methods can verify that a new system satisfies old requirements, highlighting the importance of software maintenance and preventing the silent failure of features.

Read more
Development requirements change

Solving Blue Prince's Propositional Parlor Puzzle with Logic

2025-04-21
Solving Blue Prince's Propositional Parlor Puzzle with Logic

This article details how to automatically solve a logic puzzle from the game Blue Prince using propositional logic. The puzzle involves three boxes (blue, white, black) each making statements, and rules stating at least one box is entirely true, at least one is entirely false, and the prize is in exactly one box. The author models the problem in propositional logic, uses a brute-force approach to find all satisfying assignments, and thus determines the prize's location. The article includes a JavaScript implementation and discusses code optimization.

Read more

Google's AMP for Email: A Bold Failure

2025-04-18
Google's AMP for Email: A Bold Failure

Google attempted to revolutionize email with AMP (Accelerated Mobile Pages), enabling interactive experiences like booking hotels or replying to Google Docs comments directly within emails. However, this initiative ultimately failed. The article analyzes the reasons behind AMP for Email's failure, including high development complexity, poor compatibility, and conflicts with email's inherent properties. Developer distrust of Google's push contributed significantly to its demise. While interactive emails aren't impossible, they should prioritize compatibility and permanence, not at the expense of simplicity and reliability. Email's enduring success hinges on its simplicity and decentralization.

Read more
Tech

Beyond NP: A More Intuitive Complexity Problem

2025-04-17
Beyond NP: A More Intuitive Complexity Problem

The author challenges the use of the Halting Problem as the canonical example of a problem harder than NP-complete, arguing it's confusing and unintuitive. While undecidable, verifying a "yes" answer for the Halting Problem can be done by running the program for a finite number of steps. A more easily understandable alternative is presented: moving a token on an infinite grid to reach a target point. This problem is PSPACE-complete in lower dimensions, but its complexity explodes with increasing dimensions, eventually reaching ACKERMANN-completeness, visually demonstrating a complexity far beyond NP problems.

Read more

Solving a Layton Puzzle Elegantly with Prolog

2025-04-08
Solving a Layton Puzzle Elegantly with Prolog

The author rewrote the chapter on logic programming languages in their book "Logic for Programmers", showcasing Prolog's power with a 'Layton-style' puzzle. The puzzle involves deducing the fourth student's score based on the scores of the first three. Using concise Prolog code (just 15 lines!), the author elegantly solves the problem, leveraging Prolog's pattern matching and bidirectionality to find all possible answer keys, ultimately determining the fourth student's score as 6. A comparison is made to a longer, less efficient solution. While the author argues against using puzzles for teaching, this example demonstrates Prolog's practical application potential.

Read more
Development Puzzle Solving

It's Time to Stop Building KV Databases

2025-03-25
It's Time to Stop Building KV Databases

The author argues that Key-Value databases are overly simplistic and lack expressive power, making them painful to use. While popular among storage engine vendors, KV databases are merely building blocks for reasonable data models, forcing users to build these models from scratch, often with suboptimal results. The author proposes a middle ground: an embedded database with typed records, separating logical and physical schemas but writing queries against the physical schema. This avoids complex query planners, supports asynchronous schema changes and layout switching. This approach balances data independence with the simplicity needed for embedded systems, offering a compelling alternative to both simple KV stores and the complexities of full-blown relational databases.

Read more
Development

Verification-First Development: Beyond Test-Driven Development

2025-03-18
Verification-First Development: Beyond Test-Driven Development

This article explores Verification-First Development (VFD), a paradigm that emphasizes establishing verification mechanisms before writing code. This could involve writing tests, defining type invariants, adding contracts, or other methods. VFD differs from Test-Driven Development (TDD), which is a specific case of VFD and focuses on using tests to drive code design. VFD's advantages include reducing the likelihood of skipping verification, early error detection, and improved code quality. However, VFD also has drawbacks: it can slow development, hinder exploratory coding, and verification methods might influence code design. The author argues that VFD, as a technique rather than a paradigm, is more flexible and easily integrates with other approaches.

Read more

Five Types of Nondeterminism: Practical Insights from Formal Methods

2025-02-20
Five Types of Nondeterminism: Practical Insights from Formal Methods

This article explores five types of nondeterminism in system modeling: true randomness, concurrency, user input, external forces, and abstraction. The author explains each type clearly with practical examples. True randomness, while often simulated with pseudorandom number generators, is usually treated as nondeterministic choice in modeling. Concurrency is a major source of nondeterminism, requiring special handling due to state space explosion. User input and external forces are treated as nondeterministic external influences. Critically, abstraction simplifies complex deterministic processes into nondeterministic choices, simplifying models and increasing sensitivity to potential errors. This provides valuable insights into understanding nondeterminism and its applications in software development.

Read more

Efficiency vs. Horizontal Scalability: A Necessary Trade-off?

2025-02-12
Efficiency vs. Horizontal Scalability: A Necessary Trade-off?

This article explores the tension between software efficiency and horizontal scalability. The author argues that software optimized for scalability often performs poorly in single-machine environments, and vice versa. This stems from Amdahl's Law, coordination overhead, and limitations on shared resources. Efficient algorithms often rely on assumptions about the system and problem that may no longer hold true when scaling horizontally. The author also discusses cultural factors and task types influencing choices, illustrating with examples like the Tigerbeetle database and CPython's GIL. Ultimately, a deep understanding of the problem and environment is key to achieving both high efficiency and scalability.

Read more
Development

The Curious History of Regex Anchors: Why `$` and `^`?

2025-01-21
The Curious History of Regex Anchors: Why `$` and `^`?

This post delves into the historical origins of using `$` and `^` as line anchors in regular expressions. Tracing back to the QED text editor, `$` initially represented the end of the buffer, later adapted by Ken Thompson to signify the end of a line in regexes. The choice of `^` likely stemmed from the limited character set of the Teletype Model 35 typewriter, with `^` already present in ASCII-67. This wasn't a brilliant design choice but rather a consequence of hardware and character set limitations of that era, becoming a convention in regexes.

Read more
Development regular expressions

Mathematical Modeling Reveals Just How Bad the Dreidel Game Is

2024-12-18
Mathematical Modeling Reveals Just How Bad the Dreidel Game Is

Last year, the author used the PRISM probabilistic modeling language to model the traditional holiday game Dreidel, proving its lack of fun. This year, he refined the model to simulate the entire game until its conclusion. The new model corrects the previous flaw of only simulating the elimination of the first player and improves the calculation logic for betting and player elimination. Through model simulation, the author found that, on average, a four-player game takes 760 spins to end, and the longest can even exceed 6 hours. This fully proves that the Dreidel game is long, tedious, and frustrating.

Read more