Hacker News new | past | comments | ask | show | jobs | submit login

There's a number of programmers who really seem to dislike exceptions: Joel Spolsky and Rob Pike among them.

This discussion always seems really weird to me, because I've been using exceptions for about 15–20 years now, and my experience has always been: 1) my code looks much nicer, 2) my code is far easier to make correct, and 3) exceptions give me no trouble whatsoever. Honestly, I experience 10x as much pain from the _for_ loop as I do from exceptions, for crying out load!

Maybe if I had spent more of my like working with particularly ugly Java systems, then I might feel differently. But when using C++, Lisp, Dylan, Schema, Python and Ruby, exception handling has always been completely painless. Well, in C++, you need to use RAII, and sometimes you need to write WITH-OPEN-FILE or File.open {|f| ... }. But this is an order of magnitude easier than making explicit error-handling correct.

In fairness to Go, exception handling is much trickier when you live in a world of lightweight co-routines. But again, Erlang seems to generalize things in a plausible way: Declare links between co-operating processes, and propagate failures across those links until somebody wants to catch them and recover.

It looks like Go is slowly moving in that direction. But in the meantime, writing Go programs always leaves a sour taste in my mouth—I really don't want error-handling code gunking up my programs like that.




"There's a number of programmers who really seem to dislike exceptions: Joel Spolsky and Rob Pike among them."

Additionally, the Google C++ style guide forbids the use of exceptions.


Also Haskell seems to discourage exceptions. They are possible to raise everywhere and catchable in the IO Monad --- but they do not play along nicely. It's often better to wrap up your error handling in a Maybe or Either or Error Monad. (In level of increasing sophistication.)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: