this post was submitted on 20 Jun 2024
24 points (96.2% liked)

Programmer Humor

19171 readers
1452 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 15 comments
sorted by: hot top controversial new old

The best Hello World I saw used a random library. Because there's no true random without hardware, the author figured out the correct seed to write Hello World with "random" characters. I've used that to show junior devs that random in programming doesn't mean truly random.

[–] underscore_@sopuli.xyz 3 points 2 months ago* (last edited 2 months ago) (2 children)

LGTM. Though do people really code with ligatures turned on?

Edit: Ok so there are some big advocates of ligatures, I’m going to have to give them a second chance. I’ll try for a week, and either way that Fira Code font looks great.

[–] ilovededyoupiggy@sh.itjust.works 1 points 2 months ago* (last edited 2 months ago)

I was skeptical of ligatures at first, too, it took me awhile to warm up to it. But yeah, love me some Fira Code now.

[–] Luvon@beehaw.org 0 points 2 months ago (1 children)

I always do, I love having ligatures

Having ≠ looks much nicer then !=

[–] kasuaaliucceli@sopuli.xyz 1 points 2 months ago

Ah! You see, in my mind != looks nicer than ≠. Haha

[–] call_me_xale@lemmy.zip 2 points 2 months ago* (last edited 2 months ago)

As long as I don't have to maintain it.

(Who tf downvoted this? The "legacy code" lobby?)

[–] Mikelius@lemmy.ml 0 points 2 months ago (2 children)

What is that weird >>=== symbol? Looks like a cross breed between C and JavaScript here.

[–] underscore_@sopuli.xyz 2 points 2 months ago* (last edited 2 months ago) (2 children)

It’s a the right shift assignment operator so x >>= 4 right shifts x by 4 and assigns the result back to x. The code editor is displaying single double wide symbol (ligature) instead of the three character long operator >>=, I discovered today these are in fact well loved by some coders.

[–] Mikelius@lemmy.ml 2 points 2 months ago

I totally thought because of how long the equals looked, it was multiple equals characters, not just >>= lol. That's what got me confused. Don't think these are things I'd personally use but each to their own preferences right xD

[–] IsoSpandy@lemm.ee 1 points 2 months ago

Yeah.. I love them. Makes my != look like ≠

[–] EmptySlime@lemmy.blahaj.zone 2 points 2 months ago* (last edited 2 months ago) (1 children)

I guess it's a special kind of character called a ligature. They apparently are characters for combined operators. So in this case it seems to just be >>= all as one character?

[–] zod000@lemmy.ml 1 points 2 months ago

It is exactly that. Some people really like them, others do not (me included). You usually need to go a little out of your way to get a font that supports ligatures for your editor.

[–] s12@sopuli.xyz 0 points 2 months ago (1 children)

Umm… someone explain this code please?

[–] magic_lobster_party@kbin.run 2 points 2 months ago (1 children)

Bit shift magic.

My guess is that all the individual characters of Hello World are found inside the 0xC894 number. Every 4 bits of x shows where in this number we can find the characters for Hello World.

You can read x right to left. (Skip the rightmost 0 as it’s immediately bit shifted away in first iteration)

3 becomes H 2 becomes e 1 becomes l 5 becomes o

etc.

I guess when we’ve exhausted all bits of x only 0 will be remaining for one final iteration, which translates to !

[–] CanadaPlus@lemmy.sdf.org 2 points 2 months ago* (last edited 2 months ago)

Too readable. You've gotta encode the characters as the solutions of a polynomial over a finite field, implemented with linear feedback on the bit shifts. /s