There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

isVeryLoud , in How programmers comment their code

Dankpods screen cap?

Andromxda OP ,
@Andromxda@lemmy.dbzer0.com avatar

I don’t know. Anyway, DankPods is awesome, there’s a great Lemmy community dedicated to his channel: !dingusland

Venator ,

Looks like it’s from this old reddit post from 6 years ago: old.reddit.com/r/…/code_comments_be_like/

navi , in How programmers comment their code
@navi@lemmy.tespia.org avatar

A real comment in our junior year game engine codebase.

https://lemmy.tespia.org/pictrs/image/df24b62c-f86a-41ac-adec-5ca86041a086.png

Johanno , in How programmers comment their code

I write such comments because I have to.

Company policy.

Also we have to specify every line of code and what it should do…

jas0n ,

Lol leave. That is so many levels of braindead.

explodicle ,

I would smash everything into a handful of overly-complicated lines.

MystikIncarnate ,

I loved doing this is school, just trying to mess up my teachers.

jaybone ,

Sometimes I think after i retire, I should teach. In the hopes that i could inspire people to write good code, instead of a lot of the garbage i see in the industry. This comment makes me sad.

MystikIncarnate ,

I just want to be clear, this was like highschool cs classes. I took things a bit more seriously in college.

I never wrote messy code or illogical code, or any code that didn’t work. We were learning C++ in those days and if you know anything about C++, you can basically cram an entire program into a single line. You can also do some shorthand stuff for calculations and updates to variables… So while the class was instructed to use whitespace and comments and update variables like “var = var + #” I would do var += #… I wouldn’t comment it, mainly out of hubris.

I was pretty good at it but I was lazy as all hell with it.

ulterno ,
@ulterno@lemmy.kde.social avatar

I feel like I am going to have to do the same thing in the end, to get my hand-over accepted.
Should I just copy the line of code and make a comment next to it with:


<span style="font-style:italic;color:#969896;">// It does <paste line of code>
</span>

CC BY-NC-SA 4.0

VOwOxel ,

Do you license every comment of yours? If yes, why? Tbh i’m just curious

ulterno ,
@ulterno@lemmy.kde.social avatar

Not every. The quick, very-low effort ones, I just leave.

Why:
I saw another post with “Anti Commercial AI License”, then wen on to read the license and went, “Neat!”.

  • It makes it easier for anyone to decide what to do if they want to use my comment/post (in cases where it actually has something useful)
  • It makes life just a bit harder for people data-mining for AI
    • That way, some data entry worker will probably ask for a raise and probably even get it and maybe some entrepreneur going “AI everywhere!” will think twice.
    • Or there will be a chatbot spouting “Anti Commercial AI License” or “CC By-NC-SA” in their answer text, which would be hilarious.

CC BY-NC-SA 4.0

communism ,
@communism@lemmy.ml avatar

How are you inserting your signature? is it manually? Do you have some kind of keyboard shortcut to insert it?

ulterno ,
@ulterno@lemmy.kde.social avatar

For now, I have just saved it in my clipboard application, so I copy-paste.
When it goes out of history, I just open a file, where I have saved it and copy from there. So it’s pretty crude.

I was hoping that either the KDE Social web interface would add a “Signature” feature or I would pick some Lemmy application that would allow that, but for now it’s just this.

Perhaps, if I feel like it’s being too frequent, I may set a compose key for it.

CC BY-NC-SA 4.0

AlexanderESmith ,

It's cute that you think data miners give a fuck about the license of anything they scrape.

jaybone ,

// this line increments the value of i by 1

i++;

AdNecrias ,

I hope they get paid per line of code.

jaybone ,

I hope i never have to work with you.

yetAnotherUser , in How programmers comment their code

