Live data from Hacker News

Autogenerating Rust-JS Bindings with UniFFI

hacks.mozilla.org

11–19 of 19 posts

Re: Autogenerating Rust-JS Bindings with UniFFI

#13
post #11
post #7

why is this big news weve had this stuff for decades now ?

We’ve had a library for generating JS bindings for Rust code for decades ?

Agreed, I doubt it's been a decade.. though maybe close-ish

wasm-bindgen does something similar though, right?

Re: Autogenerating Rust-JS Bindings with UniFFI

#14
Similar to the PythonMonkey project which provides high level bindings to SpiderMonkey from Python. Although its implemented in C++, I wonder if it or other projects like it could benefit from UniFFi

PythonMonkey lets you arbitrarily execute JS code like:

``` import pythonmonkey pythonmonkey.eval("(() => { console.log('hi from js'); })()") ``` for reference.

Re: Autogenerating Rust-JS Bindings with UniFFI

#15
Did switching from "everything is synchronous" to "everything is asynchronous" break a lot of other UniFFI users? I keep hearing people recommend UniFFI as the solution for Easy-FFI™, but that sounds like a drastic change that might break folks downstream.

Re: Autogenerating Rust-JS Bindings with UniFFI

#16
I'm using https://koffi.dev for running rust-compiled code in Node.js, so if this -in any way- means there's going to be something that just works(tm) as part of the standard JS stack, rather than having to rely on third parties to "mostly" implement FFI, that'd be amazing.

Re: Autogenerating Rust-JS Bindings with UniFFI

#17
post #5

Earlier quoted context omitted.

Yes, you can do that. UniFFI allows you to generate Kotlin and Swift wrappers, which you can wrap in a RN wrapper. We did this at work for a cross-platform mobile app, it's a bit of a headache to create because that are some subtleties with async or these kind of things, and they are handled differently in the UniFFI wrappers and RN wrapper, but for relatively simple libs I find it pretty convenient.

What would be really awesome would be a tool for generating JSI bindings to Rust code. Then you wouldn't need to go via Kotlin or Swift. I believe there are no technical barriers to such a tool. Someone just needs to implement it.

Most of the details for doing this are over my head but wow what a nerd-snipe!

Re: Autogenerating Rust-JS Bindings with UniFFI

#18
post #17

Earlier quoted context omitted.

What would be really awesome would be a tool for generating JSI bindings to Rust code. Then you wouldn't need to go via Kotlin or Swift. I believe there are no technical barriers to such a tool. Someone just needs to implement it.

Most of the details for doing this are over my head but wow what a nerd-snipe!

If you're looking for somewhere to start, then this repo which does some manual Rust JSI integration might be a good one https://github.com/triniwiz/nativescript-mason

Re: Autogenerating Rust-JS Bindings with UniFFI

#19
post #13
post #11

Earlier quoted context omitted.

We’ve had a library for generating JS bindings for Rust code for decades ?

Agreed, I doubt it's been a decade.. though maybe close-ish wasm-bindgen does something similar though, right?

It does, but wasm-bindgen is currently missing some features that I personally think are necessary for widespread adoption. Things like being able to have a `Vec` without venturing into type unsafe land and JSON.
Post reply on HN