5 ms·
The third paragraph says > Managed languages like Java and Kotlin are the best option for Android app development. These languages are designed for ease of use
by nindalf 6y ago
The third paragraph says
> Managed languages like Java and Kotlin are the best option for Android app development. These languages are designed for ease of use, portability, and safety.
You're not going to write Android Activities in Rust. Nothing is stopping you from adding Rust code to your Java/Kotlin app though.
- berkes 6y agoWhile it feels terribly hacky, one could probably write an Android-wrapper around Rust in Java. A rather big undertaking, I'd guess, since it means exposing all APIs to rust somehow. An other approach would be to employ one of many thin webview wrappers, in which your app is HTML+Js+CSS. When such a webview wrapper supports WASM, the JS part could be written in rust. Not something I'd do other than "to prove it can be done".
- Argorak 6y agoThe biggest problem here is that in Android, Java "owns" the app, so you will have to invert a lot of lines to make "develop a whole app in Rust" feel awesome. But, TBH, I think Kotlin and Java are _indeed_ fine application languages. What Rust is already quite often used for is for libraries that work on both iOS and Android. For a public example, see the Glean SDK: https://mozilla.github.io/glean/book/index.html https://mozilla.github.io/glean/book/index.html
- berkes 6y ago> But, TBH, I think Kotlin and Java I agree wholeheartedly. But there will be a demographic of people who know Rust and not Java, but who might want to build an app. Somewhat similar to how there is an apparent need for "HTML+JS+CSS"-devs to build native apps.
- Argorak 6y agoWell, this is always a tradeoff: the cost of being away from the mainstream may outweigh familiarity with a programming language at some point. I'm not sure if the argument for "HTML+JS+CSS" is purely familiarity, there's also technical arguments like portability and future-compatibility. But I _do_ hope that the portability story will become better in the coming years beyond just this stack.
- raphlinus 6y agoThe "cargo apk" tool already exists to bundle Rust code into a NativeActivity that can be run without needing to write any additional Java code. The API surface so provided is more limited than the full toolkit, but could be useful in many domains. It's currently mostly used for games. I am using it for the Android port of piet-gpu, and it's working pretty well.
- jeroenhd 6y agoThere's already an API for native activities. While I doubt that Google will be the one to release the framework to write Rust applications, there's no reason why it would be impossible to interface app-level Rust with the Android SDK. The big problem with such a setup, of course, is that the application itself would be running inside a JVM/Dalvik VM, so the app would constantly be switching between Java and native, which can't be great for performance. However, it can be done; thankfully, Chrome and Firefox aren't completely compiled to byte code, the JIT and rendering code is written in native code. With Mozilla's use of Rust in their browser, that means that there's already a significant Rust runtime running on Android, at least. If the app uses Rust and a library to hook the draw call, it should be fairly easy to write the app like a video game and render everything in Rust. This would come bundled with a tonne of accessibility problems, of course, as every rendered control would be a non-standard one.
- asveikau 6y agoI think another problem is that native binaries for multiple architectures would grow the binary, one per arch; aarch64 is not the only thing android runs on. Maybe some people would also forget that and not bother targeting others.
- throwaway189262 6y agoJava is a better fit for high level code, and you can already use Rust where performance matters. I've put a lot of time into learning Rust and I still reach for Java for high level stuff. GC is just wonderful for developer productivity. Lifetimes are way better than C but still a PITA. Especially when you mix with threading, you end up using Reference Counting anyways which is just shitty GC.
- rbanffy 6y agoHonestly, between the magic Kotlin adds on top of Java and Rust, I prefer Rust. At least it’s not doing stuff behind my back.
- bobthebuilders 6y agoC++ is better. Rust is a cargo cult language (same with Kotlin, Kotlin especially is a corporate language to sell more IDEs and Google was bribed by JetBraine to adopt it). Rust is just a bad attempt at reinventing the wheel.
- wffurr 6y agoRust is a bad attempt at reinventing C++? That's a unique take. Memory safety is a big deal for writing secure programs, which has been repeatedly shown to be impossible to do at scale in C++. Provably safe parallelism and concurrency is key for performance on multi core devices, also extremely difficult to do safely and correctly in C++. If C++ is the wheel being reinvented, it's not much of a wheel.
- howinteresting 6y agoRust is a fantastic attempt at reinventing C++. It works really well. I've been writing production code in it for the last few years and it's an utter delight to use. I maybe break out rust-gdb once a year. My code has fewer bugs than ever, thanks to extensive use of the high-quality modeling tools (types and lifetimes) provided by the language. My main project for the last year has had a grand total of one logic bug that was caught after release. It also has an inclusive community: at the last RustConf, half the speakers were nonbinary and/or transgender. I fit both those criteria and feel more welcome in the Rust community than in that of any other language, meaning that I can do my best work in Rust.
- carlhjerpe 6y agoConsidering way less than 50% of developers are nonbinary/transgender, don't you get the impression that they're then trying to fill quotas rather than picking the best speakers? Not saying they weren't the best, just that either rust is a very unique community or something is "up" with the selection. Just to clarify, I'm asking with good intent.
- skybrian 6y agoApparently the Android team is still not recommending Flutter. Hmm.
- pjmlp 6y agoWhy should they? Jetpack Compose is their defensive answer against Flutter.