HACKER Q&A
📣 jarbus

What are some great examples of well-written, clean, and minimal code?


Looking for some inspiration to improve my programming skills, figured looking at clever ways people approach problems might be a good start


  👤 BallCramp Accepted Answer ✓
"Well written" is hard to demonstrate, because (aside from being somewhat subjective) it's something that might only play itself out over a long period. For example, can you take one feature and completely remove it, without creating a nightmare for yourself? Can you add a new feature without needing to re-write and rearrange a million other things? And then on the opposite end of the spectrum, is everything so de-coupled that it adds needless structural complexity?

I think my biggest lesson as a programmer was returning to large projects I hadn't touched in a few months, needing to implement big changes. Nothing else has developed my sense of where, when, and how to separate concerns.

I'd recommend toying around with "design patterns", which forces you to think about different approaches. But I might be answering this at a different scale than you're asking. Personally I've found my biggest challenges have been structural... rather than coming up with tight little algorithms for things.


👤 martyalain

👤 samsquire
Try reading your language's standard library.

You don't want to be clever when writing code. Clever is hard to read. You want to be readable.


👤 0xcde4c3db
System V /bin/true (after a fashion) [1]

[1] http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html


👤 brudgers
Have you considered Knuth's Art of Computer Programming?