Hacker News new | ask | show | jobs
by geocar 3078 days ago
> Exchanging a single word for another may totally alter the effect of a passage

I think that describes code perfectly.

> but a function that is subjectively easier to read can be shown objectively to produce the same effect as the original function.

I think you lost me here.

I've rarely seen two implementations of an array sort that have the exact same effects. Things like how fast it is, and how much memory it uses is important to me.

How many characters on the screen is also important too, although certainly in more of a subjective way.

> The cliff-notes version of Macbeth can never produce the same effect in the mind of the reader as reading Macbeth

And the bubble sort doesn't produce the same effect as quicksort.

I'm not sure I understand what you're saying.

2 comments

You seem to be talking about algorithmic differences. Most of the time, when I see someone talking about code readability, they're not talking about the algorithm. The same exact algorithm can be implemented with varying degrees of readability.
>> Exchanging a single word for another may totally alter the effect of a passage

> I think that describes code perfectly.

I wasn't very clear here: what I meant was that exchanging a single word even for its closest synonym will always change the effect of a passage to some degree, because the intrinsic aesthetic qualities of the word inevitably alter the effect of the word.

This isn't true for code, where refactoring a line of code might change how readable that line is, while conceivably having an identical effect when the line is interpreted, compiled or executed.

I still see symmetry:

That the computer cannot receive joy from code does not mean that I can't; That the computer doesn't experience joy from Macbeth doesn't mean that I don't.

Reading joyful code is a treat. I pity who has not read some code that has brought them joy. And yet, what brings me joy[1], [2] is what the peanut gallery may call unreadable. What then?

[1]: www.nsl.com/papers/origins.htm

[2]: cr.yp.to/qmail.html

Surely something else must be going on.

Kernighan and Plauger, while otherwise dated, has one of the best rules for programmers:

Say what you mean, simply and directly.

Assume the best of the writer of the code you are reading; assume this was them saying what they meant, as simply and directly as they could.

Was it clear in their mind?

Or does it feel like they were muddling through the problem?

If as I am decoding this foreign thing of other people's code, I find my mind repeatedly would put it simpler, cleaner, and clearer, I can complain about the tedium, and mindless repetition in the code, but I'm still not complaining about it's readability.