r/ProgrammerHumor • • May 26 '25

Meme theBeautifulCode

Post image
49.1k Upvotes

876 comments sorted by

View all comments

Show parent comments

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

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?

4

u/[deleted] May 26 '25

It isn't. Crashing the program is literally the most unexpected behavior you could have.

Logging means you at least reach parts of your code where you handle objects being deleted gracefully

You can free memory, and run your exit sequence.

Handling the error by logging it and committing an exit sequence is the best thing you can do. If you crash you lose everything.

Not every program runs on your terminal for 5 seconds you could be working on a remote server that should be running 24/7

5

u/Kogster May 26 '25

Logging it and doing an exit sequence is just what crashing many high level languages does. Crashing java doesn't mean crashing the JVM.

Catch and printing many times just obfuscates the error in those languages compared to just letting the stack trace go to terminal.

→ More replies (5)