On 2010-12-03, Paul Rubin <no.em...@nospam.invalid> wrote: > Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> writes: >>> There are better ways to handle errors than Python's exception system. >> I'm curious -- what ways would they be? >> I'm aware of three general exception handling techniques: ... >> What else is there? > > The Erlang approach is to chop the application into a lot of very > lightweight processes, and let any process that encounters an error > simply crash. A monitoring process notices the crashed process and > restarts it. There is a "supervision tree" of uber-monitor processes > that restart crashed monitor proceses. I haven't programmed in that > style myself and I'm not persuaded that it's better than what Python > does, but I think it's different from the stuff on your list, which is
Erlang also offers an exception syntax almost identical to Python's for use within a single process. What makes Erlang's supervisor mode of error handling superior is that it works for more then just the current vm. If a process throws an exception, the supervisor catches and handles it. If a vm dies, a supervisor from another vm takes over. If an entire computer dies, a supervisor on another computer takes over. OTP provides some extremely advanced support for supervisory structures. > an answer to your "what else is there". I do know that they write some > complex, very high reliability systems (phone switches) in Erlang. Erlang isn't what I would call a very general purpose programming language like Python; but, if you want to build highly scalable and/or highly available systemes, there really isn't anything else that comes close to it. I am not really a huge fan of the purely functional nature of the language; but, light weight processes using the actor model is the way to go for concurrent processing. The BEAM virtual machine is also a powerful system with its ability to patch systems on the fly. It has start to become the target for other languages. I know of two that are in current developement. I wouldn't mind seeing a version of Python that could leverage the power of the BEAM vm. -- http://mail.python.org/mailman/listinfo/python-list