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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Integrating a Rust module into an Android app

40 点作者 alex_hirner将近 3 年前

3 条评论

terhechte将近 3 年前
I&#x27;ve worked on some projects (private and commercial) where embedding Rust into one of those targets was required: iOS, Android, Flutter, macOS, Web. I&#x27;ve played around with a variety of approaches because there exist multiple solutions depending on the platform. Apart from Web&#x2F;Wasm, where Rust really shines, the next best solution is uniffi by Mozilla, which has quite solid iOS&#x2F;Android support:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mozilla&#x2F;uniffi-rs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mozilla&#x2F;uniffi-rs</a><p>While this works, the bigger pain (at least on iOS) is that the Rust-Compiler LLVM and Xcode LLVM are not always in sync leading to strange bugs. Also, packaging Rust libraries into a nice XCFramework (or even SPM Module) works, but usually involves hacky shell scripts.<p>The reason why you&#x27;d still want to do this is if there&#x27;s a Rust library that has no equivalent on the Kotlin or Swift side. There&#x27;re a lot of good crates &#x2F; libraries for Rust would require an expensive re-implementation in Swift or Kotlin. Also, because Rust doesn&#x27;t have a garbage collector, it is easier to embed in garbage collected languages like Kotlin without running into situations where the two garbage collectors don&#x27;t agree.
评论 #32111677 未加载
ZeroCool2u将近 3 年前
I don&#x27;t have a need for this personally, but having been forced to deal with some Java build nightmares like PyLucene&#x27;s JCC[1], I respect the hell out of these guys for figuring it out and actually documenting it with a working example for others to take advantage of.<p>[1]: <a href="https:&#x2F;&#x2F;lucene.apache.org&#x2F;pylucene&#x2F;jcc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;lucene.apache.org&#x2F;pylucene&#x2F;jcc&#x2F;</a>
评论 #32108579 未加载
rob74将近 3 年前
<i>&quot;Since I have experience in cross-compiling and building automation, I often choose Rust as my primary programming language.&quot;</i> - hmmm, not sure I see how the second follows from the first?<p><i>&quot;In addition, Rust is still a relatively new language, and utilizing any technology from the previous decade is setting you up to fail.&quot;</i> - er, no? Or at least you should consider the thought that using a technology that isn&#x27;t established yet and might be abandoned could also set you up for failure? Not saying that Rust is in danger of that, but...<p><i>&quot;Sometimes, following the hype train is the quickest route to success.&quot;</i> - ok, I&#x27;m not sure I want to read this article anymore. Or is my irony detector malfunctioning?
评论 #32109133 未加载
评论 #32108936 未加载
评论 #32108819 未加载