Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Writing Code Is the Same Thing as Writing Prose (gybe.ca)
34 points by kiyanwang on Dec 26, 2023 | hide | past | favorite | 51 comments


I write both code and prose for a living.

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.


> 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.

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.


Code is not mainly to be read by a person. It is a step to an executable artifact. It is read by a person mainly to modify that artifact. This trope that code is meant to be read is misunderstanding why you are reading it. One doesn’t read code as prose for its own sake. You read code as a means to an end. It is why we sometimes only read the documentation of libraries without reading the underlying code.


Precisely.

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

:-)


I agree that code is restricted by harder constraints, in that tests need to pass and typos/grammatical errors are disastrous.

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.


Grammar checks are somewhat like compilers. When I type prose or code into my text editor, both are underlined with squiggly lines if they are grammatically incorrect.

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.


> With a program, whether it compiles is a hard feedback. It either does or it does not, no wiggle room.

So it's like writing javascript? Only half joking!


> The act of writing Code and writing Prose is the same. They both use the same mental processes, have language constructs and audiences

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 don't experience writing code as similar to writing prose. Code has a lot of technical constraints, and prose is much more about emotion.

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.


I agree with you and disagree with this article.

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.


> I don't experience writing code as similar to writing prose. Code has a lot of technical constraints, and prose is much more about emotion.

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.


I think that you're saying that writing code is the same as writing prose. My experience is that, if I write both in the same way, I will fail at both. People just don't read prose to bask in it's technical correctness. Programming, at least the kind people get paid for, has strict technical requirements. They may get met in a creative manner, but they must be met. The primary output needs to be workable, runnable code. Programmers get paid to solve problems. But so do, e.g., surgeons. It doesn't mean that surgery is the same as programming, even if some people are called "code surgeons".


It's not the same, but there are some similarities. They have different purposes, so it's enough to say that they are not the same. I was just playing devil advocate and wanted to show that the set of arguments presented by original commenter was not that good.


> Code has a lot of technical constraints, and prose is much more about emotion.

Don't you like your variables? Are you not heart-broken when you need to let some dead code go?

:-)


Not to mention that feeling of emptiness and irrecoverable loss when a beloved binding goes out of scope. The passing of this local function left me with the existential dread of utter oblivion!


"mov pc, lr: a moving story of time passing's irreversibility" soon in your local bookstore.


I really like this post. However, one of the reasons I love writing fiction so much is that it feels like such a _different_ way to express myself creatively than programming. Both use my brain, but in totally different ways, almost like exercising different muscles.

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.)


> It’s a bit nonsensical to compare the number of words in English to the number of packages in PyPi, but we can agree that both English and Python are very rich languages, and no single person can reasonably understand the full scope of either language.

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.


Prose is the freest, loosest, and default way of writing in English.

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.


> They both use the same mental processes

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


Writing code uses the multiple demand network of the brain while writing prose uses mainly the language centres of the brain. Writing code is very much not the same as writing prose.

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)


As both an author and software developer, I find writing fiction to be wholly different from writing code. There is almost nothing in common between the two for me. (I’m pretty sure about this because I know quite a lot about how my brain doesn’t work and how I compensate for broken hardware.)

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 don't want to write an essay for an answer. I wish the author the best of luck in realizing their error.

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.


Can you elaborate why you don't want to convey the programmer's intent in the code? I mean, sure, pure functional code doesn't need variable names (or even legible function names), but why would you want to write in that style?


Because it shields you from implementation details, making your work orders-of-magnitude simpler as time wears on.

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)


Well, I suppose opening an essay with a compound gerund is close enough to the prose equivalent of premature optimization to suggest they may be onto something. However, aside from both processes optionally using keyboards for efficiency, code and prose really couldn’t be more different.


I am surprised that no one has mentioned Donald Knuth's literate programming yet.

https://en.m.wikipedia.org/wiki/Literate_programming


This article seems like non-sensical stretch to me.


By the dubious logic of this article coding is also like playing the piano, painting, or playing soccer.

I do write both code and short stories, and honestly it feels like 2 completely different activities to me.


This is probably different for different people. People experience creative activities in different ways.

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.


I really struggle with writing. It’s when I try anyways, however, and push through that, when I see how the process behind the two is similar. In both you’re just structuring ideas to direct the flow of data to achieve some goal.

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.


There is no demand that prose be internally or externally consistent, let alone logically functional, to achieve its objective of conveying information, emotion, or nuance. If you think there is, you're writing bad prose.

On the other hand, if you're writing code for a human audience, you're just doomed.


Maybe Angie's List could be more helpful than you think.

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."


To some extent, that analogy is interesting. Some code bases are really written like beautiful prose. All the rails code base is like that. WebKit is another great example. You can actually pretty quickly figure out where the flexbox layout implementation is.

Postgres code base is also notable in that regard.


I have definitely found the same joyous feeling of ‘flow’ when writing prose and when writing code - when you just write and it pours out of you uninterrupted, and at the end you come out of your fugue state and think “whoa, I wrote all of that?”

Live for those moments.


One distinction I saw when finally getting into writing:

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.


Maybe because pronouns act as implicit identifiers? Kotlin goes a little way towards that by letting you use "it" to refer to the first parameter of a lambda (which are used extensively) without having to introduce a new noun.


Good point.

There are natural languages without pronouns too, or at least it's seen as rude to use them like in Japanese.


Interesting. I explain it to non-tech people as like painting a landscape. There are many different ways to do so and I like to build up from low detail to higher detail until there is enough.


This to me makes as much as sense as comparing coding with running. I take a step, then I take another one, sometimes there are hurdles along the way, sometimes I get tired and I do it again the next day. And similar sense as the article.


If it were the case, I would be Ernest fucking Hemingway.

Jokes aside, the only thing they have in common is the fact that you 'write' them.


If this is true then programmers must sometimes have writer's block, which is something I've never heard of.


Programmers very definitely get writers block. Uncertainty over what to write, difficulty choosing between many options leading to doing none of them.


I wonder if the author would say reading code is the same thing as reading prose?


That's why I hate this new breed of computer idiot who presumes to be equal in everything, in order to elevate themselves above the futility of their control structures. And also the reason why I'm actually completely wrong on this platform and will be considered an outsider.

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.


> When writing prose, the reader’s brain becomes a compiler, translating the words from screen or paper into tangible thoughts and images, even if the words are not strictly correct.

This feels like someone felt that writing and coding are similar, and went on to force analogies between every aspect of both.


Really! Show me a 30 minute stand up comedy routine written in Perl or shut the fuck up.


These were featured on HN recently: https://nickm.com/poems/ppg256.html


This article absolutely infuriates me. Total horse shit. Not even a remotely valid premise and the execution is pathetic. It is on par with Flat Earth and Phrenology texts.

Read with caution because this is brain poison.


The author at one point advocates speeding up the writing process by incorporating bogus nonsense from ChatGPT and chucking the whole thing over the wall to someone else for fact-checking after it's completed. They may have taken the same approach with this article.


absolutely agree! But the difficult part is to find good arguments against it, which go beyond your feelings. Because we live in world, in which feelings alone have become almost meaningless.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: