632
top 50 comments
sorted by: hot top controversial new old
[-] eigenraum@discuss.tchncs.de 1 points 1 day ago

Can someone make it an async function?

[-] Klnsfw@lemmynsfw.com 1 points 1 day ago

x = printf("one + nine");

[-] ulterno@programming.dev 24 points 2 days ago

That's not even enough to get you a job these days.
You now have to use:

do {
    x = reinterpret_cast<int>(AI::Instance().ask("Do Something. Anything. Be efficient and productive. Use 10 tokens."));
} while (x != 10);
[-] Tetragrade@leminal.space 8 points 1 day ago

This isn't just a function, it's a bold restatement of what it means to write code — a symphony of characters, questioning the very nature of the cutting edge language models that I want to beat with hammers.

[-] ulterno@programming.dev 1 points 1 day ago

And for those who might not have noticedThere is 10 words in the prompt.

[-] Tetragrade@leminal.space 2 points 1 day ago

You're absolutely right! I used more than 10 words in my prompt. Cry about it.

[-] melfie@lemy.lol 6 points 2 days ago

You’re absolutely right! Who sets a variable these days without running it though a LLM?

[-] jali67@lemmy.zip 2 points 1 day ago
[-] MonkeMischief@lemmy.today 2 points 1 day ago* (last edited 1 day ago)

First, we'll deep dive into "What is a variable?", then together we'll examine "Who sets a variable?", "What is an LLM?" and finally, "Who would set a variable without using an LLM?"

You'll be a coding pro in no time!

How does that sound?

(I felt gross writing this lmao)

[-] OshaqHennessey@midwest.social 61 points 3 days ago
function myFunction() {
  try {
    x = new Random().nextInt();
    if (x != 10) {
     throw "not 10";
    }
    else {
      return (10)
    }
    catch(err) {
      myFunction()
    }
  }
}

x = myFunction()

Commit notes: Added error handling

[-] firewallfail@lemmy.world 59 points 3 days ago

Returning 10 instead of x when x finally ends up being 10 really ties it together.

[-] OshaqHennessey@midwest.social 26 points 3 days ago

I'm glad you noticed. That was my favorite part too.

load more comments (2 replies)
[-] ArbitraryValue@sh.itjust.works 84 points 3 days ago

The advantage of that last approach is that it has side effects and cannot therefore be optimized out by the compiler.

[-] ronigami@lemmy.world 11 points 2 days ago

That’s only one advantage. In theory it does not necessarily terminate, so that’s another one.

[-] joshchandra@midwest.social 1 points 20 hours ago

In ~~theory~~ hypothesis

To get pedantic, you'd have to test that out a whole bunch before even coming close to theory level, lol!

[-] moseschrute@lemmy.world 10 points 2 days ago

Probably Microsoft: You’re hired! Go work on GitHub

Context

[-] cooligula@sh.itjust.works 3 points 2 days ago

I'd say Meta hiring someone to work on WhatsApp. Man, is that piece of software crap... Every update, a new UI bug/glitch appears

[-] baggachipz@sh.itjust.works 15 points 2 days ago

It would get you promoted at Twitter, where lines of code is the productivity metric.

load more comments (1 replies)
[-] edinbruh@feddit.it 40 points 3 days ago

For a time on Reddit (some years ago when I still used it) there was a trend of finding the worst way of implementing is_even(x: int) -> bool. My contribution to that was a function that ran Ackerman(x,x) flipping a Boolean at every iteration, and check if it was true or false at the end.

It works btw, I will find the proof later

[-] uranibaba@lemmy.world 12 points 3 days ago

I would love to see the implementaion.

[-] edinbruh@feddit.it 18 points 3 days ago* (last edited 3 days ago)

The implementation is not very exciting, I capture a variable in python. It could have been done more cleanly.

1000041934

The proof is this. But, I could have made mistakes, it was many years ago.

1000041935

Note that in python you'll never be able to run is_even(5) the stack cannot handle it

Edit: daaaamn, that variable is ugly as hell. I would never do things like that now.

[-] boonhet@sopuli.xyz 1 points 1 day ago

That's , uh...

Yeah. Cooler than anything I could've achieved for purposefully bad is_even

My first idea of a purposefully bad is_even is this:

def is_even(i):
    return True if i == 0 else not is_even(abs(i)-1)

But I'm sure I could come up with worse given enough time.

