a companion discussion area for blog.codinghorror.com

Coding: It's Just Writing


I’ve seen that adhering to Spartan Programming principles yields not only more concise but also more readable code.



There’s one big difference between coding and writing, however.

If you’re writing a book, and leave out a semicolon in the third paragraph on page 96, it usually doesn’t make pages 217 through 231 disappear. :wink:


brevity is the soul of wit.

And you’re also (hopefully) writing code for customers, who want something useful.


Geez, i do agree that programming and writing have some correlation, but i disagree that it lies in making yourself understood. I think it has to do with making your ideas better. Because it is very easy to have crappy ideas and believe them to be perfect, just like in a dream you are in a house that is and is not yours, things like that. And i do not mean logic, only, but full, consistent, mature ideas. Just because a big-calculator can churn out your ideas does not mean that they are good ideas. Good ideas have to be measured by some other metrics. And the thing is, when you write, you are not only expressing ideas that were previously in your head, you are actually forming the ideas. You are giving those ideas a body, so to say, and it is in this process that the ideas really come to life, not on your idle and selfish wondering inside your head for yourself. So, being understood by your fellows is definitely correlated to good code, but it is not a cause. Or something like it.


Chris Noe has an excellent point; that’s what I came here to say.

To add to that, the most frustrating part of my job as a developer is that after taking the time to write simple and well-crafted code a musical chairs event often comes along and I end up taking over code from a developer who absolutely thrives on creating complexity. They never think to rewrite, revise, edit, and simplify; once they get the first draft working, it’s done.

The result is that the developers who inherit my code are suddenly very productive, while I’m left wallowing in a pit of unnecessary complexity. The productivity inversion is even worse once you factor in the extra time I took to craft my code instead of just going with the first thing that worked. Fortunately I work for a good company so this is seen for what it is.

Over time I’ve found that the developers who write the worst code also have a tendency to move on to another team or project as quickly as they can so they don’t have to stick around and maintain or extend what they’ve written.


Ironically, I agree with the sentiment that this article suggests, with the possible exception of brevity. Brevity suggest that the one liner is the ideal form, when the opposite is probably true. Java encourages Literate programming in a way that say, perl doesn’t.


Maybe that’s why more things are not open-source, people are just too embarrased of their writing abilities and poor spelling hence the world is not perfect


Can someone (kindly) explain to me why ‘IF NOT SomeBooleanVariable’ is better than ‘IF SomeBooleanVariable = FALSE’? I personally find ‘= False’ easier to understand. And in keeping with the theme of Jeff’s post, that should make it better. Right?


I absolutely agree, but this shouldn’t be news to anyone. Brian Kernighan (perhaps you’ve heard of him), wrote The Elements of Programming Style 34 years ago. Maybe each generation of programmers gets to discover this anew.



Feature request:
New feed - 1 random archived post daily.
kthxbye :wink:


Matthew (commenter #2): It’s spelled embarrassed. :wink:


Coding: It’s Just Writing - reminds me of a true Dilbert moment a few years ago, when my (obviously non-technical) boss commented that he never understood why it took months to develop software. After all, he said, it’s just typing. Uh, Yeah.


I learned a lot from both The Elements of Style and The Elements of Programming Style (Kernighan and Plauger). The second is inspired by the first. Many of the rules are truly timeless. Recommended reading (if you’re not too allergic to Fortran).


I have a soft spot for Strunk White (despite also being a reader of Language Log), but even I was struck by your picking as an example one of the most obviously self-contradictory passages in the book:

13. Omit needless words.

Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. This requires not that the writer make all his sentences short, or that he avoid all detail and treat his subjects only in outline, but that every word tell. Yea, verily, verily, I say unto you, omit needless words and cast out all forms of redundancy.

What White should have written, of course, was either:

13. Omit needless words.

A writer should use no unnecessary words just as an artist should draw no unnecessary lines. Concise writing is vigorous; make every word tell.


13. Omit needless words.

Vigorous writing has a rhythm. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts; at the same time, however, a redundant word or overly ornate clause may be just the counterweight needed to restore balance to an otherwise dense mass of words. Vigor requires not that the writer make all his sentences short, or that he avoid all detail and treat his subjects only in outline, but that he weigh every sentence thoughtfully and make every word tell.


I think the trouble with the font has to do with browsers that don’t anti-alias fonts.

It looks great in IE 7 and Firefox 3 (who AA fonts), but I’ve also noticed that it’s pretty muddled in IE 6 and Firefox 2. Unfortunately they’re still quite popular browsers.

I truly understand how difficult it is to write, I’ve been keeping a blog for about a year, and only now am I starting to realize just how bad I am at writing!


Great blog, bad font. Is that concise enough?


Loved the Deleting code link at the end of your post.

I wonder if there’s a direct relationship between the people who can’t delete code and those who multi-compulsively back up their digital life?


I’m sending a link to a blog post I made about Strunk and White this past October. It’s mainly about web writing but it might be applicable to writing code. Others above are alluding to the same points I make:



I’ve been thinking this for years. Having done an English degree before one in Computer Science, I was quick to notice that problem solving skills weren’t the only ones that went into making a good programmer.

Along these lines, when being harassed by people I meet to solve their computer (virus) woes when they learn I’m a programmer, I like to point out their computer is like a bookstore, and I’m just an author. For the trouble they’re having they probably need a carpenter (to build a door, or patch a leak) or someone to clean up the mess in the aisles, but definitely not an author. :wink:


I’m glad you said writing. I find it hard to talk but I can write. The certificate that makes me most proud is my A at English O Level.

I had to make a change to software written using the nuweb literate programming tool. It was harder than it should have been (and I don’t think the document was badly written). And then the person after me modified the generated code directly. Sigh.

@Doug. Methinks? Hi, I’m English too! No-ones uses that word anymore (outside of Blackadder). And embarassing your coworkers is bad form dude. Good software is a team sport.