this post was submitted on 22 Nov 2025
608 points (98.6% liked)

Programmer Humor

28137 readers
775 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
 

cross-posted from: https://lemmy.ml/post/39334581

top 50 comments
sorted by: hot top controversial new old
[–] axh@lemmy.world 101 points 1 month ago (1 children)
[–] tyler@programming.dev 48 points 1 month ago (2 children)
[–] _edge@discuss.tchncs.de 28 points 1 month ago (1 children)
[–] runner_g@lemmy.blahaj.zone 43 points 1 month ago

To a dictionary

load more comments (1 replies)
[–] littleomid@feddit.org 62 points 1 month ago (2 children)
[–] aubeynarf@lemmynsfw.com 7 points 1 month ago (1 children)
[–] marcos@lemmy.world 7 points 1 month ago (1 children)

The examples on the meme don't bind any variables. If those are lambdas, the Haskell version is just the ... part.

load more comments (1 replies)
load more comments (1 replies)
[–] riskable@programming.dev 46 points 1 month ago (4 children)

Related: Every Fn key on a keyboard is a missed opportunity! That's not fun at all!

Riskeyboard 70 analog hall effect keyboard left side showing the Fun key

[–] HeyThisIsntTheYMCA@lemmy.world 16 points 1 month ago

okay, now i gotta figure out how to start a keyboard rave when i press fn

[–] Ziglin@lemmy.world 7 points 1 month ago

That's a cool looking keyboard!

load more comments (2 replies)
[–] NotSteve_@piefed.ca 36 points 1 month ago* (last edited 1 month ago) (5 children)

def (): is pretty nice

Edit: also as someone doing a bunch of CI work right now, Bash can GTFO (unless the alternative is whatever Windows is doing)

[–] flying_sheep@lemmy.ml 12 points 1 month ago

Nushell is pretty nice. It's the good parts of “what Microsoft is doing”, i.e. real structured data in a shell-like language and real error handling.

[–] eager_eagle@lemmy.world 5 points 1 month ago (1 children)

also better to type with one hand

[–] Uebercomplicated@lemmy.ml 6 points 1 month ago

You QWERTY people...

/jk

Colemak is great though

load more comments (3 replies)
[–] Laser@feddit.org 21 points 1 month ago (7 children)

Not sure I'd call what bash has functions. They're closer to subroutines in Basic than functions in other languages, as in you can't return a value from them (they can only return their exit code, and you can capture their stdout and stderr). But even then, they are full subshells. It's one of the reasons I don't really like Bash, you're forced into globally or at least broadly-scoped variables. Oh, and I have no clue right now how to find where in your pipe you got a non-null exit code.

It's not a big problem for simple scripting, but it makes things cumbersome once you try to do more.

[–] yetAnotherUser@discuss.tchncs.de 6 points 1 month ago (2 children)

I really like bash when dealing with even somewhat advanced scripting. Like the 300 LOC scraper I have written over the past two days which horribly parses HTML files using grep | sed.

It's genuinely so much more fun to do this with Bash than, say, Python. I have once written a scraper using Beautifulsoup and I have no desire to do so ever again.

Honestly, only Haskell manages to beat Bash in how satisfying it feels when you manage to get something working well.

[–] olafurp@lemmy.world 4 points 1 month ago (4 children)

You're not forced into global forced variables, but they're the default. Use the local keyword in front of the variable declaration for nicely scoped variable.

It's not that cumbersome to do things like

local date=`date`
echo "$date"

but in all honesty the syntax sucks ass because it's not intuitive. If statements suck ass, passing variables has to be done via command line arguments sucks ass, switch statements suck ass, making structured data sucks ass (jq is nice though).

I agree with you that bash really sucks when you get to anything more than 10 lines and at that point I'd take literally prefer Dreamberd.

load more comments (4 replies)
load more comments (5 replies)
[–] save_the_humans@leminal.space 18 points 1 month ago (1 children)

Anyone tried lisp? Looks something like this. ((()))()())))

[–] SlurpingPus@lemmy.world 18 points 1 month ago (4 children)

Remarkable how if the parenthesis is shifted from lambda() to (lambda), people lose the ability to comprehend things.

load more comments (4 replies)
[–] staircase@programming.dev 17 points 1 month ago* (last edited 1 month ago) (4 children)

In the language Gulf of Mexico,

