☞ The Art of Computational Narrative
From Scripture to Source Code
The renowned scholar and translator Robert Alter has argued that the main narrative mode of the Hebrew Bible employs a specific register. Among its many features, this style of biblical prose is spare. It uses a relatively small vocabulary, avoids synonyms, and likely uses words that are more formal than those that were in ancient everyday usage. In addition, it uses a lot of repetition. Biblical narration is one of “slight strangeness,” with repetitive sparseness and somewhat greater formality, all features that Alter tries to honor in his translations.
As I was thinking of this, I was first drawn to making a comparison between biblical narrative and computer code. And at least when it comes to a relatively small vocabulary—variable names, repeated keywords, specific operators, particular functions in widely used libraries—that is true.
For example, as per its official documentation, Python has only 35 keywords:
But of course, the analogy breaks down very quickly. Biblical prose is narrating a story or conveying laws, and a computer program is designed to do something (interact with the user, process some data, display some graphics, whatever). Code needs to act. Also, biblical texts were meant to be read aloud and understood within a certain environment, and source code is meant to be looked at in a very different context. It also has to work in a very specific and delimited way. The programmer and novelist Vikram Chandra cautions against making these comparisons, writing in Geek Sublime, “[t]o compare code to works of literature may point the programmer toward legibility and elegance, but it says nothing about the ability of code to materialize logic.”
And we could go on.
Nevertheless, perhaps we can salvage something from this bad analogy. Perhaps there are specific features of computer programs that might be (a tiny bit) like prose. For example, just as literary texts have specific properties and rhythms, it could be useful to compare programming languages based on their literary properties. Is there a rhythm to a Python program, or something written in Lisp? And what are the nuances behind keyword choices within each programming language? For despite the limitations on syntax and vocabulary that each language contains, the resulting code may have a particular expressive power.
Different languages can even create different computational accents:
The computer scientist Edsger Dijkstra already noted this decades ago, though with his typical acerbic style he did this in the manner of a vicious takedown of various programming languages: FORTRAN is an “infantile disorder,” BASIC causes programmers to be “mentally mutilated,” and COBOL “cripples the mind” and is a “disease.”
Of course, not only will many of you will disagree with my characterizations of different languages—not to mention Dijkstra’s—but judging each language in its entirety is also not really fair. Some programs in Python can employ the more functional features of the language giving it a different flavor, or another program can suffer from being entirely spaghetti code. Each program and each programmer can have its own style (Exhibit A: “Is there a Correlation between the Use of Swearwords and Code Quality in Open Source Code?” Apparently yes).
However, just as there are people who advocate for software criticism, there is something to be gained for taking code seriously as a text and examining its literary features.
And what I’ve mentioned so far is just a taste. We can do much more, studying programming prose at the level of functions and classes and how they are written, or how if-statements are employed, how variables are named, how comments are composed, how a project is divided into separate files, and so much more. One can examine the structure of code at high and low levels, which is only natural, as one of computation’s defining features is that of abstraction.
This is often what a lot of software development does consider, such as in Code Complete (literate programming could also be relevant here). But I think it would be valuable to explore this more explicitly, as well as allow it to percolate out of the software world into the larger culture.
Code can be beautiful, or at least interesting and informative, and highlighting some of its distinctive features is something both fun and provocative. Let’s do more of it. ■
Thanks to Steve Krouse for feedback on this essay.
Tech of the Rings: I made a list of tech companies with names from the world of Lord of the Rings. More suggestions are welcome.
Lastly, I’ve been working on Magic Paper, a simple drawing tool geared towards doodling.
The Enchanted Systems Roundup
Here are some links worth checking out that touch on the complex systems of our world (both built and natural):
🜑 Speculative Technologies: “a nonprofit research organization that runs coordinated research programs to unlock big-if-true technologies that are too speculative to be a startup but are too coordination- or engineering-heavy for academia alone.” I am proud to be an advisor.
🜸 English is a Terrible Programming Language: “Because that’s another thing that people are confused about when it comes to programming, and this is something that even programmers don’t all recognize. The code isn’t for the computer—it’s for you. It’s for humans.”
🜹 Regular Expressions make me feel like a powerful wizard - and that's not a good thing: “What I'm getting at is that source code is designed to be read and edited by busy and distracted humans. We should be writing intelligible code for each other and letting computers do the boring work of making it more efficient.” Pairs well with the above article.
🝳 Deep learning for twelve hour precipitation forecasts: “neural networks can learn to emulate complex and large-scale physics”
🜛 A deep-learning search for technosignatures from 820 nearby stars: “Our work also returned eight promising extraterrestrial intelligence signals of interest not previously identified. Re-observations on these targets have so far not resulted in re-detections of signals with similar morphology.”
🝯 SF’s Market Street Subway Runs on Reagan-Era Floppy Disks: Some context from the article:
For those who’ve never had to use one—and keep it far away from any magnets—floppy disks are still used as the “save” icon on computers worldwide, but they’ve been obsolete for 30 years or more. Originally a full eight inches across when introduced in the 1970s, floppies later shrunk to five-and-one-quarter inches, and, eventually, a mere three. Early generations were indeed bendable, although the final generation was made of a harder, thicker plastic, with no flop at all. Eventually, CD-ROM technology superseded them before becoming nearly extinct, too.
🜑 ChatGPT Is a Blurry JPEG of the Web: Thought-provoking analysis from Ted Chiang.
🝖 What Is ChatGPT Doing … and Why Does It Work?: “But now with ChatGPT we’ve got an important new piece of information: we know that a pure, artificial neural network with about as many connections as brains have neurons is capable of doing a surprisingly good job of generating human language.”
🜚 Leonardo da Vinci's Forgotten Experiments Explored Gravity as a Form of Acceleration: “the fact that he was grappling with this problem in this way—in the early 1500s—demonstrates just how far ahead his thinking was”
🝤 The cursed universes of Dana Sibera: Computer hardware from a parallel universe.
Until next time.