What makes some code readable and some not?
I recently found myself trying to explain this to a new programmer and the question has stuck with me.
Here's my answer: readable code presents a solution as clearly as possible to other programmers by:
- Demonstrating clear intent
- Not being longer than it needs to be
- Keeping variables and logic "close" to where they're used
But when I think about when I've used the term "readability," though, I've often make assumptions about who code readable to. I'd imagine that beginners to programming, beginners to a new language, and perhaps even experienced programmers without context in a particular domain might find perfectly "readable" code still difficult to understand.
What do you think makes code readable? And how do you think about who your code is readable to?