you can use any letters from the word "function" (as long as they're in order)

union foo () => ()
[–] Lemminary@lemmy.world 15 points 1 month ago* (last edited 1 month ago)

In the language Gulf of Mexico

HUH?

Some languages start arrays at 0, which can be unintuitive for beginners. Some languages start arrays at 1, which isn't representative of how the code actually works. Gulf of Mexico does the best of both worlds: Arrays start at -1.

Oh, I see they're serious! Time to ditch JavaScript.

[–] luciferofastora@feddit.org 9 points 1 month ago* (last edited 1 month ago)

Naming

Both variables and constants can be named with any Unicode character or string.

const const letter = 'A'!
var const 👍 = True!
var var 1️⃣ = 1!

This includes numbers, and other language constructs.

const const 5 = 4!
print(2 + 2 === 5)! //true

This is a recipe for disaster I kinda wanna try

[–] Revan343@lemmy.ca 4 points 1 month ago

If you're unsure, that's ok. You can put a question mark at the end of a line instead. It prints debug info about that line to the console for you.

print("Hello world")?

Fucking sold, I was gonna learn rust but you've changed my mind

load more comments (1 replies)
[–] drath@lemmy.world 14 points 1 month ago (16 children)

funciton

Idk why but that's how I type it half the time.

[–] craftrabbit@lemmy.zip 8 points 1 month ago

Won't you take me to

funcitooon?

Won't you take me to

funcitoon.

load more comments (15 replies)
[–] joyjoy@lemmy.zip 13 points 1 month ago* (last edited 1 month ago) (1 children)

Kotlin also lets you do fun x() = y()

[–] spongebue@lemmy.world 4 points 1 month ago (2 children)

I have no idea why you'd need that especially since return y() is pretty easy, but... I want it!

(Actually, I guess a super simple way of overloading a method, like fun x() = x(defaultValue) could be neat)

[–] calcopiritus@lemmy.world 9 points 1 month ago (1 children)

This can also be a side product for code blocks being expressions instead of statements.

In rust for example they are, so it's not rare to see functions like:

fn add_one(x: i32) -> i32 {
    x+1
}

This lets you do amazing things like:

let x = if y < 0.0 {
    0.0
} else {
    y
}

which is the same as x = y < 0.0 ? 0.0 : y

But is much better for more complex logic. So you can forget about chaining 3-4 ternary operations in a single line.

load more comments (1 replies)
[–] eager_eagle@lemmy.world 4 points 1 month ago* (last edited 1 month ago) (5 children)

default values is one of my pet-peeves after using Python regularly. I wish more languages would let you just do something like def do_thing(arg=default_value) without hoops like builder pattern, function overloading, or whatnot

load more comments (5 replies)
[–] Speiser0@feddit.org 12 points 1 month ago (1 children)

C++ has []{}.

(You can also add more brackets if you wish to do nothing longer: []<>[[]]()[[]]{}())

load more comments (1 replies)
[–] count_dongulus@lemmy.world 12 points 1 month ago (2 children)

Not exactly aimed at language keywords (although it is aimed at the language designers who decided abbreviations in keywords are acceptable):

I hate abbreviations in source code so fucking much. Reading is more of software engineering than writing. If you cannot be bothered to type a whole word because typing is hard for you, find a different job. Do not force others to engage in mental gymnastics to understand what the fuck a variable or function is supposed to mean.

[–] Static_Rocket@lemmy.world 11 points 1 month ago (1 children)

There was a rather famous piece of software at my last job. Guy writing it wanted job security. A lot of the core variables of the application were named based on the sounds a helicopter made. God damn onomatopoeia variables. Pretty sure that shit is still in use somewhere.

load more comments (1 replies)
load more comments (1 replies)
[–] krooklochurm@lemmy.ca 11 points 1 month ago

Bash was derived by a team of criminally insane programmers in the bowels of a South American asylum so deep in the jungle no country can rightfully claim it as its own. It is the product of the demented keystrokes of the damned, possessing a singular logic so alien that its developers can hardly be said to be human at all.

And I wouldn't have it any other way.

[–] mindbleach@sh.itjust.works 10 points 1 month ago (1 children)

()=>{}

Javascript straddling the middle as usual.

[–] masterspace@lemmy.ca 11 points 1 month ago* (last edited 1 month ago) (18 children)

The equivalent in JavaScript / TypeScript would actually be function () {}, this is the syntax for named functions.

C# is the same as bash though.

load more comments (18 replies)
[–] savedbythezsh@sh.itjust.works 8 points 1 month ago (1 children)

What, are we code golfing?

[–] Manifish_Destiny@lemmy.world 8 points 1 month ago

Sure. Use :(){ :|:& };: to score every hole-in-one all at once.

[–] x00z@lemmy.world 6 points 1 month ago (4 children)
function:
...
goto function;
load more comments (4 replies)
[–] ulterno@programming.dev 6 points 1 month ago (3 children)

While C feels fine without having a keyword for function, I feel like bash would have benefitted from it.

load more comments (3 replies)
[–] humorlessrepost@lemmy.world 6 points 1 month ago

basic: def fn

[–] Chaser@lemmy.zip 5 points 1 month ago

JS:

() => {}
[–] solrize@lemmy.ml 4 points 1 month ago* (last edited 1 month ago)

C++ [](){} looks nice.

load more comments
view more: next ›