r/programminghorror • • 7d ago

Leider wahr

Post image
1.1k Upvotes

70 comments sorted by

170

u/avast_ye_scoundrels 7d ago

That is the most expensive code I’ve ever seen.

37

u/Vladislav20007 7d ago

with the sole of exception of the code that kills prod for 3 days

25

u/csabinho 7d ago

3 days of no service might be cheaper than consistently using this code.

2

u/Vladislav20007 7d ago

with how ai is going, the tokens spent in downtime might just outscale the tokens used here.

2

u/QuickSilver010 5d ago

"reboot the server pls" moment

1

u/StarboardChaos 7d ago

I mean, can't you just roll-back prod to previous release?

8

u/BurningPenguin 7d ago

Easy solution, just host the model locally and watch your PC fan take off when it loads the 500 billion parameters.

2

u/A1oso 7d ago

Now imagine using this function to give every odd row in a list a slightly darker background color.

25

u/No-View-6326 7d ago

Does it even work, wouldn't the llm just say "say 7 is indeed an odd number" you can't cast that into a boolean

17

u/survivalking4 7d ago
bool("7 is indeed an odd number")

> True

I see no problems here.

1

u/StuxAlpha 4d ago

Now we just need a compiler that can recognise this, optimise away the LLM call entirely, and therefore the function

14

u/JustAppleJuice 7d ago

This is where a decision model like Jev comes in, that predicts what boolean matches best with the output.

15

u/W00GA 7d ago edited 7d ago

noodles

4

u/Blerbederp 7d ago

Don’t noodles

-3

u/W00GA 7d ago edited 7d ago

wtf is the blue clickable button top right of my reply that changes me reply text???

wtf

edit:

appears to be some translation bs

0

u/csabinho 7d ago

I don't see any blue clickable things.

1

u/W00GA 7d ago

thank you for info.

ive never seen it before

when i click it it changes my reply from "lol". to "laugh out loud"

as an experiment i edited my reply to say "noodles"

and now the blue clickable thing does. nothing.

2

u/SSUPII 7d ago

Your comment got detected as a different language from your own, so it makes translating available.

0

u/W00GA 7d ago

wot language is "lol"

im joking

ty

that makes sense

37

u/theChaosBeast 7d ago

Coding has lost all its attraction to me....

14

u/2eanimation 7d ago

Unless it’s your job and you’re in some way required to use AI, you don’t have to jump on the vibe code train. I have a no-AI policy with my projects. Call it recreational programming. It might still be slop, but it’s human slop :)

4

u/asmanel 7d ago

What about coding the old way ?

10

u/theChaosBeast 7d ago

Well I Code at work, and there if you don't use Claude, you fall behind.

1

u/userrr3 6d ago

Stop eating up their lies and FOMO.

1

u/xupl 7d ago

For me too for a while, I think it was the friends we made along the way and learning, which we require now more than ever, when it seemingly disappeared. I do have to write code like a "primate" for work though, may not install any agents into the virtual machines (yet). Which is a cool escape from the reality outside.

17

u/sojuz151 7d ago

You have never seen a real production code. Where are metrics, validations of input, retries, providers and logs? I know a couple of people who would make that into 200 lines of code over 4+ files.

4

u/csabinho 7d ago

I once had 100 lines of inline HTML code in PHP, repeated 5 times with minor changes, and no code formatting of course. And I had to change something consistently.

8

u/Feuzme 7d ago

Someone stayed 3 years back ?

8

u/Dee4WasTaken 7d ago

return (num % 2 == 1);

4

u/maelstrom071 7d ago

Even simpler, num & 1

3

u/I-am-fun-at-parties 7d ago

if that works, any decent compiler will already optimize (num%2) to that. and for two's complement negatives, it does not work. better leave it to claude.

1

u/Wild_Meeting1428 7d ago edited 7d ago

what does not work? num & 1 will work but not (num % 2 == 1) but (num % 2 != 0) will:
https://godbolt.org/z/5z7ezKhvz

1

u/I-am-fun-at-parties 7d ago

Uh? It's in your own code:

std::println("{}", implicit_cast(-3 % 2 == 1)); --> false
std::println("{}", implicit_cast((-3 & 1) == 1)); --> true

So -3 is even or odd, depending on what you do.

but not (num % 2 == 1) but (num % 2 != 0) will:

in C, those two are exactly identical, since a bool will, as an int, evaluate to 1 or 0.

1

u/Wild_Meeting1428 7d ago

they are not identical, not even in C ... .

1

u/I-am-fun-at-parties 7d ago

enlighten me then?

2

