Hacker News new | ask | show | jobs
by Void_ 5000 days ago
This is cool as a joke, but I don't think code should be compared to writing.

For example I am an engineer, so this comment is written like code. It contains just enough words to express my point, it's clearly structured and my goal is to make it easy to read.

That's okay writing, but far from great. Great writers can just sit down and write amazing text. I could never do that. I have to go back, read after myself and refactor.

I wonder if other engineers feel similarly.

6 comments

Writing prose is actually quite similar to writing code. I don't think any author writes in linear, unidirectional process. Just like coding, you solve some subproblems (chapters, sections, etc.) before moving on to somewhere else, you go back and refactor so that the text flows better, or the ordering of points is better. And there are bugs. Stuff that's wrong, a dropped word and so on.

My experience with writing is mainly with academic prose, but I think most literary authors work like this as well. Besides, I do think that different programmers will have different styles in the same way different authors have styles. In part it'll probably influence your choice of language, but there'll be variation within a single language as well.

> I don't think any author writes in linear, unidirectional process.

Yes, people do. On the extreme end you have the stream-of-consciousness style. E.g., on the road was written on a typewriter with a series of sheets of paper joined together to avoid interruptions. I also think I remember Neal Stephenson saying in a talk that the writing should come out naturally, not sculpted word for word. When it doesn't, it's called writer's block; a programmer's block on the other hand is not really a thing.

Text is typically read linearly, so it's also easier to write that way. Code, except for the very simplest, jumps around from function to function so it's going to require some additional planning.

I disagree. I think the best writers work precisely like the best coders. They don't compromise on a single letter, they ruthlessly rewrite and refactor their own work as many times as they need to, and they value simplicity, elegance, and effectiveness.

The main difference isn't the method, it's that writers usually get a lot more time to do their work.

Tangentially, I believe that learning to write better will make you a much better coder and communicator.

> They don't compromise on a single letter

+1. I think that's why the Hemingway snippet works so perfectly. The tone both perfectly captures Hemingway's voice, and the design qualities of beautifully engineered code.

> I believe that learning to write better will make you a much better coder and communicator.

And again, yes.

> Great writers can just sit down and write amazing text.

Very few great writers can. Dickens wrote prolifically because he was paid by the page (actually, he published in 32 page installments, so he was paid for each 32 pages); which may be why he's so controversial. They often edit a lot to improve the structure of their work (unless they publish in instalments).

> For example I am an engineer, so this comment is > written like code. It contains just enough words > to express my point, it's clearly structured and > my goal is to make it easy to read.

That second sentence sums up 95 percent of advice professional writing instructors give.

I think comparing coding to writing works because they both show a flow of thought. How you write and how you code depends on the way thoughts flow from you. I feel that things like verbosity, word choice, sentence structure, etc. are very similar to logic choices and order of operations.

Also, both writers and programmers do a ton of refactoring. Most authors will go over their writing 2 or 3 time, eliminating words and sentences that are unnecessary, combining and shortening sentences to make them more readable, etc. A lot of refactoring happens in both.

Go read "On Writing" by Stephen King. It will make you a better programmer and a better writer.