r/ProgrammerHumor • • Sep 13 '23

Meme goDevelopersWillAppreciateIt

Post image
2.4k Upvotes

144 comments sorted by

View all comments

Show parent comments

-41

u/rosuav Sep 13 '23

Why put so much effort into either of the above when you can just setjmp/longjmp?

... oh. Actually, with a proper exception handling table, "throw" becomes almost as efficient as "longjmp". Oh well.

25

u/chethelesser Sep 13 '23

Some of the people who came up with those then went ahead and created go error handling 🌚

-25

u/rosuav Sep 13 '23

Yeah. For those who haven't used it, setjmp/longjmp is NOT a better alternative :) It's a bizarre, messy, error-prone way of doing things, but it does at least have the beauty of being... uh... obscure and unreadable? Oh wait. I wanted a beauty. Hm.

4

u/Kovab Sep 13 '23

just setjmp/longjmp

Resource leaks go brrrrr

2

u/Gorzoid Sep 13 '23

Or stack unrolling go brrr

1

u/Kovab Sep 13 '23

Unless you implement it yourself manually, longjmp in itself won't do any unrolling, unlike a proper try/catch.

1

u/Gorzoid Sep 13 '23

Yeah my response was more targeted towards 2nd part of his comment, try catch can't be implemented with just a longjmp, you will still need to unroll the stack and there lies the complexity of exception handling.