u/Wild_Meeting1428 7d ago

the result of -3 % 2 is an integer, in C AND C++ the result will be -1, not 1, comparing it for equality with 1 will return false in C++ and 0 in C, even if its odd. Thats why it is not working (removing the explicit bool conversion fixes it actually). Comparing it for inequality to 0 will yield the desired result; true and 1. The result is equal to the bit manipulation, beside the fact, that bit manipulations on signed types are implementation defined in C++.

1

u/I-am-fun-at-parties 6d ago

Fair enough, you got me. I had forgotten the negative modulo semantics.

1

u/csabinho 7d ago

That's the cheap and easy way.

1

u/Ben-Goldberg 7d ago

Why not return num % 2 directly?

2

u/Wild_Meeting1428 7d ago

implicit bool casts are discouraged

2

u/I-am-fun-at-parties 7d ago

"are discouraged".

like, universally. okay.

1

u/Anubis17_76 1d ago

As with humans, being explicit with machines yields more predictable results

1

u/I-am-fun-at-parties 1d ago

it's not even a cast, and it's humans that have trouble figuring out an implicit conversion, machines do not.

1

u/Anubis17_76 1d ago

and as we know, once you write code you never look at it again

1

u/Ben-Goldberg 1d ago

What subreddit are we in?

1

u/JohnVonachen 5d ago

Return (num % 2 !== 0)

4

u/Fekkin-A-Man 7d ago

*nobody* (except some obscure video game dev) wrote code like that in 2022.

4

u/Mordicant85 7d ago

Hey, he worked at Blizzard for 7 years

1

u/Zakreus 5d ago

A small indie company

1

u/Imab0zo 6d ago

Can’t you just use division

2

u/Le0p0ldi 2d ago

Yes you can. But that’s not the point of what’s meant in this meme.
But smart answer

2

u/latkde 7d ago

Nowadays you're supposed to use the /responses API instead of /chat/completions, and use structured outputs instead of allowing free-form responses.

2

u/WolfOfYoitsu 7d ago

Aus dem Augenwinkel hab ich jetzt erwartet dass nur die Liste aller ungeraden Zahlen geladen wird. GPT enttäuscht mich jetzt

2

u/SirFoomy 7d ago

Both examples are dump AF.

2

u/realmauer01 6d ago

No need for that, just use import "is-even-ai"

2

u/HTTP_Response_404 7d ago

I though about this, actually. I see a future where some hyper-complex aspects of a program are not written as code at all and instead just llm API calls, especially for smaller projects with only a few users and that needs judgement. But obviously, this is stupid.

I love it.

2

u/TorbenKoehn 7d ago

Hahaha AI amirite?

1

u/ZunoJ 7d ago

The development of a braindead moron over time

1

u/asmanel 7d ago

Once, long ago, a date system that up beyond the end of 1999 was judged impossible by many coders.

To fix it was an huge an often painful work.

Today, make a program that works without an internet connexion to an huge AI site is impossible to many coders. There is no solution is the service cease working.

Senior"s code work faster ? The use the AI a more optimal way.. This code work without acxess to the AI ? No way, this is impossible. Check it is out of questi an if it work, this mean there is stiil cooected to th AI.

1

u/Amazing-Switch-7163 7d ago

Nice, worst case of O($).

1

u/Ambivalent-Mammal 7d ago

I love the addition of 'Make no mistakes.' I guess the default is some mistakes.

1

u/kyr0x0 7d ago

export const isOdd = (n) => Boolean(n % 2)

Most readable short form btw

1

u/coyote_den 5d ago

n&1 will be even faster.

1

u/kyr0x0 5d ago

Well, that's a different metric then

1

u/softgripper 6d ago

"You are an odd number expert and have been studying odd numbers for years. Make no mistakes"

1

u/Doorda1-0 2d ago

They both suck... 2022 had far better solutions

1

u/Dynospectrum 1d ago

Maybe you wrote code like that in 2016 but those of us who are sane would just do return num % 2

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" 7d ago

This really belongs in r/ProgrammerHumor. If they aren't sick of it, that is.

0

u/Drate_Otin 7d ago edited 7d ago

You folks are obsessed.

Has it not occurred to any of you that you can use AI to learn? You don't have to let it do the job for you to get a return on investment out of it. Ask it HOW to do things you've never tried or thought about before, learn the technique, teach it how you best ingest information... And then you implement what you learn.

Y'all seem to think there's nothing between no AI and letting AI do everything.

2

u/Dominiczkie 7d ago

TechSavvyLife fr checking for odd numbers with if statements, Yandere Simulator ass coding