Q: When are Tcl and Python faster than C? A: When they invoke faster, better libraries.
shootout.alioth.debian.org
shootout.alioth.debian.org
I wonder how much of the difference here between Tcl and Boost can be attributed to the DFA vs NFA algorithm and how much to the underlying string representation (Tcl's flat DString buffer vs the rope used by the Boost program).
I suspect that for these regexes and for this size text (100k) we're really just seeing better cache behavior.
This isn't 100% true, because in theory you could have written out the ideally optimized version of machine language for what you're trying to do, or (perhaps) a direct transliteration thereof in C. In practice, this isn't realistically possible, except in tiny pieces.
See also: Proebsting's Law (http://research.microsoft.com/~toddpro/papers/law.htm)
Also, the proof skips more than a few critical steps when it says "Let's assume that this ratio is about 4X" and then uses that number as a multiplier in the answer.
Also, I think most things in computing called X's Law are not entirely serious, these days.
AFAIK this is the idea behind numpy.
SBCL, Haskell, Java, and OCaml all basically provide this.