[-] edinbruh@feddit.it 1 points 1 day ago* (last edited 1 day ago)

That's also slower than most of the stuff you could come up with, it is so slow that there is no hyperoperation fast enough to describe it. There were other approaches that were almost worse though, like "the function is a switch-case that returns false by default. As complaint tickets are opened, more cases get added to the switch-case"

[-] boonhet@sopuli.xyz 1 points 1 day ago

the function is a switch-case that returns false by default. As complaint tickets are opened, more cases get added to the switch-case”

Oh if that is acceptable, then my secondary idea of using an API call for this should work too. I thought that it would have to be guaranteed to be correct (as long as you don't reach a stack overflow or something)

[-] squaresinger@lemmy.world 1 points 1 day ago

It never occurred to me that you could assign fields to a function. I mean, it totally makes sense considering that functions are objects in Python. It just never occurred to me that this is a thing one can do. Crazy.

[-] edinbruh@feddit.it 1 points 1 day ago

Please don't do that, I was stupid when I wrote that. But still, in very dynamic languages like python or js everything is an object, including functions, so you can just do object stuff on them.

[-] squaresinger@lemmy.world 1 points 18 hours ago

I wasn't going to, and after I saw it it totally makes sense that it's possible, it just never occurred to me.

I guess this could be used like static variables inside functions in c. So scope-limited global variables. Not a good design choice in most cases.

[-] Mika@piefed.ca 23 points 3 days ago

I once was helping to organize the testing of town-level algorithmic competition for school students.

The competition had one entry level issue that was basically solvable by reading the question properly, recognising that it's just multiplication of two numbers, and writing the simplest app ever.

And there was one student who passed the automatic tests. We had to read the code too for the protocol, just to make sure there was no cheating.

We looked in the code. What? Why? It had two nested for loops and a++ inside. When we understood what's going on we couldn't stop laughing for like solid ten minutes.

[-] TheOakTree@lemmy.zip 3 points 2 days ago

Multiplication is just repeated addition :) glad it worked for the kid, despite the... inefficiency.

[-] Grandwolf319@sh.itjust.works 27 points 3 days ago* (last edited 3 days ago)

How about

x=x-x

x++

x++

x++

x++

x++

x++

x++

x++

x++

x++

[-] okmko@lemmy.world 8 points 3 days ago* (last edited 3 days ago)

Freshman year of college doing assembly programming, I spent a while figuring out a "programmic" way to solve a problem, trying to wrangle labels and gotos. My friend came in with essentially this but as lookup table. It blew my mind.

It was then that I learned to trade space for complexity.

load more comments (6 replies)
[-] Hirom@beehaw.org 31 points 3 days ago

The compiler will optimize it anyway. /s

[-] Dumhuvud@programming.dev 17 points 3 days ago* (last edited 3 days ago)

You jest, but you aren't wrong. At least if we are talking about C, C++ or Rust. https://godbolt.org/z/oPPfdfcf5

.NET compiler is weak when it comes to optimizing your code; I assume Go's is as bad.

load more comments (1 replies)
load more comments (5 replies)
[-] untorquer@lemmy.world 3 points 2 days ago* (last edited 2 days ago)

Something like

int *a = new int(10)

Int*b = null

While *b !=10 { b = rand(); a=new int(10)}

Return *b

I haven't coded recently enough in c/c++ to remember syntax but the concept might work eventually if you're lucky and have enough memory... Might need a time variant seed on the rand()...

[-] Atlas_@lemmy.world 9 points 2 days ago

Oddly enough, out of all of these the one the compiler has the best chance of optimizing out is the last one

[-] zea_64@lemmy.blahaj.zone 4 points 2 days ago

Not if Random writes to global state, that's a side effect that must be preserved

load more comments (2 replies)
[-] 6nk06@sh.itjust.works 15 points 3 days ago

What is the value of x in the Good example before the loop?

[-] Devial@discuss.online 28 points 3 days ago

Doesn't matter, it's 10 after the loop.

[-] BassTurd@lemmy.world 15 points 3 days ago

An int. Value doesn't matter because it's overwritten.

load more comments (6 replies)
load more comments (2 replies)
[-] irelephant@lemmy.world 4 points 2 days ago
 x = (function(){
return 10
})

Or something like that

load more comments
view more: next ›
this post was submitted on 13 Dec 2025
632 points (97.7% liked)

Programmer Humor

27882 readers
649 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