Yeah. Most of the time I use comments in my algorithms, as they often use some weird optimized black magic which are difficult to understand without comments.
Comment on I am God's greatest programmer
magic_lobster_party@kbin.social 1 year agoComments should only be used to describe stuff that’s otherwise difficult to convey with code.
dukk@programming.dev 1 year ago
DoomBot5@lemmy.world 1 year ago
Like don’t set this value to the obvious default. Bad stuff happens
xmunk@sh.itjust.works 1 year ago
The best explanation I’ve ever heard is:
hikaru755@feddit.de 1 year ago
There are some cases though where the code is just complicated for reasons outside of your control, in which case “what” comments are good - but they should never be taken at face value, but only used as a first step in understanding the code. There’s a significant risk of the code not actually doing what the comment says.