Interesting to read that djb is in favor of automatic exception handling rather than explicitly checking return codes:
"Fortunately, programming languages can—and in some
cases do—offer more powerful exception-handling facilities, aborting clearly defined subprograms and in some cases automatically handling error reports. In those languages I would be able to write
stralloc_cats(&dtline,"\n")
or simply
dtline += "\n"
without going to extra effort to check for errors. The reduced code volume would eliminate bugs; for example, the bug “if ipme_init() returned -1, qmail-remote would continue” (fixed in qmail 0.92) would not have had a chance to occur."
Contrast this with the explicit error handling promoted by Go (and used in djb's software due to lack of exception handling in C).
That's the philosophy in Python. Instead of checking if you can do something ahead of time, just do it. If it fails, handle it then.
This results in significantly cleaner code, since you generally assume that the code you're writing is going to run correctly (e.g. that you can successfully create a directory in /tmp/ or a pidfile in /var/run).
Python, however, is also dynamically typed, which means that a lot of code is going to run even if you get unexpected input (e.g. 'print "this variable is %s" % somevar' is going to do a reasonable thing for pretty much every possible value of somevar), but it also means that your code might do something with invalid input which only makes sense if you know that your input was invalid (e.g. 'y * 10' is 20 if y is 2, or "2222222222" if y is "2"). C doesn't have that flexibility/curse, so it wasn't really an option for DJB.
"Well defined subprograms" is key here -- in a mutable language like Go, goroutines are not well-defined subprograms, so exceptions are tricky to use correctly.
Edit: I should clarify that's just speculation/personal opinion on my part. I'm not sure what djb had in mind.
"Fortunately, programming languages can—and in some cases do—offer more powerful exception-handling facilities, aborting clearly defined subprograms and in some cases automatically handling error reports. In those languages I would be able to write
or simply without going to extra effort to check for errors. The reduced code volume would eliminate bugs; for example, the bug “if ipme_init() returned -1, qmail-remote would continue” (fixed in qmail 0.92) would not have had a chance to occur."Contrast this with the explicit error handling promoted by Go (and used in djb's software due to lack of exception handling in C).