Writing Code Is the Same Thing as Writing Prose
gybe.ca
gybe.ca
They are not even close to being the same.
Can there be analogies, some very far fetched? Sure.
Do those analogies mean that the two are the same? No.
Is the reader's brain like a compiler? No. Compilers are very literal. Readers' brains build an imagined world from the hints given by the author.
One huge difference is the feedback. With a program, whether it compiles is a hard feedback. It either does or it does not, no wiggle room. Same if your unit tests pass. Does this sentence work? Maybe. Are you done revising that chapter? Well, I guess it's better now, but it still seems a bit wonky.
etc.
So it's like writing javascript? Only half joking!
But being able to write code that merely runs is the bare mimimum requirement you could put on a programmer. The thing is, the compiler is not your only audience.
>Readers' brains build an imagined world from the hints given by the author.
This is as true when reading code as when reading anything else.
Code is mainly to be read by a person. Otherwise there is no reason to keep a copy of the source file after it's been compiled into binary/executable form.
The main difference you pointed out is that for code to be functional it has an additional requirement of having to comply with rigid rules of the programming language, but the "reader" is still human.
And studies showed that code is read by humans far less than assumed.
And, in my experience, understood even less. Instead, it is rewritten from scratch.
See also CADT development paradigm: Cascade of Attention Deficit Teenagers
https://www.jwz.org/doc/cadt.html
:-)
Furthermore, I compose both types of text in an iterative process where I got the general ideas down first and then improve the precision and completeness of the piece.
Lastly, I think deeply about the human meaning of the text before I consider it complete, at least for my side projects. I refactor the code so that it matches my human model of the problem as well as I can.
Your mileage my vary, but coding and prose feel similar in my experience.
They don't use the same mental processes (do you code 3 characters per second for extended periods of time?), the language constructs are very different (just one example: no ambiguity), and your audience is not in a social relation to you. So no.
I'm not saying they have nothing in common. Code and prose are both written in languages, and prose has certain technical requirements like good grammar, etc... There are very creative prose stories that play with the rules of language. But the primary focus of prose is it's effect on people and that has a different requirements than a program which has to run, run correctly, be understandable, and be maintained.
Emotional constraints. You need to play those emotions in the right way to obtain desired outcome in the reader.
> There are very creative prose stories that play with the rules of language.
Just like demoscene, iocc or quines. Some stories/programs play with the rules of language/language to obtain desired awe inspiring result in reader/machine, some are more direct to obtain desired novel idea/calculation in reader/machine.
> But the primary focus of prose is it's effect on people and that has a different requirements than a program which has to run, run correctly, be understandable, and be maintained.
Not all programs need to be maintained, some are pretty good as is for their intended purpose. The rest is also a requirement for prose. It has to be read and understood for it to be usable.
Quote of the day:
"Debugging is like being the detective in a crime movie where you are also the murderer." - Filipe Fortes.
The assertions are quite generic to the point you could apply them to most pursuits or hobbies.
I think there is definitely an interesting link between coding and creative writing, but to me it's the way it scratches the same itch of producing something out of nothing, of the planning and different approaches you can take. They are similarly rewarding to me. In all other ways beyond the surface level of yes, both involve writing words, I think they're wildly different. My anecdotal evidence is I find it very difficult to swap between writing code and writing fiction on the same day - I am either doing one or the other, and I feel it's because of how differently the brain works in these 2 modes. If anything, I think coding has stronger similarities to maths, and it's just interesting that many coders also do creative writing - which I'd attribute it mostly to an intersection of people who like science fiction and also like making things.
Don't you like your variables? Are you not heart-broken when you need to let some dead code go?
:-)
I think you can find similarities of the kind listed in this post within pretty much any two activities if you look for them. But overall the differences are what make writing and coding so well-suited and _fun_ to experience in one brain in my opinion.
In the end, both coding and writing are a way for me to vent my creativity and bring the worlds and ideas in my head into something tangible. That is their primary similarity. I do believe programming and writing fiction are two sides of the same coin. But they feel largely orthogonal to each other in my experience of them.
(After I wrote the last sentence I wasn't sure I was using the term "orthogonal" correctly, as I see that in the plain English sense of the term it seems to mean entirely independent... When what I am trying to express is rather that they _are_ related and _not_ entirely independent. As my experience or knowledge of coding changes, so does my experience of writing, in the sense that they retain the consistent right angle or relationship to each other despite otherwise feeling very different.)
If I were editing this article, I would tell the author to remove the entire paragraph leading up to this snippet. Why would you insert a section that's so bs that even you immediately criticize your own point?
Truthfully, I read this article and came away with the conclusion that writing code is nothing at all like writing prose.
Writing code is a lot more like writing verse in iambic pentameter [1]: You have technical constraints that you need your writing to conform to, and thoughts or sequences can stretch out over many distinct lines.
[1] - Lines of ten syllables with certain rules, usually applied loosely, for syllable emphasis.
There is not some evidence or argument in the article to actually support this claim. If anything, assuming the more plausible hypothesis that programming and mathematical thought are akin to each other, and the fact that research supports that there brain networks related to mathematical reasoning unrelated to other language activities [1], I would think it is much more plausible that writing code is fundamentally different from writing prose (even if they do share some similarities as language goes).
There is a close connection between mathematical thinking, including all between basic arithmetic up to calculus, algebra and advanced research mathematics, and specific spatial abilities and skills (specifically mental rotation/transformation, but not other spatial/navigation skills [2]). Programming is also imo a mode of mathematical thinking, and in this one needs to construct and manipulate logical relations between objects and processes. This makes it different than prose, where the relations are of different natures. I think this is what is missing from this: math and programming alike involve a certain understanding and manipulation of relations, which uses our preexisting toolbox of spatial reasoning (which may or may not take the form of explicit mental visualisation; people with aphantasia can also be good in mental rotation tasks).
[1] Origins of the brain networks for advanced mathematics in expert mathematicians https://www.pnas.org/doi/10.1073/pnas.1603205113
[2] Reimagining Mathematics: The Role of Mental Imagery in Explaining Mathematical Calculation Skills in Childhood https://onlinelibrary.wiley.com/doi/abs/10.1111/mbe.12281
Source: https://www.cs.cmu.edu/%7Eckaestne/pdf/icse14_fmri.pdf (paper is mostly about reading code, but there are a collection of papers that together with this, puts together a strong argument that it's the same for writitng)
Documentation has significant overlap with code at work… because I treat shared code as documentation. For personal projects, I don’t do this and writing code has no relation to writing prose.
I used to feel the same way. I wrote and blogged about it, then did a bunch of research. I feel that this journey of ideas I took was the most important of my programming career. There's some extremely interesting stuff in how this guy is wrong.
In short, they are opposite things. In pure functional programming, the two are exact opposites. Mutable imperative programming gets fuzzy, which is why it tends to be so verbose. If you think about it, pure functional code without OO doesn't need variable names. The programmer's intent has been completely extricated from the implementation. We start adding a bunch of words to convey our intent to ourselves and future coders. Eventually this naively begins to seem as if we're actually communicating in a human language. Make the code readable, I used to say. It's a solution not a mystery novel. Comments are always good/bad.
I miss those innocent halcyon days of yore. Happy that I grew, but it was also fun confusing these two entirely different epistemological domains and believing there was some value in that confusion. There was not.
Think of how you already interact with pure functions: bash piping, SQL statements, OS math libraries, etc. If you're expecting an int, you get an int. Now, it may be the _wrong_ int, but that's on you, not the coder. Implementation complexity goes away.
Contrast that to how you might interact with a favorite JS library or framework. You do a thing that you think is right and the wrong answer or outcome occurs. 99% of the time your'e now researching SO and digging through somebody else's code trying to figure out whether it's you or them. Most of the time it's you, the code is good, but in either case you've mentally assumed responsibility for all this _new_ complexity that, by definition, is not related to the value you want to provide; it's just supportive.
Imagine if every time we used these pure functional things if we had to grok around the web and dive into code. What would using spreadsheet by like? How would word processors help us? Can you imagine an accounting project that spent three years designing their own spreadsheet for this particular customer, or decided to use a dozen new accounting tools that had never been put together exactly like this? Yet this seems to be the most common way programmers do their work. It's completely screwed up, we're hurting both our industry and our customers by continuing to work this way, and we should be ashamed of ourselves frankly. There are plenty of examples of complex programming solutions being provided that aren't created and maintained this way. (rant continues)
I do write both code and short stories, and honestly it feels like 2 completely different activities to me.
Programming, maths and computer games all feel about the same for me. Painting, prose or music are not the same activity in any sense. Might be worth noting that I scored poorly on language testing and highly in mathematics during education as some external validation that they aren't the same thing for me.
The author has generalised their experience to that of all people, possibly for dramatic effect.
It makes me dream of a day where I can just sit for hours and get lost in some prose, and come out of that with an end-to-end working demo.
Coding and drawing are the only two activities where I can be like that for now. Writing would be so cool to add though.
On the other hand, if you're writing code for a human audience, you're just doomed.
When they changed her name to just plain "ANGI", I heard about it on the radio.
For those who didn't know what Angie's List was to begin with, they kindly informed listeners that "Angi can help you find the prose you need."
Postgres code base is also notable in that regard.
Live for those moments.
Pieces written in a programming language are full of proper nouns (variables names) and proper verbs (function names).
Pieces written in English get pretty far without introducing new identifiers all the time.
There are natural languages without pronouns too, or at least it's seen as rude to use them like in Japanese.
Jokes aside, the only thing they have in common is the fact that you 'write' them.
No, computer programs (and code) neither solve existential problems nor do they resemble a poem or a story. It may be that for a developer 'meaning and code' coincide and have a special "artistic" meaning, but that does not mean that the emergent result is of general importance or has anything artistic about it. Running a loop and checking conditions a thousand times per second may give you a certain feeling, or even "Microsoft Word", but in the end it's just repeating the same thing over and over again. The only artistic thing about machines and programs is their speed.
Actually, for speaking to a machine one has to think like a machine, and for writing a poem, one has to think like a human.
'Ah, so you feel proud to have programmed a new 'service' that no one needs?' Congratulations! Be happy that there is also art, to which you have now turned to in order to experience something different from what you claim to be the same.
I get angry when I have to read such nonsense.
This feels like someone felt that writing and coding are similar, and went on to force analogies between every aspect of both.
Read with caution because this is brain poison.