TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Regular expressions: Rust vs. F# vs. Scala vs. D

5 pointsby yawniekover 9 years ago

2 comments

weinzierlover 9 years ago
Regarding performance Rust is the loser in this comparison. The regex crate documentation addresses this issue and says this is because of a lack of optimization. Generally I really like the fresh approach that Rust takes on the regex topic. I can&#x27;t explain it better than the docs:<p><pre><code> This crate provides a native implementation of regular expressions that is heavily based on RE2 both in syntax and in implementation. Notably, backreferences and arbitrary lookahead&#x2F;lookbehind assertions are not provided. In return, regular expression searching provided by this package has excellent worst-case performance. [...] Rust&#x27;s compile-time meta-programming facilities provide a way to write a regex! macro which compiles regular expressions when your program compiles. Said differently, if you only use regex! to build regular expressions in your program, then your program cannot compile with an invalid regular expression. Moreover, the regex! macro compiles the given expression to native Rust code, which ideally makes it faster. Unfortunately (or fortunately), the dynamic implementation has had a lot more optimization work put into it currently, so it is faster than the regex! macro in most cases. </code></pre> <a href="http:&#x2F;&#x2F;doc.rust-lang.org&#x2F;regex&#x2F;regex&#x2F;index.html" rel="nofollow">http:&#x2F;&#x2F;doc.rust-lang.org&#x2F;regex&#x2F;regex&#x2F;index.html</a>
评论 #10850979 未加载
chenglouover 9 years ago
Would be nice to have JS&#x27; speed (V8)! Last time I checked they compile the regex into some really clever heuristics. I wouldn&#x27;t be surprised if the speed is on par or faster than what&#x27;s here.<p><a href="http:&#x2F;&#x2F;blog.chromium.org&#x2F;2009&#x2F;02&#x2F;irregexp-google-chromes-new-regexp.html?m=1" rel="nofollow">http:&#x2F;&#x2F;blog.chromium.org&#x2F;2009&#x2F;02&#x2F;irregexp-google-chromes-new...</a>