Re: Python or Perl for a Debian maintainance project?
On Monday 16 Feb 2004 1:47 pm, Andrew Suffield wrote:
> However, it results in code that throws exceptions to the user rather
> than useful error messages, which is amateurish. The user should never
> see an exception unless there is a bug in your code; errors from the
> system should be handled properly. This *does* make your code twice as
> long, but it will not make it any less readable if you do it
> right. Failing to do it is like failing to test your code before
> releasing it, or trusting data read from the network - it is not
> something that has any place in a serious program.
> "Python makes it easier to write bad code" is a pretty lousy argument.
Exceptions are a valuable programming tool, and I think your criticisms are
largely unfounded. Exceptions allow you to rid yourself of the overhead of
checking for NULLs etc inside your main logic and move the error handling
code (which is rarely part of your algorithm - checking for failed allocs in
a sort algorithm for example) out of the main code.
In Python you have:
# do some stuff
except Exception, e:
# do specific cleanup
# do cleanup
In C you have:
/* Do some complicated stuff */
if (foo == NULL)
/* Continue complicated stuff */
if (bar == 3)
/* Cleanup */
It's just another way of writing the same thing.
Personally I would not use a language that did not support exceptions for any
large scale project.
 I'm sure you can come up with examples to counter this, but they are
exceptions (get it?) rather than the rule.