this post was submitted on 13 Dec 2025
644 points (97.6% liked)

Programmer Humor

27913 readers
2196 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
(page 2) 45 comments
sorted by: hot top controversial new old
[–] Ooops@feddit.org 6 points 5 days ago (1 children)

Wants to be Pro but doesn't even do it recursive...

[–] OshaqHennessey@midwest.social 5 points 5 days ago* (last edited 5 days ago) (1 children)
function foo() {
  x = new Random();
  case (x = 10):
    return (x);
  default:
    foo()
}
[–] anton@lemmy.blahaj.zone 3 points 4 days ago* (last edited 4 days ago) (1 children)

What unholy mix of languages is that? It is dominated by a blend of javascript and python, but with notes of something exotic. Maybe algol? or vhdl?, there is to little to tell.
Impressive, someone write up a spec and publish it to the esolang wiki.

[–] OshaqHennessey@midwest.social 5 points 4 days ago

It's an incoherent hodgepodge of C#/.NET, PowerShell, and JavaScript, each of which I've forgotten more about than I currently know

[–] ThunderLegend@sh.itjust.works 3 points 4 days ago (2 children)
[–] olenkoVD@lemmy.dbzer0.com 1 points 4 days ago

Could be Java.

[–] irelephant@lemmy.world 0 points 4 days ago (1 children)
[–] piccolo@sh.itjust.works 1 points 4 days ago

Js is Math.Random. and NextInt() is a java method.

[–] OshaqHennessey@midwest.social 4 points 5 days ago

Now write a function to unroll the while loop to "optimize it for the compiler"

[–] phpinjected@lemmy.sdf.org 2 points 4 days ago

bad but more chaotic

you want to be punk rock not blues or jazz

[–] spongebue@lemmy.world 2 points 4 days ago (5 children)

x = -i;

Do many languages let you do that? When it's in front of a variable I would've expected it to be a subtraction operator only and you would need to do x = -1 * i;

[–] squaresinger@lemmy.world 2 points 4 days ago* (last edited 4 days ago) (1 children)

Why would they not let you do that? I honestly don't know a single language that wouldn't let you do that. Same as basic math notation allows you to do that.

x = -i

is a totally valid mathematical equation.

For the downvoters: Find me a single language that supports operators but doesn't have an unary minus operator

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

It's a valid mathematical notation, sure. But there is an implicit understanding that the - in this case is making a number negative rather than subtracting (or, an implicit subtraction from 0).

With the way negative numbers generally work in binary there would be much different ones and zeroes stored behind the scenes, so handling that would have to be pretty intentional.

That said, I did just try it in Java because that's what I work in normally and I swear I had a gotcha with that. But it worked fine as far as I can tell.

[–] squaresinger@lemmy.world 2 points 4 days ago* (last edited 3 days ago)

Find me a language where it doesn't work like that, and we'll continue the discussion.

Unary minus operator is standard in every single language that I used so far, including C/C++, Java, Python, Kotlin, Lua, JS/TS, Groovy, PHP, Visual Basic, Excel, Mathematica, Haskell, Bash.

Here's more info btw: https://en.wikipedia.org/wiki/Unary_operation

[–] OshaqHennessey@midwest.social 2 points 4 days ago (1 children)

I just tested it in PowerShell. Works fine

$i = 1
$x = -$i
$x

Outputs -1

[–] squaresinger@lemmy.world 2 points 4 days ago (3 children)

Works fine in any language I ever used.

I'm honestly quite surprised that this very basic language feature is even a matter of discussion here.

load more comments (3 replies)
[–] boonhet@sopuli.xyz 2 points 4 days ago (1 children)

Personally I would expect it to behave the same in front of a numeric literal and in front of a variable. I do think most languages do that, but I haven't actually tested that many and could br wrong.

load more comments (1 replies)
[–] quilan@lemmy.world 1 points 4 days ago (4 children)

But of course -- It's just flipping around the -= operator!

[–] spongebue@lemmy.world 1 points 4 days ago* (last edited 4 days ago)

That only works if x is already 0

If i is 10 and x is zero, yes, x -= i would have a value of -10. If x was 5 from something else previously, x-=i would end with an x value of -5.

load more comments (3 replies)
load more comments (1 replies)
[–] vrighter@discuss.tchncs.de 1 points 4 days ago

it takes two instructions to materialize a constant in risc-v. X64 has LEA.

Risc-v is better!

load more comments
view more: ‹ prev next ›