1. 15
  1. 4

    And this website is not cutting it either. Barely readable without zooming in, code is a picture for C++, etc.

    1. 3

      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++.

      Please see: https://old.reddit.com/r/cpp/comments/e16s1m/what_is_wrong_with_stdregex/

      1. 2

        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.

        1. 4

          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.

          1. 1

            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)