D
Daniel Carrera
Hi all,
I guess I just want to share a tiny "case study" from a project that I'm
doing in Python and which I wish I could do in Ruby instead.
I am writing a BibTeX filter for the OpenOffice project (BibTeX is the
bibliographic cousin of LaTeX). I am doing it in Python because, of the
languages with stable bridges to the OOo component model (UNO) Python is
the one I like best.
My requirements are mostly related to regular expressions and string
methods. This is an area where Ruby really shines and is light-years
ahead of the competition.
Regular expressions in Ruby are infinitely eaiser and more sensible to
use than in Python.
Ruby:
str =~ /^(#{char})\s*{\s*(#{char}+),(.*)}/
Python:
regex = re.compile(r"^(" + char + "+)\s*{\s*(" + char + "+),(.*)}")
regex.match(str)
Like this, there are many exaples. Quite simply, strings are much easier
to manipulate in Ruby. Regexes are superior, there is varible
substitution, and the string methods are much better.
To make a long story short. If I could do this in Ruby the parser would
be easier to write, more understandable, and I would be more confident of
its correctness.
Cheers,
I guess I just want to share a tiny "case study" from a project that I'm
doing in Python and which I wish I could do in Ruby instead.
I am writing a BibTeX filter for the OpenOffice project (BibTeX is the
bibliographic cousin of LaTeX). I am doing it in Python because, of the
languages with stable bridges to the OOo component model (UNO) Python is
the one I like best.
My requirements are mostly related to regular expressions and string
methods. This is an area where Ruby really shines and is light-years
ahead of the competition.
Regular expressions in Ruby are infinitely eaiser and more sensible to
use than in Python.
Ruby:
str =~ /^(#{char})\s*{\s*(#{char}+),(.*)}/
Python:
regex = re.compile(r"^(" + char + "+)\s*{\s*(" + char + "+),(.*)}")
regex.match(str)
Like this, there are many exaples. Quite simply, strings are much easier
to manipulate in Ruby. Regexes are superior, there is varible
substitution, and the string methods are much better.
To make a long story short. If I could do this in Ruby the parser would
be easier to write, more understandable, and I would be more confident of
its correctness.
Cheers,