News for hackers. Stuff that matters.
Re:Go bindings to Rust's regex engine by burntsushi on Monday May 02, 2016 @02:28PM (#11614081)
Unfortunately, no, that is not the usual way any more. Two primary reasons:

1. Compiling regexes at compile time requires a compiler plugin, which only works on nightly.

2. The compile-time regexes are dramatically slower (think orders of magnitude) than the normal Regex::new method. The normal Regex::new method is what's shown here in these bindings.

The compiler plugin was code I wrote two years ago, and really hasn't changed since then. Regex::new on the other hand has gotten a lot of love.

The plugin's performance may one day get better, but it won't be soon unless someone else works on it.

Re:Go bindings to Rust's regex engine by AYBABTME on Monday May 02, 2016 @03:43PM (#11614857)
curious, why is the compile-time regex slower? is it just a less efficient implementation?
Re:Go bindings to Rust's regex engine by burntsushi on Monday May 02, 2016 @04:10PM (#11615119)
Regex::new has these tools at its disposal: Pike VM (NFA), backtracking (NFA), DFA (online), DFA (offline), Boyer-Moore

The plugin has these tools at its disposal: Pike VM.

But yeah, killercup is correct. The DFA (online) is one of the bigger reasons. But the offline DFA and Boyer-Moore are probably just as important.

You might glean more information from my hacking guide: https://github.com/rust-lang-nursery/regex/blob/master/HACKI...

Re:Go bindings to Rust's regex engine by killercup on Monday May 02, 2016 @03:53PM (#11614953)
Yes, several of the optimizations of the dynamic regexes aren't available in the compile-time version. (It doesn't even have a DFA, IIRC.)

There is [a lint][1] which checks that your regular expressions are valid (at compile time), though.

[1]: https://github.com/Manishearth/rust-clippy/wiki#invalid_rege...