<span style="color:#323232;">/*
</span><span style="color:#323232;"> * Gets stupidFuckingInteger
</span><span style="color:#323232;"> *
</span><span style="color:#323232;"> * @returns stupidFuckingInteger
</span><span style="color:#323232;">*/
</span><span style="color:#323232;">public double getStupidFuckingInteger() {
</span><span style="color:#323232;">    return stupidFuckingInteger;
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span>
mrpants ,

The lack of a return type declaration makes this sooo good.

expr ,

It has the return type declared to be double.

mrpants ,

I cannot read. Even better.

ILikeBoobies ,

Makes sense, people looking for int would find a double

Amir ,
@Amir@lemmy.ml avatar

This being a double physically hurts

AdNecrias ,

Reminds me of a job I had where c# summaries were mandatory and people used a documentation generator just like that.

/// Ages the Category. public int AgeCategory (…)

schnurrito ,

plenty of APIs in Java have documentation like that and it is worst when I read the documentation in order to find out the definition of the nouns and verbs used there and then it is just like that

Honytawk , in How programmers comment their code

Same with BIOS descriptions.

FGTSAB switch [toggles the FGTSAB setting]

infuriating

Andromxda OP ,
@Andromxda@lemmy.dbzer0.com avatar

I love it

Artyom ,

It’s so bad it’s almost artistic

jaybone ,

You mean autistic.

Dropkick3038 ,

An autistic coder would have documented this feature to the point of pedantry.

jaybone ,

And who updates that documentation three months later when a bug gets fixed or a new requirement get implemented?

BenLeMan ,

Yup, my first thought as well. While those days are thankfully over, those braindead BIOS “help” messages remain etched into my mind forever.

RogueBanana ,

Are the recent ones any better? I got a gigabyte b660m for 12th gen intel and it’s really bad at that. Had to look up a lot to figure out things.

BenLeMan ,

Maybe it’s an ASUS thing but both my current and previous boards have been pretty good with the help texts.

Honytawk ,

Snapmaker Luban is amazing with its help messages.

Every setting in this 3D slicer is completely explained how the setting works, what the different options are, with pictures and even what every option is the most optimal in whatever situation.

Too bad that it isn’t the best program unless you have a Snapmaker, and even then…

Amir ,
@Amir@lemmy.ml avatar

Love having to enable “support for sleep state 5” to turn off USB power when the PC is off

cupcakezealot , in How programmers comment their code
@cupcakezealot@lemmy.blahaj.zone avatar

//@TODO document this function later

15 years later

Shoe ,

Have reviewed 16 year old code for a very well known company in the last week with this exact comment peppered throughout, alongside delightfully helpful comments like:

// do not delete or change this it just works

// TODO temporary fix added 12/09/11 to fix incident must be removed ASAP

// CAUTION this returns false here instead of true like it normally does, not sure why

// if true then matched to valid account not is true

mundane , in How programmers comment their code

Comments should explain “why”, the code already explains “what”.

smeg ,

The allowable exception is when the what is a what the fuck, as in you had to use a hack so horrible that it requires an apology comment

mundane ,

Absolutely, although I see that as part of why

Why is there a horrible hack here? Because stupid reason…

bleistift2 ,

Describing the what also helps when you dabble in a new technology or little-used technology. It helps to explain to yourself what you’re doing and it helps in onboarding. “Hey, newbie, there’s a function in XYZ module that’s extensively documented. Look there for guidance.”

sukhmel ,

Or if the what is so cryptic and esoteric that it would require the reader a couple hours of research to understand it.

Also, I find it useful to summarise the what before code blocks if that can’t be summarised in a function name

azdle ,
@azdle@news.idlestate.org avatar

Unless you’re working with people who are too smart, then sometimes the code only explains the how. Why did the log processor have thousands of lines about Hilbert Curves? I never could figure it out even after talking with the person that wrote it.

ripcord ,
@ripcord@lemmy.world avatar

“Smart”

mundane ,

If you know how the code does something, you also know what it does.

calcopiritus ,

Inline comments yes.

Function/Class/Module doc comments should absolutely explain “what”.

mundane ,

You are absolutely right. It was inline comments I had in mind.

MystikIncarnate ,

I don’t code, at best I script. I’m a sysadmin, not a dev, so I play around in PowerShell mostly.

I just started to naturally do all of this. Not because I was taught to, but because I’ve written too many scripts that I later looked at, and thought, WTF is going on here… Who tf wrote this? (Of course it was me)…

So instead of confusing my future self, I started putting in comments. One at the beginning to describe what the file name can’t, and inline comments to step me through what’s happening, and more importantly why I did what I did.

The sheer number of comments can sometimes double the number of lines in my script, but later when I’m staring into the abyss of what I wrote, I appreciate me.

myplacedk ,

I agree.

I usually think of that as documentation, not comments.

But even so, the code should say what it does, with a good name. The documentation adds details.

SlopppyEngineer , in How programmers comment their code

Best comment ever was “It used to work like this but person at client demanded it work like that on this date” when the client complained it shouldn’t work like that.

0x0 ,

The best comments are “why” comments, the runner up is “how” comments if high-level enough, and maybe just don’t write “what” comments at all because everyone reading your code knows how to read code.

conciselyverbose ,

That’s basically what comments are most useful for. When you’re doing something that’s not obvious, and want to make sure the “why” doesn’t get lost to time.

kubica ,

// I'm not really that dumb, there is a reason.

DarkDarkHouse ,
@DarkDarkHouse@lemmy.sdf.org avatar

// narrator: the reason was management

NotMyOldRedditName ,

<span style="color:#323232;">// I told them I'd do this but only if they gave me time next sprint to fix it  - 12-03-1997
</span>
MostlyBlindGamer ,
@MostlyBlindGamer@rblind.com avatar

[flashbacks to the backlog being wiped out because “the client already signed off on the release”]

ChickenLadyLovesLife ,

I spent a year making my company’s iOS apps accessible (meaning usable for the blind and people with vision disabilities). I had to do a lot of weird shit either because of bugs in Apple’s VoiceOver technology or because of the strange way in which our code base was broken up into modules (some of which I did not have access to) and I would always put in comments explaining why I was doing what I was doing. The guy doing code review and merges would always just remove my comments (without any other changes) because he felt that not only were comments unnecessary but also they were a “code smell” indicating professional incompetence. I feel sorry for whoever had to deal with that stuff at a later point.

sukhmel ,

Well, this is shitty

I hope the reviewer did not also squash commits, and the next programmer would be able to at least dig what was there.

Doing changes after some rockstar dev implemented some really complex service, but left no clues as to what does what is so frustrating, and I can never be sure that I don’t break anything in a different place completely

ChickenLadyLovesLife ,

I meant to say commits and not merges, and yes he removed the comments before committing. It made no difference in long run because every new release broke all the accessibility stuff anyway. It’s amazing how little developers can be made to care about blind people - almost as little as managers. The only reason my company cared at all was they were facing million-dollar-a-month fines from the FCC.

recursive_recursion ,
@recursive_recursion@programming.dev avatar

this seems like a great idea as it provides proof in writing just in case the stakeholder complains later on about the thing you implemented at their request

jaybone ,

That’s actually the perfect comment, because if anyone ever comes back to fuck with you about it, it’s explained right there. Then you turn it right back around on management and watch them run around like chickens with their heads cut off.

sukhmel ,

Out management used to tell us, that even if head of department had committed to doing something some way, there’s no way or need to hold them accountable. It’s just that situation has changed, and nobody should bat an eye.

To be fair, they also did not pressure us much for the missed deadlines or missing features, because it was indeed the result of the situation described in the first paragraph

Maalus , in How programmers comment their code

How bad programmers comment their code. Good programmers don’t comment at all and let the code speak for itself, leaving commenting to some obscure and arcane implementation the coder left in after a week long binge on caffeine and gummy bears.

menas ,
magic_lobster_party ,

This is the truth. In my experience, the people who often writes comments are also writing the most incomprehensible code.

Comments are frequently getting outdated as well, so they’re not in great help understanding the code either.

CodexArcanum ,

I was rewriting some old code of mine and ended up stripping out the comments. I kept reading them instead of the code, which I had been changing, and they were irrelevant. (I added new comments back in, though a big reason to rewrite was to make the code more self-explanatory.)

Toribor ,
@Toribor@corndog.social avatar

“What does this section of code do?”

Run it and find out, coward.

Maalus ,

Nah. It should be obvious by just looking at it in code. If it isn’t, you haven’t extracted single purpose methods out of it yet.

magic_lobster_party ,

Just having clear and concise variable names often goes a long way. Avoid using abbreviations.

Breaking out the code into functions helps limit the number of variables within a scope, which makes it easier to name them.

BombOmOm ,
@BombOmOm@lemmy.world avatar

Code should absolutely speak for itself. But the occasional comment is still good to explain the ‘why’ of the code when the why isn’t very obvious, often due to a niche requirement. Also any time you have to break out a hack, that needs comments up the ass, what was the bug, what URL did you find the fix at, why does this hack work, etc etc. It’s very satisfying to go back and remove those hacks after they are no longer needed, often because the underlying technology fixed the bug that had to be hacked around.

Maalus ,

Yeah, hence me mentioning the arcane code nobody knows what it does.

NotMyOldRedditName ,

It definitely feels great when I get to remove the

//hack abc due to bug in library xyz version 1.4.5, issue tracker says it’s fixed in 1.5.0. - link

Wild_Mastic , (edited ) in How programmers comment their code

The code is self explanatory

/s needed apparently

menas ,

The words of the machine are sacred, Only the impure need explanation

The Flesh is Weak

snooggums ,
@snooggums@midwest.social avatar

It explains what it does, it does not confirm that it is what was intended.

shundi82 , in How programmers comment their code

/********** Setting up the fkuArray **********/

fkuArray = array(…

Hupf ,

Well, fku that array indeed.

muntedcrocodile , in More confusion for recruiters

With blackjack and hookers.

agelord , in More confusion for recruiters

It already exists: pyscript.net. See also: github.com/kkinder/puepy.

P.S: I’m affiliated with neither projects

calcopiritus , in More confusion for recruiters

Make it strongly statically typed. Dictionaries and lists must have all their items of the same type. For extra confusion.

MHanak ,

Even better: make it purely functional

dwraf_of_ignorance , (edited )
@dwraf_of_ignorance@programming.dev avatar

Even betterer: make it MOP(Monad Oriented Programming). IYou pray to a supreme being monad till your program works.

https://en.m.wikipedia.org/wiki/Monad_(philosophy)

sukhmel ,

And tuples should have the same types inside. And dictionary keys should have the same type as that dictionary’s values 😈

mexicancartel ,
  • require compilation
Redkey , (edited ) in I Have No Constructor, and I Must Initialize

Did you read all the way to the end of the article? I did.

At the very bottom of the piece, I found that the author had already expressed what I wanted to say quite well:

In my humble opinion, here’s the key takeaway: just write your own fucking constructors! You see all that nonsense? Almost completely avoidable if you had just written your own fucking constructors. Don’t let the compiler figure it out for you. You’re the one in control here.

The joke here isn’t C++. The joke is people who expect C++ to be as warm, fuzzy, and forgiving as JavaScript.

arendjr ,

Can’t it be both? :)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines