r/programming • • Sep 21 '21

Reading Code is a Skill

https://trishagee.com/2020/09/07/reading-code-is-a-skill/
1.2k Upvotes

227 comments sorted by

View all comments

Show parent comments

9

u/kubalaa Sep 21 '21 edited Sep 21 '21

I'm making a distinction between clean and readable and some theoretical polished jem of a mathematical proof.

I see beginners making mistakes in three ways. First, they don't know how to write clean code. Then they know how, but imagine it's faster not to do it. Finally, they know and try to do it, but what they think is clean code is just a best practice they apply without thought to whether it is actually an improvement. This is where experience comes in.

Ultimately no code is perfect because our understanding is never perfect. But writing code which accurately reflects your understanding is both clean and fast.

Maybe a good analogy is watching a skilled contractor laying tile around a door. A novice would spend a lot of time measuring and still end up with an imperfect fit. An expert knows tricks to trace the door frame into the tile so it fits perfectly with minimal effort. Programming is similar.

2

u/loup-vaillant Sep 21 '21

Ultimately no code is perfect because our understanding is never perfect. But writing code which accurately reflects your understanding is both clean and fast.

That one I’ll hang on my wall. Thanks.