Pavlov for the Web

One of the aims of pavlov is to give developers and LLMs a model-check-driven development workflow that is superior to both traditional TDD and REPL-driven development. When using pavlov, you should be able to use a model to guarantee that your application does nothing you do not want it to do, and everything you do want it to do. This is straightforward to do with an application that runs on a single system. Model checking comes for free with the behavioral programming paradigm. ...

2026-04-17 · 4 min · 698 words · Thomas Cothran

Avoid with-redefs in tests

Advice to avoid with-redefs often focuses on the wrong things. It is true that with-redefs can cause race conditions in your test suite. And that functions can be captured in closures, leading to them not being redefined as one might expect. And that with-redefs doesn’t redefine inlined functions. And that with-redefs can cause problems with type-hinted functions. And that they cause problems when used with macros. And that mutating the global environment is something functional programmers should know is a bad practice. Etc., etc. ...

2025-04-07 · 3 min · 591 words · Thomas Cothran

What do I want from a codebase?

Carson Gross’ “Codin’ Dirty” essay is designed to provoke controversy. Although I will critique the essay, I want to make it clear that I am (on this Thanksgiving eve) grateful for Carson Gross’s work. Gross writes: I’m … not trying to convince you to code dirty with this essay. Rather, I want to show that it is possible to write reasonably successful software this way and, I hope, offer some balance around software methodology discussions. ...

2024-11-27 · 9 min · 1728 words · Thomas Cothran

Bthreads: A Simple and Easy Paradigm for Clojure

Asynchronous programs are hard to reason about. But is this intrinsic to asynchrony? Or might we be using the wrong paradigms? Behavioral programming is a programming paradigm that aims to make asynchronous, event-driven systems both simple and easy by using a system centered on behavioral threads (bthreads). In my previous article, I introduced the idea of behavioral programming in Clojure. In this article, we dive deeper. I hope to convince you that, compared to the alternatives: ...

2024-10-30 · 9 min · 1723 words · Thomas Cothran

Behavioral Programming in Clojure

Behavioral Programming is a relatively new programming paradigm that excels at isolating and composing behaviors in event driven system. It is unrelated to behavior driven development. Behavioral programming was invented by David Harel, who also invented statecharts in 1987. It uses independent units of behavior, called bthreads, which are coordinated in a pub-sub protocol. How does it work? A behavioral program will first collect the bids from all of its bthreads. A bid can do three things: ...

2024-09-24 · 5 min · 913 words · Thomas Cothran

The Ocelot Game

The ocelot game works like this: a developer has written a feature, and presents it to an ocelot. Not a real ocelot. Ocelots are playful. But they’re wild animals. Their claws easily poke holes in things. We want to poke holes in code. The ocelot is a role played by a developer who tries to poke holes in another developer’s code. Specifically, they try to change the code in such a way that the feature breaks while still passing the unit tests. ...

2024-09-11 · 5 min · 866 words · Thomas Cothran

Top-Down Imperative Clojure Architectures

When I first became interested in functional programming, a more experienced engineer told me: “you know functional programming doesn’t really amount to much more than procedural programming.” As I insisted on the benefits of map, filter and reduce, he simply shook his head. “You’re thinking in the small. Go look at a large real-world application.” It took some time for me to see what he meant. My preferred language, Clojure, is a functional language. But too often it is used to build top-down, imperative applications. This negates the value proposition of functional programming: isolating side effects, local reasoning, and system composition. ...

2024-07-22 · 7 min · 1280 words · Thomas Cothran