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.

Thcdenton , in Me after I got fired

That happened 🙄

extratone , in Fitbit Clock Face
@extratone@lemmy.world avatar

Datestamp horror.

Daxtron2 , in Fitbit Clock Face

Everything’s a string 😢

lseif ,

Everythings an object 😰

Daxtron2 ,

lua tables all the way down

takeda , in 10 months later bill revisits his spaghetti code. forgets absolutely everything and refuses to elaborate. this wouldn't have happened if Bill forgot to comment on his code

I’m Bill I don’t comment my code (except complex parts), instead I try to make code clear, including using proper variable and function names and try to keep functions short. I don’t think I ever got lost in my own code in my 20+ years of experience. Even got complements about it.

The programming language is meant for humans to read/write, if you need to put comments to understand your code then your code sucks.

suodrazah ,

Use comments to describe the philisophy of the code, the why. And any non obvious extended relationships. Risk. Etc.

Comments on function are typically a waste of space.

NuXCOM_90Percent ,

Commenting is an art. Too much and it is outright misleading after the first hotfix. Too little and only the original developer can maintain it

But uncommented code is a dick move. And, more importantly, it means you can’t punt bug fixes to the intern

krellor ,

When writing basic business code, structuring the code well and having good naming standards means you shouldn't need a ton of comments, but you should still have some. Plus, using structured function content blocks gives you intellisense in some languages and IDEs, which is important for code reuse in teams.

However, when I was doing scientific programming I'd have comments for almost every line at times where I put the mathematical formula and operations the line represents. Implementing a convolution neutral network with parameters to dynamically scale the layers or MPI stochastic simulations is much different than writing CRUD functions or basic business logic.

robdor ,

I think that makes you Phil, not Bill. Thanks for the good work you do Phil.

ILikeBoobies ,

Comments are there to make your ctrl + f’s faster

Anders429 , in the myth of type safety

I’ve seen this same thing happen with Python’s type hints. Turns out giving an “escape hatch” type for devs who have no clue what the type actually is leads to a lot of useless type hints.

vzq ,

/me laughs in void*

magic_lobster_party ,

Laughs in Object

RandomDevOpsDude ,

Laughs in object

Knusper ,

Yeah, it’s especially bad, when a library doesn’t provide type hints itself. It can be comically difficult to find out what the return type of a function is, because every if-else-branch might have a different return value, so you may need to read the function body in full to figure out what the type might be.

Add to that, that lots of the tooling around type hints isn’t as fleshed out / useful as it is in fully typed languages and I can definitely understand why someone might not immediately feel like it’s a valuable use of their time.

magic_lobster_party , in Show me a better text format for serializing

JSON for serialization all the way. It’s simple and to the point. It does one thing and does it well. There’s little room for annoying surprises. Any JSON can easily be minified and prettified back and forth. If you want it in binary format you can convert it to BSON.

Yaml is too much of a feature creep. It tries to do way too many things at the same time. There are so many traps to fall into if you’re not cautious enough. The same thing can be written in multitudes of ways.

jjjalljs ,

Yes, but whoever decided that json can’t have trailing commas has my ire.


<span style="color:#323232;">{ "a": 1,
</span><span style="color:#323232;">  "b": 2,  &lt;-- nope
</span><span style="color:#323232;">}
</span>

There was some other pitfall I can’t remember around missing keys and undefined, too, but I can’t remember it now.

OmnipotentEntity ,
@OmnipotentEntity@beehaw.org avatar

Change to Haskell formatted commas and the problem goes away :D


<span style="color:#323232;">{ "a": 1
</span><span style="color:#323232;">, "b": 2
</span><span style="color:#323232;">, "c":
</span><span style="color:#323232;">    [ 3
</span><span style="color:#323232;">    , 6
</span><span style="color:#323232;">    , 9
</span><span style="color:#323232;">    ]
</span><span style="color:#323232;">}
</span>
ursakhiin ,

Where is the nearest fire to dump this comment in?

Sgtmoustache ,

I’m pretty sure you can have trailing commas…

Bjornir ,

You can’t but some parser allow them. But those that do do not respect the standard.

