Welcome to Part IV of my VI-part series about Eve , an exciting and fascinating new programming language.
I. How Eve unifies your entire programming stack
II. When logic programming meets CQRS
III. Throwing off our scope chains
IV. Smalltalk and protein programming
V. The rock-solid foundation for Eve’s big vision (Monday 12/5)
VI. Why Eve will be perfect for realtime apps (Thursday 12/8)
Smalltalk with stateless APIs
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:
Read from a request buffer
Manipulate local variables
Manipulate database data
Write to a response buffer
#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:
1. Live 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”.
2. No single point of failure
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.
3. Programming without order
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.