Ragel success story

Wincent Colaiuta w... at wincent.com
Mon Feb 4 20:40:48 UTC 2008

Here's a little Ragel success story.

I've written a wikitext-to-HTML translator written in C (a Ruby
extension) and up until a few days ago it was using a lexer generated
by ANTLR 3.0.1 (the C target). I've had a suspicion for some time,
however, that a Ragel scanner might be faster for a number of reasons.

Imagine my surprise when I compared the speed and found that Ragel was
nearly 10 times faster! I hadn't been expecting that kind of

You can look at the code here:


And an article with the benchmark results is here:


For comparison, the current version of the ANTLR grammar at the time
of writing is:


And the corresponding Ragel scanner implementation is:


I've made no attempt at optimization yet, but the performance of the
Ragel scanner is already spectacular for a "rough draft".

Ragel is a wonderful tool!


More information about the ragel-users mailing list