Sgtmoustache ,

Good to know. Must be why I thought you could. Thanks.

adambowles ,

Trailing commas are supported in json5, as well as comments

kool_newt ,

There should be a “Simple YAML” that is just scalars, lists, and dicts.

kogasa ,
@kogasa@programming.dev avatar

Toml

octoperson , in A box of DevOps

Did you know YAML is a recursive acronym? It stands for ‘YAML AML MAML LAML’

SaakoPaahtaa ,

Nature is beautiful❤️

sxan ,
@sxan@midwest.social avatar

Is it polynomially recursive? Like, the AML stands for “AML MAML LAML”, and so on?

cupcakezealot , in JavaScript's days are numbered
@cupcakezealot@lemmy.blahaj.zone avatar

slides £20 across the table make it end tomorrow

ARk ,

reserve me tickets for the inevitable shit show that follows 🍿

explodicle , in When someone corrects your code

Correcting my code is helpful. The machine didn’t know what I even meant. Computers are interesting and changing rapidly.

Correcting my grammar is an unsolicited English lesson from someone who already knew what I meant. English is not interesting or changing quickly.

MJBrune ,

English changes very quickly. New words come out every year. Some programming languages takes years for updates.

Doug ,

Also that person may have known what you meant, but another might not and may have any number of reasons for not asking.

Better communication skills are a worthwhile goal and there’s no good reason to not learn and grow.

CanadaPlus ,

I mean, there’s a difference between something being phrased in an odd or confusing way, and a pedantic comment about whether you should use a Latin plural. 90% of the time you get the latter.

Doug ,

90+% of the time you get common mistakes. Should ofs, they’re - there - their confusions, apostrophes for plurals.

The kind of thing that confuses ESL speakers. The decent thing would seem to be to try and stick to the way it’s taught rather than go with the “it doesn’t matter” route when it absolutely matters to some.

CanadaPlus , (edited )

If you’re speaking to someone ESL, don’t do not even use contractions. They are perfectly valid but they are confusing to those new to the language. I also like to put all idioms in quotes when writing, as those are confusing in any new language. Misspellings are less of an issue than you might think because English spellings are dumb and arbitrary already.

When someone tells me “um, it is cacti, AKCTUALLY” I do not think concern for an ESL person listening in is the main motivation, though.

Doug ,

I think you and I have very different experiences. I rarely see that kind of correction if ever.

When you’re in a public space you never know when your words are being consumed by an ESL speaker. I think the best approach is natural yet accurate. They’re going to encounter contractions when dealing with native speakers, but the difference between it’s and its, for example, can be tricky so try to use them as taught.

Spelling mistakes can absolutely be an issue. It’s already hard enough to figure out English spelling without native speakers making it worse. Add on to that the difficulty in any added language of working out near homophones, let alone actual homophones.

I knew someone who was pretty decent with English as their third language but had trouble keeping Texas and taxes straight. I know another guy who is American and uses no in place of know. That one threw me for a while before I figured out what he was trying to say.

I will admit, I do like that “technically” the plural for octopus is “supposed to be” octopods (pronounced like oc-tip-o-dees) but that’s a fun “fact”, not a correction I’ve ever tried to make.

CanadaPlus ,

I really do run into issues talking aloud about plants of the family Cactaceae fairly often. It might be a hyper-local thing I guess.

I don’t remember where exactly I got the spelling thing from, so I could just be wrong about that.

Doug ,

I didn’t want to come off dismissive asking how often you’re talking about those specific kinds of plants but maybe it’s a relevant question after all lol

CanadaPlus ,

Yeah, but what percentage of normal speech is made up by words under 20 years old?

MJBrune ,

Depends on how you talk and what you define as normal. How much C++ is still using C++98 and how much uses C++20? It’s pretty silly of a comparison. As someone else put it, corrections are also there for a third party.

But let’s get down to the issue. You are right, correction of English is used as an insult a lot of the time. Sometimes correction of code is also used as an insult. When correcting someone is used out of line and abused, it’s always a bad thing. Correcting someone should never be used to insult.

