4 ms·
IMHO, now is a great time to use native Swift/Kotlin code alongside shared Rust code via UniFFI
by railka 18d ago
IMHO, now is a great time to use native Swift/Kotlin code alongside shared Rust code via UniFFI
- rvz 18d agoSo you want to review and maintain code in 3 separate languages? Sounds like a complete waste of tokens with the worst case of just quickly building more technical debt, three times.
- massel 18d agoIt's a lot nicer than having the same logic in 2 languages and trying to keep them in sync – whether doing it by hand or with an LLM. One of the big rules is don't repeat yourself – much of the logic only needs to be written once (except UI)
- rvz 18d agoIn that case, Kotlin makes even more sense especially with Kotlin Native, and Rust is unnecessary. Kotlin is already multi-platform and can be re-used as the business logic in iOS apps with Swift as the UI and the Android app with a Kotlin UI (Jetpack Compose) or both iOS and Android apps can be written entirely in Kotlin. That vastly reduces the maintenance and Kotlin is reused across all apps and keeps it at 2 languages at most. No need to introduce Rust to achieve the same goal.
- doc_ick 18d agoWell you don’t repeat yourself if the llm repeats it for you at the cost of millions of tokens.
- mike_hearn 18d agoRust is uncompetitive for the use case of sharing logic between mobile apps. Kotlin has Swift interop and KMP is a mature tech by this point.
- mwcampbell 18d agoThis is probably biased by the specific multi-platform apps I've worked on, but my default assumption is that sooner or later, any non-trivial multi-platform app will need to reach for something that doesn't already have a KMP library and that, on Android, might require compiling native code via the NDK. Rust has a way bigger library ecosystem than KMP. So I figure one might as well do the cross-platform core in Rust and add that FFI boundary early, but managed by something like uniffi-rs. And, I've seen it work in a few real projects now, with just a little build system friction up front. So in what sense is Rust uncompetitive for this use case?
- mike_hearn 17d agoKMP can call into native libraries easily. C FFI is not a competitive advantage. Rust has a smaller library ecosystem, I'd say. Kotlin can use Java libraries on the server side, and on the client side on Android, and the ones needed on iOS are easy to convert to KMP - IntelliJ can do it semi-automatically. And KMP has the libraries that matter on mobile, for hardware access, animations and so on.
- hn-acct 17d ago> mature. Sure if you want to write old Swift.
- massel 18d agoWe've been doing this for a while and it works great. Logic and network stuff goes in Rust, UI goes in Swift/Kotlin.