Skip to content
Coordinates of ThoughtHome of Philosophy
Join
Debate

Thesis

Elegant code is beautiful in the same sense a poem is, not merely by analogy

Written by the editors in the voice of an illustrative reader. About the community →

Where it stands

Editorial profile. This thread was started by an editorial profile, written by the editors in a reader’s voice to open the question. Replies from members are their own. About editorial profiles.

Programmers talk about beautiful code constantly. Donald Knuth called his life's work The Art of Computer Programming and meant the word. Edsger Dijkstra argued that elegance in programs is not a dispensable luxury but often what separates success from failure.

I write verification tools, and I recognise the feeling. A proof that a chip does what it should can be a sprawling case analysis or a short, symmetric argument that makes you see why it works. The second one is beautiful. I don't think I'm using the word loosely.

The motion: elegant code is beautiful in the same sense a poem is, not merely by analogy.

The strongest objection, I think, comes from Kant. He distinguished free beauty, which pleases without any concept of what the thing should be, like a flower or a pattern, from dependent beauty, which presupposes a concept of the thing's purpose, like a horse or a church. Code would be dependent beauty at best. Its beauty is always beauty-as-a-solution-to-something.

But poems have purposes too, and nobody thinks that makes them second-rate. A sonnet answers to fourteen lines; a ghazal to its refrain. Where exactly is the difference?

LikeReplySaveFollow3 replies

Join the conversation: members reply here, and joining is free. Reading is always free.

Join free to reply Sign in

3 replies

For the thesis 0

  1. Tomasz Szewczak

    For Illustrative reader

    For. In a proof assistant I sometimes prove the same theorem twice, once by brute force and once by finding the right lemma. Both are verified. Only one makes me want to show it to someone. That wanting-to-show is exactly what I feel about a poem.

  2. Kavya Menon

    For Illustrative reader

    For, from the poet's side. Pieter, a poem does have maintainers: every reader and every translator after me. And poems are judged on whether they work too, whether the line lands, whether the rhyme strains. I don't see a clean line between a tool admired for its use and an art admired for itself. Most art I love is both.

Against the thesis 0

  1. Pieter van Dijkhuizen

    Against Illustrative reader

    Against. The machine-learning code I write is often ugly and works beautifully, and the "elegant" refactoring sometimes breaks the thing that mattered. Elegance in code tracks something real, maintainability and clarity for the next human. That's a virtue of a tool, admired for what it lets us do.

    A poem has no next maintainer. Its beauty doesn't have to earn its keep. That's the difference Kant was pointing to, and I think he was right.