this post was submitted on 27 Aug 2024
303 points (95.0% liked)

Programmer Humor

19503 readers
467 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
 
top 22 comments
sorted by: hot top controversial new old
[โ€“] sus@programming.dev 65 points 2 months ago* (last edited 2 months ago)

but sometimes "๐Ÿ‘๐Ÿฝ".reverse() == "๐Ÿฝ๐Ÿ‘"

[โ€“] SzethFriendOfNimi@lemmy.world 58 points 2 months ago (1 children)

Imagine, if you will. A world where string reverse changes the character codes of the string.

What beauty, what wonder would such a world have?

Destruction and despair. Developers unsure why their programs donโ€™t respond correctly. Ships run aground on islands already overcrowded with those who were shipwrecked before. Signal antennas pointed towards the sun with itโ€™s constant noise. Spacecraft whose exhaust melt to slag populated cities as people briefly scream their final terrors of pain and suffering.

This, is a world we should not want to live in. A world you can only find, in the Twilight Zone.

[โ€“] sukhmel@programming.dev 5 points 2 months ago (1 children)

Nah, this could've been possible with some clever fuckery in defining those emojis' unicode content, like with flags that are not a single point but three independent ones, allowing you to do this:

"๐Ÿ‡ง๐Ÿ‡ฌ".reverse() == "๐Ÿ‡ฌ๐Ÿ‡ง"
"๐Ÿ‡ฌ๐Ÿ‡ช".reverse() == "๐Ÿ‡ช๐Ÿ‡ฌ"
[โ€“] n7gifmdn@lemmy.ca 2 points 2 months ago

THANKS. I didn't get the flag joke at first @sukhmel@programming.dev

[โ€“] i_love_FFT@lemmy.ml 41 points 2 months ago (1 children)

"๐Ÿ™‚".reverse() == "๐Ÿ™ƒ"

[โ€“] jol@discuss.tchncs.de 10 points 2 months ago (1 children)

Then we need reverseX and reverseY

[โ€“] Randelung@lemmy.world 9 points 2 months ago

๐Ÿ™‚.reverseX = ๐Ÿ™‚

[โ€“] ABluManOnLemmy@feddit.nl 15 points 2 months ago

"๐Ÿ‡ฎ๐Ÿ‡ช".reverse() = "๐Ÿ‡จ๐Ÿ‡ฎ"

[โ€“] RVGamer06@sh.itjust.works 12 points 2 months ago (1 children)

Has someone made a library for that?

[โ€“] hydroptic@sopuli.xyz 45 points 2 months ago (2 children)

Use a dynamically typed language and you won't have to: just override the default reverse() method on strings like a Real Programmer!

Unintended consequences you say? Nonsense! What could possibly go wrong?

[โ€“] petey@aussie.zone 27 points 2 months ago (1 children)

Iโ€™m tempted to publish an NPM package to do so as a joke, but I fear that itโ€™d get used seriously

[โ€“] RonSijm@programming.dev 7 points 2 months ago (1 children)

Where does it end though? It's a bit like infinite craft - but instead of combining resources you'd have to find an inverse for every emoji

[โ€“] Feathercrown@lemmy.world 6 points 2 months ago* (last edited 2 months ago)
async function reverse(str){
    return ChatGPT.ask(`Please reverse the string ${str}. Reply only with the answer, without other words or symbols.`);
}
[โ€“] RVGamer06@sh.itjust.works 6 points 2 months ago

Lua could possibly do this

[โ€“] sukhmel@programming.dev 11 points 2 months ago

Yet we live in a world where

"๐Ÿ‡ง๐Ÿ‡ฌ".reverse() == "๐Ÿ‡ฌ๐Ÿ‡ง" and "๐Ÿ‡ฌ๐Ÿ‡ช".reverse() == "๐Ÿ‡ช๐Ÿ‡ฌ"

[โ€“] MrLLM@ani.social 7 points 2 months ago (1 children)
File "<stdin>", line 1
    "๐Ÿ‘‰".reverse() = "๐Ÿ‘ˆ"
    ^
SyntaxError: cannot assign to function call
[โ€“] derpgon@programming.dev 15 points 2 months ago (1 children)

It is a font that changes == to one long equals sign.

[โ€“] MrLLM@ani.social 4 points 2 months ago

Oh my bad, that idea didnโ€™t cross my mind.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'reverse'
[โ€“] Lifter@discuss.tchncs.de 5 points 2 months ago (1 children)
[โ€“] hydroptic@sopuli.xyz 4 points 2 months ago

"A".reverse() == "โˆ€"

Where is your god now?!

[โ€“] Brahvim@lemmy.kde.social 1 points 2 months ago (1 children)

What's with the lines of both equals symbols being combined together haha?

[โ€“] hydroptic@sopuli.xyz 0 points 2 months ago* (last edited 2 months ago)

That's known as a ligature and they're pretty common in many programming-oriented fonts, which usually have stylistic sets with different ligatures for different programming languages that you can optionally enable in your editor's configuration. For example, here's the stylistic sets the Monaspace font offers:

Personally I'm not too fond of ligatures so I never enable any, but many folks do like them.

Edit: and just as a side note, ligatures are super common in many fonts, you just might not notice them. Here's some classic examples from the DejaVu Serif font, with and without a ligature: