You have read and written vast volumes of code in your years behind the keyboard. Most of that code was lackluster at best. Sure, most of it managed to function well enough to keep the bits moving. Sure, some of it fits into a well-crafted architecture. But, face it. Very little of it was code that you'd show someone on a first date.
Yet, that desert of unexceptionalness had an oasis or two. You have seen some gorgeous code. You have seen some code that was the Platonic ideal of itself.
I thirst for this code. I want to see the greatest code that you've ever seen. Share it with me.
Actually, my interest goes beyond seeing the code myself. I believe that seeing, reading, and understanding perfect code is instructive. I believe young programmers will benefit from reading the best code we have to offer.
My goal is to write a book, or at least a series of blog articles, which presents and discusses the finest code I can find. Sadly, the goal of publishing book or articles means I may have to turn away some true gems. But, I want to know if you have seen any specimens which:
- manifestly beautiful,
- self-contained (at least to the extent where the purpose and conventions of any external functionality is obvious from the call itself),
- potentially publishable (as in, permissive enough licensing or obvious enough authorship through which to obtain such permission), and yet is still
- under four hundred lines (including comments and vertical whitespace);
Point me to them. Email them to me. Tattoo them on my thigh if that's the only way to convey them.
Neither the programming language nor the raison d'être matter at all. It can be a snippet of COBOL that tracks the number of paper towels you've used this year so long as reading the code makes you weep with joy.