a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment by briandmyers
briandmyers  ·  3469 days ago  ·  link  ·    ·  parent  ·  post: Kernighan's lever

It's not cleverness that's the problem, it's inscrutability. They can be linked but they are not the same.

Write your code so that it's as easy as possible for a later coder to read and understand - because that coder might well be you.





rob05c  ·  3469 days ago  ·  link  ·  

Right. But scrutable cleverness is often difficult or impossible. As anyone who's written C++ macros or templates can attest. My question is, what do we do when the only options are inscrutable cleverness, or scrutable badness.

briandmyers  ·  3469 days ago  ·  link  ·  

The best you can do is write some prose explaining how it works, and what you're trying to do, I suppose. Writing good comments is the hardest part sometimes.

rob05c  ·  3469 days ago  ·  link  ·  

That's essentially my conclusion, as well. I think it's important to ask the question though, lest we write inscrutable cleverness unnecessarily.

I've also come to the conclusion that almost the only valid reasons are performance (where it's actually necessary; it usually isn't), and duplicate code.

briandmyers  ·  3469 days ago  ·  link  ·  

And sometimes you just have to write "This works, so please don't change it unless you really know what you're doing". A heads-up is better than nothing.