[BangPypers] Do you think a more declarative RE syntax would make the world a better place ?

Noufal Ibrahim noufal at gmail.com
Mon Aug 9 14:08:20 CEST 2010


[...]

> Does anyone think something of this sort would be of wider use? Do you
> know already existing packages that can do it? What are the
> limitations that you see to this approach? Does anyone think, having
> the declarative string in code, would make it more maintainable?

[...]

I don't want to rain on your parade but I don't think this will be
useful. 

Regular expressions are mathematically sound ways of representing state
machines. They unambiguous and clean. They were brought into the whole
"programming" universe as a tool to do text processing and then
unleashed upon the unwashed masses leading them to use it for everything
from looking for a string in a file to parsing XML. The problem now is
that we have too much of this line noise in our programs and there have
been efforts to "clean it up" by using more "readable syntax". There was
even one floating about a few months ago which used XML to describe
regexps. I don't want to try to write an example. 

One of the things about regular expressions which makes them powerful is
their brevity and compactness. This of course leads to sometimes
unreadable code, abuse etc. but all of those are discipline issues which
should be addressed by simply using less regexps and using other things
which are more suited to the task (plain string indexing, parsers etc.).

I think an attempt to create a more "friendly regexp format" which is
more readable is going the way of COBOL with it's "ADD 1 to X" rather
than x+=1.

However, it's an interesting idea to make this work. I'd like to do the
reverse. Given a regexp, break it down into English for me so that I can
figure out what it's trying to do quickly.

-- 


More information about the BangPypers mailing list