this post was submitted on 20 Aug 2023
1231 points (98.9% liked)

Programmer Humor

19463 readers
830 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] ArcaneSlime@lemmy.dbzer0.com 21 points 1 year ago (5 children)

Lmao me commenting my 14 line bash script, comments almost as long as the script itself.

I have a habit of forgetting "why'd I put this there" and at least with my scripts I can leave myself a note for future me.

[–] nuez_jr@lemm.ee 10 points 1 year ago (1 children)

The highest comment-to-code ratio I ever wrote was a CMD script that had to combine three different escaping conventions.

It was a good day when I got to throw that one away.

Adding the fourth, ultimate escape to it.

[–] coloredgrayscale@programming.dev 7 points 1 year ago* (last edited 1 year ago)

Sounds like a good use of comments. Explain why, not how. (that should be readable from the code for the most part. Unless you're having function calls like xmmmuldp (simd) )

[–] h_a_r_u_k_i@programming.dev 6 points 1 year ago

Well, bash scripts are infamous for being arcane so commenting abundantly is better than nothing.

[–] nothacking@discuss.tchncs.de 3 points 1 year ago

This actually makes a lot of sense. A computer executing the code and a human maintaining it need to know different things. A human needs to knon what the code does on a high level (what the programmer intended), how it handles (or does not handle) edge cases, etc. A computer only needs to know how to run the code at a super low level. Without comments, it is impossible to know if code is doing the right thing, or what is expected from the caller.