TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

5 点作者 yawniek超过 9 年前

2 条评论

weinzierl超过 9 年前
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 未加载
chenglou超过 9 年前
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>