"Bill Kelly" <billk / cts.com> wrote in message 
news:003901c6b202$d8a10db0$6442a8c0 / musicbox...
> From: "Just Another Victim of the Ambient Morality" <ihatespam / rogers.com>
>> "William James" <w_a_x_man / yahoo.com> wrote in message 
>> news:1154045557.877418.140290 / p79g2000cwp.googlegroups.com...
>>> Roman Hausner wrote:
>>>> However, regular expression can get generated automatically
>>>
>>> Stop generating crappy regular expressions.
>>
>>    This is easier said than done.  It can be very hard to write code that 
>> can specifically avoid generating pathological regexes, especially if you 
>> don't understand how regexes work.  Indeed, it would be nice if the 
>> regexp engine can do this for you.  After all, it is the job of the 
>> programming language to make programming easier for us, is it not?
>
> Is it worth noting that the article at
> http://perlmonks.org/index.pl?node_id=502408
> indicates:
>
>  - a performance penalty is incurred for keeping track of the
>    "have we been here before" state;
>
>  - the solution doesn't cover all regexps, so some regexps
>    can still produce exponential backtracking.
>
> ?
>
>
> The Perl guys seem to feel the trade-off was worth it.  Maybe
> so.  But it doesn't seem 100% clear cut to me.

    It is not clear cut to me, either, and yes, it is worth noting that 
there are performance trade-offs.  However, the poster to whom I was 
responding dismissed it, out of hand, by blaming the programmer, much like 
the 60's auto industry blaming accidents on drivers as an excuse for not 
bothering with safety features...

    If the performance hit is great and the regex pattern uncommon, it may 
very well not be worth it.  This is, of course, debatable and that's my 
point.  Personally, I don't use Ruby to write fast programs, I use it to 
write (correct) programs fast.
    At the very least, perhaps the PERL Regexp engine can be written as a 
Ruby extension and used as another Regexp class that we "require" in our 
code when we feel it's more appropriate?  I'm a big believer in the Best of 
Both Worlds solution...