From: "ara.t.howard" Date: 2008-06-19T14:14:09+09:00 Subject: Re: Rather validate values or use exceptions? On Jun 18, 2008, at 7:23 PM, Sam Smoot wrote: > Exceptions are _orders of magnitude slower_ than normal flow-control > structures. only when they occur - having a rescue block defined cost next to nothing on most cases. the best approach is often to *try* to use conditional structures but to still use the rescue block - but that ends up being very verbose and i'm personally no fan of the common rails pattern of using AR in such a fashion that the 'db ought to maintain integrity'. so while i totally agree with you i also see *way* too much ruby code written as unless File.exists?( pidfile ) # race condition create_pidfile pidfile which races on a normal fs and races *badly* on standard production shared filesystems like NFS. so, although exceptions might be slow, i'll take them over code that works 'most of the time' any day - although, if code is going to blow up i do like it to do so order of magnitude more quickly ;-) just my two cents on the issue - not responding to your post directly. i guess i would summarize by saying that i totally agree, but that there are *far* more exceptional behaviours in the real world that much code seems to be acknowledge. cheers. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama