Linked by Thom Holwerda on Fri 10th Sep 2010 14:59 UTC
General Development Python programmers shouldn't get too smug. While many people agree that Python is designed in a way that makes it a highly readable language, there can still be problems with legacy, untested Python code too. Porting legacy Perl to Python can be a daunting task. In this article, learn some of the theory behind dealing with legacy code, including what not to do.
Thread beginning with comment 441168
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[4]: Why would I want to do it?
by sreque on Wed 15th Sep 2010 16:39 UTC in reply to "RE[3]: Why would I want to do it?"
Member since:

Don't be so harsh on ruby! In ruby, the perl-like regular expression syntax is just syntactic sugar for using the Regexp class, which looks and feels like any other class in the language. In fact, if you wanted to, you could instantiate and use regular expression objects in ruby just like you would in python. No one usually does this, though, because the sed/awk/perl-like syntax for regular expressions is actually very convenient and helpful. I think this actually gives us the best of both worlds, because the language is still clean and consistent.

This stands in contrast to perl in many ways. For instance, in perl, if you want to assign a regexp to a variable you have to use the qr() syntax, which actually is much less convienent than the normal syntax for creating a regular expression. In ruby, you can just write something like:

re = /my_regular_expression/

which is just syntactic sugar for a properly string-escaped version of:

re ="my_regular_expression")

Reply Parent Score: 1