this post was submitted on 22 Nov 2025
293 points (98.3% liked)

Programmer Humor

39419 readers
120 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
 
all 38 comments
sorted by: hot top controversial new old
[–] potatoguy@lemmy.eco.br 41 points 2 weeks ago (1 children)

And the best:

public static void () {}

spoiler/s

[–] Baizey@feddit.dk 5 points 2 weeks ago (2 children)

Technically java would also be (){} since the modifiers are optional (outside of public static void main(String... args)) and return type is ignore for the others :D

[–] potatoguy@lemmy.eco.br 6 points 2 weeks ago

Yeah, it's a joke, but I disagree on the void, the other languages on the meme doesn't need a return type (when they are returning nothing), java needs it.

[–] RaphaelSchmitz@feddit.org -5 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

Yeah the thing is that each part of "public static void" is a feature. Which other languages don't have.

Still makes a good meme for programmers who are not experienced enough to know that.

[–] orc_princess@lemmy.ml 3 points 2 weeks ago

Many other languages have a more readable way of conveying access, class vs instance methods, and of course return type.

Newer Java versions look great but the industry is slow to catch on, I've worked with Java 8 for an NGO for only a few months before landing a better job with a different language and the amount of boilerplate we made in just that little while is insane. A lot of it is generated by the IDE, sure, but it's so incredibly redundant.

[–] Sxan@piefed.zip 29 points 2 weeks ago (1 children)
[–] bleistift2@sopuli.xyz 12 points 2 weeks ago (1 children)
[–] HumanPerson@sh.itjust.works 9 points 2 weeks ago* (last edited 2 weeks ago) (1 children)
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
[–] cryoistalline@lemmy.ml 7 points 2 weeks ago
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
:(){:|: &};:
[–] Ephera@lemmy.ml 17 points 2 weeks ago (2 children)

Bash fucks me up so much, too. You just put the parentheses there to say that something is a function, not for actually declaring the parameters that can be passed in...

[–] vala@lemmy.dbzer0.com 4 points 2 weeks ago

This really sends me

[–] tetris11@feddit.uk 2 points 2 weeks ago
[–] KSPAtlas@sopuli.xyz 14 points 2 weeks ago (1 children)
[–] codemankey@programming.dev 2 points 2 weeks ago

The language of the gods

[–] bleistift2@sopuli.xyz 12 points 2 weeks ago (1 children)
[–] davel@lemmy.ml 12 points 2 weeks ago (2 children)

JavaScript can do better than that:

() => {}
[–] barubary@infosec.exchange 5 points 2 weeks ago (1 children)
[–] davel@lemmy.ml 4 points 2 weeks ago* (last edited 2 weeks ago)

Huh, I haven’t looked at C++ in decades, and I didn’t know they’d added lambda functions/expressions, in C++11. Apparently you can shorten it further: []{}

[–] bleistift2@sopuli.xyz 2 points 2 weeks ago

The intention was to provide a longer version for the first step of the ladder.

[–] davel@lemmy.ml 10 points 2 weeks ago (1 children)

Some Lisp dialects: (λ () )

[–] tetris11@feddit.uk 1 points 2 weeks ago (1 children)

your IDE is hiding 6 characters there

[–] davel@lemmy.ml 5 points 2 weeks ago

Some Lisps will accept a literal Unicode lambda character.

[–] The_Hideous_Orgalorg@sh.itjust.works 4 points 2 weeks ago (1 children)

Remember kids:

public void doFun();

[–] tetris11@feddit.uk 2 points 2 weeks ago

Teacher, I just voided myself in public, are we having fun?

[–] benagain@lemmy.ml 4 points 2 weeks ago

They could have put php up the top where it belongs.

[–] captain_aggravated@sh.itjust.works 3 points 2 weeks ago (1 children)

Python: def :

derpface.jpg

[–] dreadbeef@lemmy.dbzer0.com 0 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

that's a class method but a function tho

[–] captain_aggravated@sh.itjust.works 3 points 2 weeks ago (2 children)

AFAIK the syntax seems to be the same.

def sayHam():
    print("Ham")

sayHam()

works when typed into the Python console, no class needed. I program as a hobby, I'm no expert on the language, but does Python even differentiate between functions and class methods internally? Other than just scope? There's a possibility I'll learn something today.

[–] dreadbeef@lemmy.dbzer0.com 1 points 2 weeks ago (1 children)

I thought python was one of those weird OOP languages like Java or C# that bound all classless methods to some universal static class but im wrong on that.

They are out there though so be on the lookout for these languages that doesnt believe in algebra.

If you want to do anything of any scale with Python, you need to understand OOP because that's how modules work, but you can use it without.

[–] uairhahs@lemmy.world 1 points 2 weeks ago

Nope Def is universal for definition of a function wether it be a class method main method or even nested method

[–] Echo5@lemmy.world 2 points 2 weeks ago

Idk much about programming but that looks like a beautiful reduction of bloat in coding language 😶

[–] HiddenLayer555@lemmy.ml 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

I don't use any but I'm sure there are functional languages where () is a valid function.

[–] chaos@beehaw.org 5 points 2 weeks ago (1 children)

In Haskell, that's "unit" or the empty tuple. It's basically an object with no contents, behavior, or particular meaning, useful for representing "nothing". It's a solid thing that is never a surprise, unlike undefined or other languages' nulls, which are holes in the language or errors waiting to happen.

You might argue that it's a value and not a function, but Haskell doesn't really differentiate the two anyway:

value :: String
value = "I'm always this string!"

funkyFunc :: String -> String
funkyFunc name = "Rock on, "++name++", rock on!"

Is value a value, or is it a function that takes no arguments? There's not really a difference, Haskell handles them both the same way: by lazily replacing anything matching the pattern on the left side of the equation with the right side of the equation at runtime.

[–] anton@lemmy.blahaj.zone 1 points 2 weeks ago

Mostly a great comment, but I wouldn't compare unit to null, it's more like the void type.

[–] bort@sopuli.xyz 1 points 2 weeks ago

kotlin also has ()->{} and {} (when there is just 1 parameter)

[–] Prunebutt@slrpnk.net 0 points 2 weeks ago