jh

Home | Projects | Blog | Quotes | Connect

Writing, Code and Prose

I’ve been thinking about the differences between writing code (programming, mostly Python) and prose (banger Substack posts, such as this one).

The Geographer, a painting by Johannes Vermeer
The Geographer by Johannes Vermeer, 1668-1669. (New meta: Instead of asking AI to generate a thumbnail, I had it find some existing painting to go with the post.)

Prose is written to be read, code is written to work

Prose is written to be read by other people. Authors can have different intentions with their texts, like informing, persuading, or entertaining the readers, but it’s the readers for whom the text is written.

Code is instructions for the computer to solve some task. When the code is run, it should solve it in a way the author intended. The ultimate goal of code is that it should work.

Of course, the code should be written in a way that makes it easy to understand its purpose. This makes it easier for other programmers – or the author in a couple of weeks – to see what’s going on and contribute. So, the code is also written to be read, but this is not the main goal, it just helps achieve it.

Code can be tested

Since the code usually has some task it should solve, it can be tested by comparing the actual behavior with a predefined intended behavior. It’s extremely useful to have a good test suite, because if all tests pass, one can have at least some sort of assurance that the update did not break anything. There’s nothing like this for prose.

Interlude: Learn Vim

I’m always flabbergasted when I see a doctor typing with two fingers – why didn’t they learn to use all ten, since so much of their work is typing? Of course, I know why – it’s painful. I think it took me like two weeks of everyday practice to get back to my previous speed when I learnt. But it’s so worth it!

I feel similarly about using Vim keybindings; I really hate writing or editing some text, both code and prose, without them. I’ll skip explaining Vim to the uninitiated, but if you’ve heard of it before or edit text/code on a computer a lot, I think it’s well worth it to learn the basics. I think it shouldn’t take more than one week to regain the lost speed.

For my setup, I sometimes use Vim, but also use the keybindings in Cursor/VS Code for programming and in Obsidian for text. I use mostly the basics: moving around with hjkl, jumping to lines with :, deleting lines or text to the end of the line with dd and d$, jumping to start/end, stuff like that. I also have Caps and Esc keys swapped for quick leaving the insert mode. But that’s mostly it, and it’s enough to not having to use a mouse at all during editing, which is very, very comfortable.

Prose gives more space for self-expression

Programming languages have pretty tight rules about how code should look. A function in Python is defined as def func(x):, not definition func(x) or def func[x]. Such code would not run.

Then there are programming conventions, like “we use snake_case for variable names”. Breaking these would not make the program not run, but it’s extremely useful to have the code look similar across the codebase, especially in a team. It’s common to have some of these rules applied automatically, so that it’s actually impossible for a programmer to break them.

On top of that, there are a lot of best practices one should follow. Code should be reused instead of duplicated, error messages should be informative, etc.

So when one is writing code or designing a system, there are a bunch of rules that should be followed, and if they are not, the code may not run or other people may request it changed.

This is less so with prose. Yes, there’s syntax and grammar and rules and best practices – but it’s much less restrictive! It seems there are many more choices the author has which all fall under the ‘style’ instead of ‘error’. There are way more ways to write a good paragraph than a good Python function, it seems.

Training the brain

Writing both good code and good prose is a challenging, deep-work activity. They both train the brain in a certain way. Coding is the ability to translate some desire from the real world into a machine-understandable algorithm. Writing prose is the ability to make one’s thoughts comprehensible to others, and even to the writer themself. It seems that the latter is a somewhat more general skill than the former.

This applies to the old-school programming before AI, which nobody does anymore. As I’ve written before, coding with AI agents has become a much more scattered and multi-tasked activity than it used to be.