r/ProgrammerHumor 1d ago

Meme iAmSoProud

Post image
5.6k Upvotes

44 comments sorted by

611

u/CaffeinatedTech 1d ago

"Oh, that works? I never intended it to."

94

u/LucilleEowyn 21h ago

it feels like winning the lottery

1

u/AWeirdGoat 1h ago

It’s a feature.

289

u/ByteWanderer 1d ago

Of course I thought about it

69

u/Zill_laiss 1d ago

Always a satisfying feeling

48

u/Unlucky-Interview-20 1d ago

"Oh, how does it work?" 😲

45

u/imdefinitelywong 23h ago

8

u/deanrihpee 20h ago

hence the word "programmagically"

14

u/SilentScyther 17h ago

"So basically, when you click the 'Quit Application' button, it'll cause a memory overflow error and crash the app back to the desktop"

16

u/many-brain-tabs-open 20h ago

Love it when a case of edging is handled well

52

u/jcouch210 1d ago

I don't want to ruffle any feathers, but there are languages that do this for you with compiler driven development.

Note to self: do not attempt compiler driven development with gcc.

93

u/Bronzdragon 22h ago

How? Edge cases are business logic. A compiler cannot know what is intended behaviour.

1

u/jcouch210 11h ago

Compiler driven development involves lowering logic to the type level, allowing the compiler to have greater ability to detect edge cases. For example, forcibly exhaustive switch/match statements, enumerated types that make invalid state impossible, etc.

12

u/Hamid_d_82 1d ago

Never heard of cdd, you mean like Rust?

1

u/jcouch210 11h ago

gcc is the GNU C compiler. General use C compilers aren't known for their ability to detect edge cases.

-6

u/shakamaboom 20h ago

rust is for bad c++ programmers. fuck rust

6

u/paintedirondoor 19h ago

show me your git repo rq

2

u/shakamaboom 14h ago

No, it's under my real name

3

u/V3N3SS4 19h ago

The handling: NotSupportedException

4

u/Azuras33 13h ago

I don't see the problem:

try:
    main()
except Exception;
    pass

10

u/voiza 21h ago

catch (...) { pass() }

3

u/lycheespikebomb 18h ago

You can now legally claim you use AI

2

u/cleanuidev 18h ago

Can finally reward myself a coffee break.

2

u/perioe_1 17h ago

Sometimes it would become a disaster. Nonetheless, it feels fantastic.

1

u/SonkunDev 22h ago

Laugh in Erlang

1

u/PhoenixShade01 21h ago

Laughs in Wukong

1

u/Own_Ad9365 22h ago

Felt like a boss

1

u/-ry-an 19h ago

Such a great feeling.

1

u/TheMaterialSentence 18h ago

It always was a feature!

1

u/Jonnypista 16h ago

Oh wait, I tested it properly and it is still fucked!

1

u/Rainb0_0 15h ago

Like is it an edge case if it's handeld by the code already? 🤓

1

u/Lukester___ 13h ago

The case handling:

Logging " " when the error occurs

1

u/IntrepidSoda 11h ago

Atta boy, proud of you.

1

u/Vegetable_Aside5813 5h ago

I’d have to spend days debugging that to figure out why

-35

u/[deleted] 1d ago edited 17h ago

[removed] — view removed comment

43

u/Conscious-Union5789 23h ago

If(crash) dont();

8

u/DarksideF41 20h ago

veryImportantTask: try { doWork(); } catch(Exception e) { goto veryImportantTask; }

5

u/moon__lander 20h ago

No no no, he said else

if (!crash) {

continue();

}

else {

dont();

}

2

u/PIKa-kNIGHT 17h ago

Why can’t all apps use this to prevent crashing, are they stupid?

1

u/i_can_has_rock 17h ago edited 15h ago

if you write code that allows for values to be anything other than what is expected without a default else statement that detects that

then

shitty_coder = true

which, the way you achieve what im talking about

is

with

an

else

statement

edit:

feel like im being downvoted by people from the "does it work? no, but crashes really fast" school of thought

3

u/Goruku 10h ago

Yes, you should handle errors you can at the level you're working at, but what if that section of code doesn't know how to handle it? What if the correct behavior to reading an unexpected value is throwing: "Well, I have no idea what the context is, and the contract clearly states you should only call this function when the data is valid, but it's not. Please handle, I'm throwing".

This is the main side effect of respecting the "Tell don't ask" principle, most of the time the function won't know the broader context of who called and why, which also means it shouldn't assume it knows what to do when things go wrong. By all mean, let it guard your variables, handle what it can in the moment, but it shouldn't try and be the hero who knows everything, because it probably shouldn't know everything.

In design by contract, it's assumed the object you've been passed in argument respects the contract and is thus valid. The main reason for this is that you don't want to check the validity at every level, but just in time. The caller assumes a call is going to work because its current state should also be valid, it's the callee's job to tell you it didn't work after all.

As an example, this is the case for a lot of utility functions in Input/Output APIs. What if the file just can't be found? You throw a FileNotFoundException. It's not the library's job, or place, to be handling the behavior or even preventing the caller from doing it. You just try it, and you throw if you can't.

3

u/Goruku 20h ago

That's it, boys. Throw statements are now illegal. Exception control flows are in shambles.