And this website is not cutting it either. Barely readable without zooming in, code is a picture for C++, etc.
While std::regex is easy to read/write it’s actually not very performant. There are other C++ libraries (or even C ones like pcre) that should probably be used when you are benchmarking Rust vs C++.
If you care about performance (and comparing the two langs..) then it’s probably better to get rid of the regex entirely. For this example the rx is literally 2 or more of a character class. Just doing that test inline is a “one if statement” state machine. I personally feel regex is not “carrying its own abstraction weight” here, though I realize rx abstraction power was (maybe?) part of the point of the C++ post.
Language speed comparisons are hard to do, because you can always tune small example code to death. C/C++/Rust can one-up each other on this one until only raw syscalls and SIMD intrinsics remain.
I agree. With very little adjustment, the Nim was like 8.5x faster than the Rust on the same input/same machine for just one file. Here I mostly meant to steer away from a “this regex lib is faster” rabbit hole when regexes themselves are overkill for the “endswith” and “2 or more charclass” use cases of this small example code. (Maybe they wouldn’t be overkill if patterns got bubbled up to the user, but it often bothers me when people reflexively reach-for-regex)