Wednesday August 19, 2009
Ruby's regexp engine sucks to debug
Today, I'm using Ruby for a project at work and Oh! My! God! Every week I get deeper with Ruby I become more impressed with how much I like writing ordinary things in it and how much I loath having to solve hard problems in it. This language, or the implementation seems to go miles out of its way to make it nigh impossible to debug.
- Without changing anything I'm aware of my trepan gem (http://github.com/jbenjore/trepan/tree/master) has started throwing Bus error
- I've found that the regexp engine is matching "something" wrong
- To debug a regex in 1.8.6, I recompiled ruby with CFLAGS=-DDEBUG_REGEX
- -DDEBUG_REGEX produces only the inscrutable output "regex loop(5): matching 0x01" which doesn't seem to map to anything like characters or offsets or anything. I can't use it
- Ruby 1.9 uses Oniguruma but it also fails to match the same regexp
- Installing the latest Oniguruma from http://www.geocities.jp/kosako3/oniguruma/ yields libonig, not something I can use in ruby. Oops
- Building 2.x per the page tries to patch my Ruby 1.8 source code but fails
- There's apparently a /third/ version of Oniguruma at http://rubyforge.org/projects/oniguruma. Maybe's it's just old? Maybe it's the version that works. Dunno
I just want a language that doesn't make me spend immense amounts of energy! Is that so much to ask? I throw tons of energy at perl but I get cool things for it. I'm throwing tons at ruby now and not even getting things I have for FREE in perl.
FWIW, after spending several hours struggling with Ruby, I threw in the towel. Read a book and went to bed early, exhausted.