Comment by nicoburns
3 days ago
There is a huge amount of potential for shared infrastructure for "native integrations" for Rust UI projects. Think: React Native modules but in Rust.
I'm hoping this can be a reality sooner rather than later. But we're definitely lacking in manpower willing or able to work on the more foundational pieces. Winit in particular is sadly undermaintained. 1 or 2 people working full time on Winit and/or other platform integration pieces would do wonders for the ecosystem.
If you do it via React Native turbo modules, it is already possible, either using craby (1) or using uniffi-bindgen-react-native (2).
(1) https://github.com/leegeunhyeok/craby
(2) https://github.com/jhugman/uniffi-bindgen-react-native
My understanding is that this only gives you access to C++ TurboModules? Binding to C++ is already easy in Rust (and odten Rust itself is a better choice for these "cross-platform business logic" kind of modules anyway). The value here is in unlocking bindings to the native platform APIs (which are mostly Java/Kotlin/Objc/Swift)
I have no idea why people would want to write UI in Rust when Swift, Kotlin and Dart are much better suited for the job.
At least for me:
* I don't trust Swift on Android to be well supported, either now, or in the future. I would never want to rely on something Appley on a non Apple platform
* I dislike Swift and find it to be an unpleasant language. This is personal pref of coures, just like preferred flavors of ice cream
* Dart looks interesting and like a good option, though I don't want to learn a new language and Dart doesn't appeal to me because it feels like they took javascript and made it more like Java, and Java is in about the middle of my list of preferred langs (see above comment about preferred flavors of ice cream). Flutter is a killer app though and might be enough to sway me.
* Kotlin is a nice language, though not nice enough to where I'd want to use it outside of Android. The ties to the JVM-world tooling/dependency management is very offputting to me.
Overall I have a strong desire to use my preferred language(s) for everything if possible, so things like this are quite attractive to me for that reason. Now that said, when I write Android apps right now, what I typically use is Kotlin or Java because I've found I always end up having to write at least part of the app in those, so might as well keep it simple and consistent in one lang. But I'm always on the lookout!
what do you find unpleasant about it?
One of the reasons for me personally is a rich selection of packages from crates.io. For example if you are writing a server in Rust, and use something like https://crates.io/crates/reqwest for http requests, then you can reuse it in your mobile app. Also there's serde. You don't need to write the schema for your data if you have Rust on both server and client. Just make a shared crate and use serde to encode/decode the data. It really saves a lot of time if you don't have to use swagger or similar tools. And there's a documentation out of the box with `cargo doc`
You shouldn't use reqwest on mobile devices, you should be using the built-in platform-specific HTTP libraries.
On Android this appears to be less of an issue, but on iOS there's documentation floating around that you really want to use e.g NSURLSession for battery/radio reasons. Spotify even went so far as to write a cross-platform lib for this kind of thing some years back.
It’s kind of the same argument as that for Node: having a singular language for everything you do lets you have “thick” tightly coupled packages that do everything, which you can compose or decompose in a safe(r) refactor as business needs change.
Once you start using JNI or Objective-C++ to hand off “computationally expensive” work to common C++ (now Rust) libraries, you end up needing to become an expert across a lot of areas.
If 95% of your competitive advantage lies in doing things everywhere with low memory, then taking on an additional 2-3 stacks (SwiftUI + React + Compose) as well as all the bindings and build system and etc overhead can be pretty gnarly.
If 95% of your value add is in your web-based UI, consolidating to a single JS stack of React + React Native + Node can greatly reduce your idea-to-market time, I’d imagine a full Rust stack could do the same if your value add requires maximum performance and only a little UI iteration.
One language vs 3 or 4? And some folks REALLY like Rust
They are slow and memory-hungry.
I would love to see RustActivity in Android one day, this would make the life much easier.
There is https://github.com/rust-mobile/android-view, although it's not currently being actively developed.
I've seen it too recently, looks interesting.
I mean cross platform is just "heavy work" in general
many company literally just give up use web wrapper instead because its just so much work