If you don’t mind, let’s go down a rabbit hole, if you don’t care to join feel free to stop reading here. The upshot is that you are correct because the intent behind correcting English is usually abusive.

So, I corrected you earlier but this is to create a conversation. This is something I’ve been noticing a lot in social media overall: corrections seem to create conversation where if you agree with someone it’s not typically a conversation. “Yeah, you are right…” isn’t a path to an interesting exchange of ideas. There is another way that I’d also love to encourage people to try. Asking questions and digging into why. I’ve seen this happen a few times and it feels like it’s taken more as an insult. A lot of people get defensive if you ask “Why is this something you think.” We’ve created an internet culture of correction, where correction makes conversation. I wonder if this stems from people on the internet correcting people as an insult. Anyways, thank you for reading this random tangent :D

CanadaPlus , (edited )

But let’s get down to the issue. You are right, correction of English is used as an insult a lot of the time. Sometimes correction of code is also used as an insult. When correcting someone is used out of line and abused, it’s always a bad thing. Correcting someone should never be used to insult.

I like this. I don’t think that’s the intention for a lot of pedants, but rather they hold a belief in prescripitivism, and have taken it upon themselves to enforce the rules as they imagine them, for one reason or another. That being said, it’s still telling someone they’re wrong without any possibility of improving present or future discussions, and that’s why it’s annoying.

So, I corrected you earlier but this is to create a conversation. This is something I’ve been noticing a lot in social media overall: corrections seem to create conversation where if you agree with someone it’s not typically a conversation. “Yeah, you are right…” isn’t a path to an interesting exchange of ideas.

It’s true, and I think there’s some people that like that approach more than others. I wonder if that contributes to the high number of lurkers on every platform. The main other kind of space centers around venting about a common complaint as the main form of discourse, and those always end up being a little unhinged after a while.

Asking questions and digging into why. I’ve seen this happen a few times and it feels like it’s taken more as an insult. A lot of people get defensive if you ask “Why is this something you think.” We’ve created an internet culture of correction, where correction makes conversation. I wonder if this stems from people on the internet correcting people as an insult.

You know, I’ve never thought about it that way, but you’re right. Every once an a while I see someone take a truly odd position on something, and I end up just asking questions because it’s new and interesting and I don’t really have a bottled comeback. It seems like that actually makes them more defensive than if I had just called them an asshole.

Anyways, thank you for reading this random tangent :D

You’re welcome, it was a good one!

Edit: Oh yeah, and on C, I was expecting someone to mention it. It’s an outlier in being way more static than pretty much every other programming language, but it’s still faster changing than the average natural language. Maybe casual Hebrew has changed more since the 60’s, I guess.

ipkpjersi ,

Except for front-end technologies like JavaScript where there’s a new framework every week lol

explodicle ,

Which is easier - read a 50-year-old letter, or run a 50-year-old program?

lemmyingly ,

What if your grammar is that bad that people struggle to understand you?

I know someone who is incomprehensible most of the time. I have to ask probing questions just to vaguely understand what they’re trying to communicate. I’ve politely told them more than once about the issue but they never try; they’re not mentally challenged or anything, just an ass.

CanadaPlus ,

I’ve never met a native speaker like that, but yeah I think they’re the exception that proves the rule.

lud ,

Then they couldn’t correct you.

sj_zero ,

fr fr no cap

bappity , in I am God's greatest programmer
@bappity@lemmy.world avatar

me when first starting out at a job commenting everything I can
VS
me a couple years in completely lost because I never updated the comments and now none of them make any sense whatsoever

xmunk ,

Commenting well is a highly advanced skill. I generally prefer no comments on code since it’s less likely to confuse people and I’ll merrily purge auto-doc comments and anything like

// getId() returns an id

That comment has negative value.

kubica ,
@kubica@kbin.social avatar

I can't help it, I always get the mental image of hands clapping sarcastically when I see something like that.

bear ,

I write a lot of fairly simple scripts in Bash and PowerShell that should be easily understood by anybody else with moderate experience in the language, but I leave a lot of obvious comments because my coworkers don’t write any code and are extremely skittish about my automations. I add them basically to quell their fears.

