I'm going to try something new here. Normally when I write a post, I think through everything that I want to say before I start writing. But I think I'm going to just shoot from the hip on this one and see what happens. Since I'm just writing this as I'm thinking about it, the end result may be brilliant or it may be senseless drivel that will make you dumber by reading it - Proceed with caution.
I was just reading Joel Spolsky's argument against programming with exceptions, and I'm inclined to agree with him.
A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly, no matter how verbose it might be. It is true that what should be a simple 3 line program often blossoms to 48 lines when you put in good error checking, but that's life, and papering it over with exceptions does not make your program more robust. I think the reason programmers in C/C++/Java style languages have been attracted to exceptions is simply because the syntax does not have a concise way to call a function that returns multiple values, so it's hard to write a function that either produces a return value or returns an error.
While I completely agree with this, I think one could argue that we do have a way of returning multiple values: Pass-By-Reference.
Click to read more ...