this post was submitted on 16 Jan 2024
517 points (98.7% liked)

Programmer Humor

19544 readers
728 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
 
all 13 comments
sorted by: hot top controversial new old
[–] shotgun_crab@lemmy.world 44 points 10 months ago* (last edited 10 months ago) (1 children)
[–] mrkite@programming.dev 28 points 10 months ago (1 children)

Known to cause heisenbugs. They're bugs that disappear when you try to measure them with a debugger or a printf.

[–] jaybone@lemmy.world 16 points 10 months ago

So regular bugs then.

[–] docAvid@midwest.social 29 points 10 months ago (2 children)

Weird. Booleanish isn't a built-in, I'm pretty sure. I'd like to see the definition.

[–] madkarlsson@beehaw.org 16 points 10 months ago

This looks like javascript so let me guess the typescript definition

any|unknown

this is a joke, please chill

[–] Drama_durch_Lama@feddit.de 25 points 10 months ago (1 children)

That gave me an idea: A variable that is only defined when observed by a debugger, otherwise it's null.

[–] Flipper@feddit.de 9 points 10 months ago

How about an instruction that jumps only when a debugger is attached? Cause that exists.

[–] CanadaPlus@futurology.today 4 points 9 months ago

Call me when defining it a second time makes it guaranteed false again.

[–] UnRelatedBurner@sh.itjust.works 4 points 10 months ago
[–] kubica@kbin.social 0 points 10 months ago (1 children)

Put it in an if-else and it executes both blocks.

[–] theneverfox@pawb.social 0 points 10 months ago (1 children)

Fun fact I learned today - you know how when there's a compound conditional, the interpreter stops once the result is known? (Eg, if the left side of an and is false, it's false so it doesn't bother checking the second condition)

Apparently, visual basic doesn't do this thing every other language I know of does... It might be a debug only thing for the convenience of the depreciated ide I'm forced to use, but I did a null check && called a function on it if it's not null, and it blew up

I pride myself on my ability to change to a new programming language and make progress on day one, but vb is truly the most disgusting POS language I've ever seen. From syntax to jarring inconsistencies in language design, it's just gross

[–] noli@programming.dev 1 points 9 months ago
  1. That's behaviour that's just part of language design. If you rely on it you should probably check how the language you're using handles it.

  2. relying on that behaviour sounds a lot like "clever" (read unnecessarily unreadable) code