odium ,

Why are coworkers who don’t write any code in the codebase?

bear , (edited )

These are scripts that manage stuff on a few hundred user endpoints and a few servers. They were doing basically everything manually until I got here, and the only way I could get them on board with my slow introduction of automation is to let them see it. I have to ensure things don’t get too long, complex, or hard to explain, or they start getting nervous.

magic_lobster_party ,

Comments should only be used to describe stuff that’s otherwise difficult to convey with code.

dukk ,

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.

DoomBot5 ,

Like don’t set this value to the obvious default. Bad stuff happens

xmunk ,

The best explanation I’ve ever heard is:

Comments should state the ‘Why’ never the ‘What’.

hikaru755 ,

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.

platypode ,
@platypode@sh.itjust.works avatar

In my experience refactoring lots and lots of crappy code left by devs long gone, a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them. If the code doesn’t have informative names and clear separation of concern, chances are a comment won’t help because the dev didn’t really know what they did that worked in the first place.

MagicShel ,

Generally, yes. However I have been known to document exactly why I’m doing something incredibly stupid - because it’s required but a stupid third party library which, despite being awful, is still better than implementing it myself as a refactor.

bappity ,
@bappity@lemmy.world avatar

a dev who can write useful comments is by and large a dev who can write code clean and simple enough not to need them.

my boss is great in this regard and also always has to keep reminding us to write unit tests 😅

MajorHavoc ,

I’ll point to the sign again:

Points to sign

“Comments shouldn’t say ‘what’ the code does, they should say ‘why’ it does it the way it does.”

oce ,
@oce@jlai.lu avatar

I’d rather teach people to comment well through my reviews. Much easier to understand two lines of well written function description in English than 20 lines of code.

Landless2029 ,

Yeah well now we have git copilot where your comments include AI suggestions.

Now I have TONS more comments

evatronic , in Memory is overrated

This is terrible! What half-witted shit-for-brains monkey crapped this craptacular crapfest out?! I swear to Kaballah Monster, as soon as I figure out…

git blame

…oh.

MerfMerf , in D or d come on
@MerfMerf@feddit.nu avatar

echo ‘set completion-ignore-case On’ >> ~/.inputrc

PupBiru ,
@PupBiru@kbin.social avatar

also idk does zsh do this automatically? don’t think i’ve ever had this problem except on legacy AF servers

i mean… unless you don’t tab complete, but then who doesn’t spam tab 30 times every keystroke?

MerfMerf ,
@MerfMerf@feddit.nu avatar

Or up-arrow a bazillion time because you probably have it SOMEWHERE in the buffer, surely.

jmcs ,

How does that handle languages that have different rules for capitalization? For example I and i are not the same letter in Turkish.

MerfMerf ,
@MerfMerf@feddit.nu avatar

Don’t know actually, never used a language like that. But should be easy enough to undo should one test it and end up not liking how it handles it.

kattfisk ,

I believe that type of stuff is specified in your locale, so it’s possible that it would do the right thing if you’ve set your language to Turkish. Please try it and let us know though :)

tostiman ,
@tostiman@sh.itjust.works avatar

Awesome, thanks

UFODivebomb ,

Shit yo. How come I only learn this now? Thanks!

M500 , in The difference

I’d argue getting doom to run is a good way to demonstrate understanding of the tech.

BradleyUffner , in Pure Evil

Any remotely capable IDE will immediately show you what, and where, the problem is.

stebo02 ,
@stebo02@sopuli.xyz avatar

it would still be confusing why all semicolons are highlighted

qaz ,

VSCode has a special case for this

etler ,

That means that detection was added explicitly because this prank was done enough that it was worth it to add.

Quik ,

The reason is in fact not only because of this exact symbol, but because people tried to change program’s behavior in a malicious way by replacing legitimate code with same looking symbols.

dylanTheDeveloper ,
@dylanTheDeveloper@lemmy.world avatar

We do a little trolling

breadsmasher , in Imagine
@breadsmasher@lemmy.world avatar

Already have ads with node / npm “looking for developers / donations / funding” messages

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