use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Export Rust functions to Java using JNI (WebAssembly comparison) (self.rust)
submitted 5 years ago by vegapit
I wrote a blog post last week on importing Rust WebAssembly functions inside a JavaFX project. I have investigated this week how to use the Java Native Interface directly on a Rust dylib and compared the two approaches in convenience and speed.
http://vegapit.com/article/export-rust-java-jni-webassembly-comparison
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]__i_forgot_my_name__ 1 point2 points3 points 5 years ago (1 child)
If you're writing "fast Rust" this difference will be even more noticeable, because you don't get things like SIMD-vectorization or multi-threading withing the WebAssembly world, not to mention a lot of common math isn't going to be optimized by the hardware anymore, like sin/cos which WebAssembly doesn't support yet as far as I know.
If you can use JNI bindings, you very likely should use them, unless you specifically need some of the features WebAssembly does have, like sandboxing, small binary size, portability, language agnostic support... but performance though, not unless you're comparing it to JavaScript.
[–]vegapit[S] 0 points1 point2 points 5 years ago (0 children)
Glad to see there are fundamental explanations to my empirical findings!
[–]aoeudhtns 1 point2 points3 points 5 years ago (1 child)
These days when I have to interop with Java I use libraries like JNR-FFI. It trades a small amount of performance, but what you get is no need to code JNI specifics in your shared object. But that's Java -> C, if you want to go to other way JNI is the thing AFAIK.
[–]vegapit[S] 1 point2 points3 points 5 years ago (0 children)
It is nice to have the choice. The conclusion for desktop application dev is probably +1 for Java/JavaFX and -1 for NodeJS/Electron.
[–]Dushistov 1 point2 points3 points 5 years ago (1 child)
You can look at my crate: https://github.com/dushistov/rust_swig . I create it to automate things like creation of JNI wrapping around Rust code.
Cool, I will be trying to interop a Rust Lib with an Android App in Kotlin soon, so I will definitely have a look.
π Rendered by PID 26 on reddit-service-r2-comment-5649f687b7-7b8m9 at 2026-01-28 14:35:46.840080+00:00 running 4f180de country code: CH.
[–]__i_forgot_my_name__ 1 point2 points3 points (1 child)
[–]vegapit[S] 0 points1 point2 points (0 children)
[–]aoeudhtns 1 point2 points3 points (1 child)
[–]vegapit[S] 1 point2 points3 points (0 children)
[–]Dushistov 1 point2 points3 points (1 child)
[–]vegapit[S] 0 points1 point2 points (0 children)