DEV Community

Discussion on: Readability is paramount

Collapse
 
matthewpersico profile image
Matthew O. Persico

Wouldn't comments solve the problem? That's what I do in my Perl: you need to grok what map and grep so, but if I stream a bunch of them together, I'll use whitespace and comments to clarify what's going on.

Comments allow you to use the more efficient code and also to "teach a man how to fish". Why do we insist on dumbing down languages instead of smartening up programmers?

Collapse
 
jhall profile image
Jonathan Hall

Comments are a really bad way to solve this problem, because comments are easily ignored, easily separated from the code they reference, and frequently fall out of sync.

Good code should be easily read and understood without comments. If you need to explain your code with comments, it means your code is confusing. As I've written before: Comments are like appologies to the next programmer: jhall.io/archive/2021/02/14/commen...

There are of course appropriate uses for comments. But they should almost always explain the WHY of code, not the HOW of code.