Advertise here!

Ruby Can Learn From Perl

I followed an interesting link off of Tim Bray's posting, which explains the differences in Java and Perl regex performance. The original article posted by Tim Bray notes his surprise that Java actually beats Perl in terms of the performance of regexes. However, it seems that Perl is losing the benchmark because they've implemented a better way to decrease some exponential matches to linear time. So the question is, is the tradeoff worth it? And if it is, then Ruby could stand to gain from implementing something similar to Perl.

Here's a simple test case, which shows that Ruby falls in the same camp as Java - they don't handle the edge case in favor of keeping faster general regex. Run the following script and try increasing that 20 by one each run and see how the amount of time to finish increases - it's frightening.

string = ""
20.times { string << "foo "}
string << "fo"
start = Time.now
string.match(/^(\s*foo\s*)*$/)
end_time = Time.now
puts "finished in #{end_time - start} seconds"
Posted at 7pm on 11/21/05 | Posted in , , | 1 responses | read on

Death of Perl?

Given the news about Ruby and YARV, the Ruby community and the language’s vitality stand in stark contrast to some of the news surrounding the Perl community. If you take a look at O’Reilly’s graphic of relative programming language book sales, you’ll notice that Perl stands ahead of Python and Ruby (even .NET). So given the latest developments with Dan Sugalski, and the relatively long release time of Perl 6, I’m curious as to whether Perl developers will flock Ruby’s way. If you take a look at the trends that O'Reilly mentions, he notes that a few years ago the Python book market was 1/6 that of Perl. Now it’s 2/3. So there’s an obvious shift from Perl to Python. The question is: Why? Ruby would seem to be a better fit.

Obviously it would be a loss for scripting languages if all they can manage to do is to cannibalize market- and mind-share from one another. The real question and trend to look out for is the move from Java, C, C++ or C#. I don’t think that move will come all too quickly. Perhaps Visual Basic though…

Maybe, I’m overstating Perl’s demise anyhow. They did just release Parrot 0.2.2, and there’s a Perl 6 implementation underway in Haskell.

Posted at 10pm on 07/08/05 | Posted in , | 4 responses | read on