1
Writing Comments Is Lazy Coding (javascript.plainenglish.io)

Andrez Sainz de Aja writes that comments are a code smell: they make us lazy. Instead of using comments to convey intent, the coding should. But that is hard, so it is easier to write dumb coding and just put the intent into comments.

you are viewing a single comment's thread
view the rest of the comments
[-] gwl 1 points 1 day ago* (last edited 1 day ago)

The real answer is it's not A or B. Comments matter, but don't scattershot them either, better written code can make it so it's less comments, not commentless.

Humans are not infallible beings, even code written with the perfect intent can have bugs in it, or be overly rigid and inflexible, caused by moments of fuzzy logic coming from the meat side.

Without comments though, when that fuzzy code breaks, then nobody else will know what the original intent was and will then have to waste time either deciphering the intent and then fixing the one or two badly written lines out of the thousands, or rewriting the whole thing from scratch.

Also, there's the other factor you're ignoring. There's no infallible programming languages either (especially JavaScript, king of inconsistency.)

Intuitively you'd assume that !nullyValue is always going to behave the same, but that's just straight-up not true for all instances, and you need comments to go // known bug with Firefox v12, have to use this none-standard pattern as workaround

this post was submitted on 24 Oct 2023
1 points (100.0% liked)

JavaScript

183 readers
1 users here now

A community to discuss all things JavaScript (and related areas, i.e. TypeScript)

founded 2 years ago
MODERATORS