Welcome to Part IV of my VI-part series about Eve, an exciting and fascinating new programming language.
One of Eve’s influences is Smalltalk, an innovative programming language developed at Xerox PARC and released in 1980. In Smalltalk, a running program consists of objects, each with their own independently-programmed behavior, passing messages to one another.
Wikipedia explains that a Smalltalk object can do exactly three things:
1. Hold state (references to other objects).
2. Receive a message from itself or another object.
3. In the course of processing a message, send messages to itself or another object.
From 30,000 feet, Eve looks like Smalltalk because both kinds of programs are made out of self-contained chunks of code that can be dropped into a program, even while the program is running, which is called live programming.
But once you zoom in and look at what the specific blocks are doing, the similarity breaks down: Smalltalk objects persist state between messages in lexical scope chains, while Eve blocks can only persist state between timesteps by writing to global databases.
Instead of comparing Eve blocks to Smalltalk objects, it’s more accurate to compare them to API handlers, those blocks of server-side application-layer code that handle client requests to API endpoints.
More precisely, Eve is similar to so-called “stateless” API handlers (ones that don't persist in-memory state between requests). Stateless API handlers are only allowed to do the following:
#2 and #3 are Eve’s bread and butter, and #1 and #4 are equivalent to manipulating the
@request database (a subset of #3). So Eve is like Smalltalk with stateless APIs instead of objects.
Recall from biology class that proteins are stateless API handlers running in your cells. They get called to do interesting jobs like catalyze chemical reactions and transport molecules. When they finish the job, they don’t persist any state; they reset back to their original configuration.
Have you ever wondered how cells call their little API handlers? Check out Sean Johnson’s Biology Stack Exchange answer for “How does a protein reach its substrate within the cell?”:
The protein doesn’t move towards anything. It just randomly diffuses (bounces around) in the cell until it sticks to something. The particular chemical structure (the shape) of the protein and whatever it hits will determine how tightly they stick together and whether or not a chemical reaction occurs.
Here’s a cool video that shows how proteins with a very specific shape bouncing around randomly can assemble into a complex structure.
Now that we know the basic rules of “protein programming”, we can get some insight about Eve by looking at places where it’s similar to protein programming but different from mainstream programming:
We’ve seen that Smalltalk and Eve are “live programming” systems whose blocks of code can change without restarting the program. Similarly, a cell’s set of proteins can change at runtime without needing to restart the cell. This is a special case of live programming called “life”.
Any individual protein can get messed up and fail to do its job. But when a cell is deployed in an organism, it can’t afford to go offline for any reason. Luckily, no single protein failure can corrupt the cell’s state that much, so the vast majority of other cellular processes don’t care when single proteins fail. Furthermore, error-checking and redundancy can be layered in, in the form of other proteins.
In Glycolysis, glucose is broken down in a series of reactions in order to eventually create ATP, the “energy currency” of a cell. The whole process happens in the cell’s cytoplasm, a.k.a. that liquid where all the proteins bounce around like crazy.
Glycolysis is a “metabolic pathway”, but the individual proteins don’t encode the fact that they’re part of anything larger — each one only encodes the logic for when to run and the state modifications it makes when it runs. The proteins just happen to be chainable in such a way that one’s output can be the next one’s input. In a cell, that timeless input-output chain structure ends up being mapped into an actual chain of events running in time; it’s just that the timing isn’t explicit in the proteins.
Eve calls itself “programming without order” because its blocks of code don’t explicitly represent the order of their execution pathways, just like proteins don’t explicitly encode the glycolysis pathway.
In a distributed system like a cell or database, implicitly ordered processes are more robust than ones that try to coordinate their timing explicitly. For example, during glycolysis, if one protein’s output gets gobbled up by some other cellular process, the metabolic pathway automatically knows not to keep running. And if that intermediate output later reappears, the metabolic pathway knows how to pick up where it left off.
Whenever there’s a glucose molecule hanging out in the cytoplasm, that’s when the first glycolysis protein calls itself in (a “hexokinase” in case you were wondering).
Event-driven programming is a mainstream paradigm, but a glucose molecule hanging around is just ordinary data; it’s not an event. A glycolysis protein is a case of code triggered by data, just like an Eve block.
By the way, it looks like biologists have independently discovered the value of literate programming. Compare:
“Protein programming” is my own term for a process that emerges out of stateless-API-like components. Another apt metaphor-term for this is blackboard system:
A group of specialists […] all watch the blackboard, looking for an opportunity to apply their expertise to the developing solution. When someone writes something on the blackboard that allows another specialist to apply their expertise, the second specialist records their contribution on the blackboard, hopefully enabling other specialists to then apply their expertise. This process of adding contributions to the blackboard continues until the problem has been solved.