Log in

No account? Create an account
22 September 2007 @ 10:00 am
There are, like, four different related topics in my head. I'm gonna pick one and write about it. I'm in a programming mood, so this take will be about programmery stuff. So: this is slightly technical, and wanders a bit. You have been warned :-)

There's a principle in programming (and elsewhere) that's often called DRY, for "Don't Repeat Yourself". The idea is that you should specify everything exactly once, because then you only have to change it in one place. Most programming languages, and most human languages, make this challenging.

Certain programming languages make this easier by allowing you to do all sorts of evil high-level mathematical tricks (I'm looking at you, Haskell and SML/NJ). And it's, y'know, cute. But I notice one thing in particular about the results of actually doing this.

It's dense. Absolutely every line is full of meaning. Looking at a page of the stuff is exhausting. There's a reason we don't write newspapers that way.

Books and newspaper articles are meant to be readable. So they go over facts in slightly different ways, add some fluff, make sure there's plenty of whitespace... They add a bunch of simple repetition, so it's not too awful to read.

What interests me most about this is that the dense, short, DRY-style text is much, much better to work out ideas in, at least as a programmer. Things change in one place only, you can see a much larger chunk of the total program, you can keep more in your head, once you've (slowly) absorbed it...

But almost nobody writes like that. At least for programmers, a lot of the problem is that it looks like a lot less work because it's so short. And in a discipline where it's very, very hard to measure actual ability or performance, people use a lot of bad metrics. The simplest is, "look how many lines I wrote!"

So you see people bragging, "I wrote a 15,000-line program!", but only rarely, "I wrote an 800-line program that does the same thing as his 15,000-line program!" And if there weren't a huge program to compare to, you wouldn't hear it at all. Rarely, in a few specific scripting languages, you'll see boasts that go, "look how much I got done in fifteen lines!" or something like that. But usually it's Perl, it looks like line noise, and nobody will ever be able to read it or modify it again :-)

The closest equivalent I know is math -- optics books, for instance, are full of one-line differential equations that you could spend months figuring out all the applications of. The Fundamental Theorem of Calculus turns out to be way more complicated (and useful) than it looks. Multivariate Calculus is full of concepts that require either a large chapter of text or three short equations to explain.

And few people work densely in that, come to think of it. The only examples I can think of are extensive proofs. I wonder if mathematicians would be more or less productive if they worked more purely in such things.

Something I'm curious about, after reading too much Paul Graham... Do software startups write much denser code? I know Paul Graham himself did -- the stuff he prefers with procedural macros is very similar to a lot of the dense, code-passing-heavy ruby code that I'm writing. But do startups, where impressing people matters less, do more of that?
Camille, Destroyer of Worldsskamille on September 22nd, 2007 05:59 pm (UTC)
Are there really people that still brag about how many lines of code they write? That are actually good programmers? I won't say I write perfect DRY-style code by a long shot, but I also don't have a job where anyone cares about quantity over quality. I guess I just feel like writing code in a real setting should teach you in at most six months that quantity is meaningless.
Noahangelbob on September 22nd, 2007 06:49 pm (UTC)
There are definitely people who mention volume of code, even among good programmers. There are more people who treat it as meaningful even if they don't brag about it in the obvious way.

For starters, quantity *does* have a positive correlation with functionality, just not a very strong one.
Camille, Destroyer of Worldsskamille on September 22nd, 2007 11:24 pm (UTC)
I just asked my boyfriend and he agreed that the only time we ever hear anyone talking about lines of code anymore is either a) to brag about how few lines they did something in, or b) to talk about the scope of a project on a resume. It is meaningful to me to hear someone say they've worked in a million+ line codebase. It is not very meaningful to hear that a person wrote X lines of code.
Zhaneelzhaneel69 on September 22nd, 2007 08:21 pm (UTC)
I think that the "I wrote this many lines" may be changing, or it may just be the programmers I hang out with.

More I know are stating 'I wrote this much CLEAN code in blank time' so that quick, error free code is being valued. Yes, it still has # of lines in there, but with other qualifiers.

And my boyfriend loves to point out his python code that is TINY and yet powerful.

Programming needs to be dense, but for readability and allowing future modifications to the code, I think white space and somewhat less dense portions are necessary.