this post was submitted on 02 Oct 2024
603 points (96.2% liked)

Programmer Humor

26799 readers
1925 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 2 years ago
MODERATORS
 
top 37 comments
sorted by: hot top controversial new old
[–] Bougie_Birdie@lemmy.blahaj.zone 23 points 1 year ago (2 children)
[–] corroded@lemmy.world 21 points 1 year ago

Meanwhile, "~x" is drooling on itself over in the corner.

[–] FilthyShrooms@lemmy.world 14 points 1 year ago

Who's on first, Not on second, and not who's up to bat

[–] kewwwi@lemmy.world 11 points 1 year ago
[–] jlh@lemmy.jlh.name 4 points 1 year ago (3 children)
[–] Takios@discuss.tchncs.de 2 points 1 year ago

What do you want?

[–] puppy@lemmy.world 2 points 1 year ago (1 children)
[–] jlh@lemmy.jlh.name 3 points 1 year ago (1 children)
[–] jaybone@lemmy.world 2 points 1 year ago
[–] tee9000@lemmy.world 1 points 1 year ago

Five questions.

[–] obosob@feddit.uk 3 points 1 year ago (1 children)
[–] OpenStars@discuss.online 13 points 1 year ago (1 children)
[–] lugal@sopuli.xyz 1 points 1 year ago (1 children)
[–] OpenStars@discuss.online 1 points 1 year ago

The one who is neither not-x nor not that not-x.

[–] Oka@sopuli.xyz 1 points 1 year ago

He is MI and I am Yu

[–] dosuser123456@lemmy.sdf.org 1 points 1 year ago

the x is not not x but is also not the nand x but x is not xnor, and or x of the x

[–] Ephera@lemmy.ml -5 points 1 year ago (8 children)

Alright, spicy opinion time: I think, the ! operator is dumb.

It's yet another symbol with a meaning, which people have to learn.

And it's easy to overlook, especially in languages with parentheses in their if-conditions:

if (!list.isEmpty()) { ... }

I think that just a .not() method on Booleans is cooler:

if (list.isEmpty().not()) { ... }

You can do this in Rust, which is where I have that idea from: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=dedb71bd84243c78ee0afad0f30b80c3

[–] DarkenLM@kbin.earth 27 points 1 year ago (1 children)

Mathematics themselves are essentially tons of symbols that people have to learn, tbf.

I personally never had any trouble looking at the negation operator, and find the .not() postfix cumbersome.

[–] MBM@lemmings.world 4 points 1 year ago (1 children)

To be fair, mathematics also uses single-character variable names

[–] DarkenLM@kbin.earth 4 points 1 year ago (1 children)

~~Laughs~~ Cries in engineering

[–] dosuser123456@lemmy.sdf.org 1 points 11 months ago

actually names his variables "x, y, z, etc etc" when coding

[–] yetAnotherUser@discuss.tchncs.de 18 points 1 year ago* (last edited 1 year ago) (1 children)

I dislike the .not() method a bit because it inverts the meaning of the previous code snippet you've read.

if (list.isEmpty()...

"Ah, so if the list is empty..."

if (list.isEmpty().not())

"Goddammit"

[–] Ephera@lemmy.ml 7 points 1 year ago

For me, it's pretty much the opposite. With the exclamation mark, I'll see the inversion, then I'll read the actual condition and try to make sense of it, and then I'll remember that this thing was supposed to be inverted. Or I won't remember, that's unfortunately also a possibility.

Might just be what we're used to, though. I have been working in a codebase with mostly .not() for the past year.

[–] TheRealKuni@lemmy.world 17 points 1 year ago (3 children)

We use ! because keyboards no longer have buttons for ¬, which is the other logical not.

[–] Zagorath@aussie.zone 4 points 1 year ago

We could have used the tilde, which has been used in formal logic & maths for negation in very many contexts for a long time.

It's used instead in C and many C-like languages for the far less useful bitwise negation. Of course, we could have had it work in the same way as bitwise vs logical and & or, by dialling up the symbol. Which would have massively improved its visibility compared to the bang.

But for some reason, no. They chose the bang instead.

[–] Deebster@programming.dev 4 points 1 year ago (1 children)

My (ISO) keyboards do, under the Esc key. I guess you're in North America (or Australia) and have an ANSI layout.

[–] TheRealKuni@lemmy.world 3 points 1 year ago

Ah, yep. I have very little knowledge of keyboards in other parts of the world, unfortunately.

[–] Ephera@lemmy.ml 0 points 1 year ago

Oh, I know where it came from. That's also why we have all kinds of maths operators in the syntax of virtually any programming language. Because back when we didn't yet know where this programming thing was going, we just threw in the conventions of maths and theoretical logic.

What I'm saying is that we have our own conventions now, i.e. objects and methods, so I think, it's worth reconsidering whether we still want to have these old conventions that are special cases in the syntax.

[–] rockSlayer@lemmy.world 12 points 1 year ago

It's ok for symbols to have different meanings in different contexts. If someone is new to the context, they should research or ask about it. People that are familiar should provide the mutual understanding, provided they have the will and ability to educate.

[–] palordrolap@fedia.io 12 points 1 year ago (1 children)

The ol' postfix 'not'. Wayne's World is a thing of the past! ... NOT

[–] OpenStars@discuss.online 4 points 1 year ago

No way dude!

img

[–] petersr@lemmy.world 4 points 1 year ago (1 children)

Would you say that it reads better as "not x" or "x not" (if we remove all special characters)?

[–] Ephera@lemmy.ml 2 points 1 year ago

I mean, that is more obvious and more readable.

But what I really don't like about it, is that it's less clear to what it applies. For example:

not list.isEmpty() and x > 3

Is that not (a and b) or (not a) and b?
Obviously, you can define precedence rules, like there also is for !, but that's again just additional things to learn.
I'm definitely not generally opposed to special characters. I do also hate significant whitespace, because I find that less readable than braces.

[–] MaggiWuerze@feddit.org 1 points 1 year ago

Kotlin has not, and, and or utility functions as well

[–] xigoi@lemmy.sdf.org 1 points 1 year ago

You’re so close to reinventing Smalltalk…