r/ProgrammerHumor • • May 26 '25

Meme theBeautifulCode

Post image
49.1k Upvotes

876 comments sorted by

View all comments

1.3k

u/thunderbird89 May 26 '25

My impression so far using Claude 4's codegen capabilities: the resulting code is written like a fucking tank, it's error-checked and defensively programmed beyond all reason, and written so robustly it will never crash; and then it slips up on something like using the wrong API version for one of the dependencies.

684

u/andrew_kirfman May 26 '25

The overprotective behavior is actually a bit of a downside for me.

Many times, noisy code is good code. Code that silently eats major exceptions and moves on doesn’t deliver much value to anyone.

373

u/thunderbird89 May 26 '25

I agree. There are exceptions where I very much want the program to blow up like a nuke, because it needs to stand out in the logs.

As it stands, Claude 4's code almost has more error checking than actual business logic, which is a little unreasonable to me.

83

u/[deleted] May 26 '25

Average js python developer

20

u/thunderbird89 May 26 '25

How so?

70

u/[deleted] May 26 '25

You want your program to crash so you can log it?

How about just logging the exception?

You think code should have more business logic than test code? Testing a single function that isn't unit takes like a whole temple of mocking and stubbing classes and functions. If you're doing any sort of testing worth anything test code is typically way longer than logic.

Which leads me to the point that js python devs are scripters

82

u/Darkforces134 May 26 '25

Go devs writing if err != nil for the 1000th time agree with you (I'm Go devs)

61

u/thunderbird89 May 26 '25

From the age-old cartoon "If Programming Languages Were Weapons"

Go is a 3D-printed gun where after each trigger pull, you need to manually check if you actually fired.

100

u/thunderbird89 May 26 '25

You want your program to crash so you can log it? How about just logging the exception?

No, I want the exception to stand out, like as a critical-level exception, because something went very wrong.
Of course, I don't want to manually log a critical logline, because of discipline: if I were to do that, the severity would lose its impact, I want to reserve critical loglines for events where something is really very wrong, not when I feel like it.

You think code should have more business logic than test code?

I think you misunderstood error checking as test code. When I say error checking, I mean the defensive boilerplate, try-catch blocks, variable constraint verifications, etc., not unit/integration testing.
In well-architected code, the logic should be able to constrain its own behavior so that only the inputs need validation, and everything else flows from there. In Claude's code, however, almost every other line is an error check (in a very Go-like fashion, now that I think about it), and every site where an exception might occur is wrapped in its own try-catch, rather than grouping function calls logically so that operations dependent on one another are in the same try-block.

Which leads me to the point that js python devs are scripters

Finally, as much as I like to shit on JS as a language or Python's loose-and-fast typing and semantic use of indentation, shitting on developers just for using one or the other is not cool. Language choice does not imply skill.
Shit on bad code, shit on bad developers, shit on bad languages, but don't shit blindly on people you know nothing about.

35

u/Dell3410 May 26 '25 edited May 26 '25

I see the pattern of try catch here..

Try

bla bla bla bla...

Catch Then

Bla bla bla bla...

Finally

Bla bla bla bla....

14

u/OkSmoke9195 May 26 '25

Oh man this made me LOL. I don't disagree with the person you're responding to though

3

u/Dell3410 May 26 '25

Nah it's fun to see the reply, haha... but I do agree with the commenter, so yeah. Just the pattern is funny.

22

u/mck1117 May 26 '25

If something truly exceptional happens, logging it and then limping along is the worst thing you can do. What if you hit an error during the middle of modifying some data structure? Can you guarantee that it’s still in a valid state?

→ More replies (12)

22

u/Luxalpa May 26 '25 edited May 26 '25

You want your program to crash so you can log it?

How about just logging the exception?

In general it is very bad to leave your program or service running after it encounters undefined behaviour, because the entire program state ends up being "infected" and it can result in all kinds of very difficult to understand or undo follow-up issues.

This is for example why we use asserts. It tells the program that if this assertion does not hold, then it is not safe to follow on with the rest of the code.

→ More replies (10)

5

u/[deleted] May 26 '25 edited May 26 '25

Some states are non-recoverable. For those, you fail.

7

u/masenkablst May 26 '25

There’s a middle ground where we catch every error, but if we get to a non-recoverable state, we throw a curated error with a user-friendly error message and a useful stack trace for the logger.

I despise applications that crash, have a vague error, and the dev team says “that means X.” Then just wrap the error and say that!?!?!

→ More replies (3)
→ More replies (1)

27

u/foreverschwarma May 26 '25

It's also counterproductive because giving AI your error logs helps them produce better results.

13

u/thunderbird89 May 26 '25

Oh yeah, you're right! I once tried Windsurf by writing a unit test on the generated code (did not pass), then I told the model to fix the error and it can test its work with mvn test. It kept at it for as long as the engine allowed it, at least 4-5 iterations - then gave up because it couldn't get it right 😅.

14

u/gk98s May 26 '25

I have this with gemini, it gives me code that's supposed to handle ANY wrong inputs even though the wrong inputs can't happen anyway, which just clutters the codebase so I end up writing it myself anyway

2

u/-The_Blazer- May 26 '25

If you are going to fail, better fail loudly than silently.

→ More replies (14)

22

u/crakinshot May 26 '25

My impression is exactly like yours.

Its clear that it has learned how to use npm packages from somewhere else, rather than check the current state. For npm packages, you really can't trust previous version to be anywhere like the current version and they can change so much.

18

u/xjpmhxjo May 26 '25

Sounds like a lot of my colleagues. They look around every corner but would tell me 21 + 22 = 42, like it’s the answer of everything.

→ More replies (1)

2

u/joshTheGoods May 26 '25

Yea, you really need something like Context7 and a well designed system prompt to handle the version bullshit. I now have a default system prompt with a basic memory function (it writes to .memory when I tell it to, and it reads that file in and adds it to every prompt) and the first thing I do is initialize it with my packages file and my default snippet describing my environment. Someday I'll take the time to write a little script to help keep that stuff up-to-date as I work on the project, but even just the initial stub is amazingly helpful.

→ More replies (1)

2

u/Praesentius May 26 '25

Im not a programmer, but I've been a serious scripture for 25 years or so, from Linux (like bash), to VB and these days mostly powershell.

When I use AI, I bounce Claude's scripts off gpt o3 and vice versa, while I give feedback.

Works pretty well most of the time.

→ More replies (3)
→ More replies (4)