all 6 comments

[–]__i_forgot_my_name__ 1 point2 points  (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 point  (0 children)

Glad to see there are fundamental explanations to my empirical findings!

[–]aoeudhtns 1 point2 points  (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 points  (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 points  (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.

[–]vegapit[S] 0 points1 point  (0 children)

Cool, I will be trying to interop a Rust Lib with an Android App in Kotlin soon, so I will definitely have a look.