Hacker News new | past | comments | ask | show | jobs | submit login
Rust compiler added to Android tree (googlesource.com)
185 points by ndesaulniers 34 days ago | hide | past | web | favorite | 33 comments



Can someone familiar with the Android ecosystem elaborate on what exactly this means? Does it mean you get rustc automatically when you download the Android SDK? Does it imply any particular level of support? How many other languages have this status?


> Can someone familiar with the Android ecosystem elaborate on what exactly this means?

It means that Google is experimenting with using Rust to build parts of Android. That could mean parts of the OS, tests, tools, SDK, etc...

As a simple example of why this isn't necessarily super interesting is Python has been in the Android tree for ages, but just for some build & test stuff.

But maybe it's interesting just in that the Google engineers working on Android have started playing with Rust enough to bother checking it in to the tree.


One reason I find this interesting however is that fuchsia, a potential replacement for Android being worked on at google (that's an aggressive oversimplification) is partially written in Rust. So this potentially opens up using parts of fuchsia.


Someone at Google should check in a Bitcoin hashcash library into the tree and watch HN go wild.


Cool; so it's not an app development thing, it's an OS thing. Thanks for the explanation.


I think they want to experiment rewriting some libraries in Rust to avoid things like stagefright in future.

Pretty much what Mozilla did when Rust got more serious.


It means someone working on Android needs to compile something written in Rust badly enough to add support for it.

The second Android developer needing to use Rust will presumably have an easier time of it, but how much Android will really use it is speculative.


Meaning Rust is being used in the Android OS itself, so this isn't about app developers?


Correct. But nothing stops you from using rust today as an app developer. See https://docs.rs/crate/cargo-ndk/0.2.0


Does anyone here have experience on using Rust for shared business logic between Android and iOS? It's something I'm considering but it seems there isn't a lot of documentation around it.


For iOS, you create C FFI bindings for your lib. Then you conpile a universal binary with cargo-lipo and use it from Swift like a C library.

For Android you write JNI bindings with something like rust-jni.

So yes, you have to write bindings twice. For an example project check out https://github.com/dbrgn/candidateparser and https://www.reddit.com/r/rust/comments/7aam04/meetup_slides_...


Yes, we're sharing Rust code through Kotlin on Android and Swift on iOS. https://github.com/mozilla/application-services/tree/master/...


Currently you could use kotlin/native for such effort.


the game "A Snakes Tale" was released on IOS and Android simultaneously, 100% Rust. The author is on twitter might have useful info for you.


Rust aside, this is a well done little puzzle game and worth the few bucks. It's on Steam, also.


We don't know what it's for. It might be used in a sample app.

But it's not something ordinary Android developers need to pay attention to.


This happens a lot on hackernews, and frankly it's really annoying. People post a link to some random thing like this, and it gets upvoted because people don't click on the link, they just are excited about the title. A lot of times, the title doesn't even mean anything. Hackernews != Twitter.

</grumpy> I'm going to get some more coffee.


hn is one of the few places on the web with a community that notices changes like these and that can contextualize them just-in-time.


I mean, it sounds like it means something, it's just hard to understand without some context.


HN could reduce (but not prevent) upvoting of unread articles by removing the upvote button from the HN home page (so you can only vote after having opened the HN thread page and seen some comments) and/or requiring the user to click the article link before the upvote button appears (so the user might have read the article before voting).


I'm just here for the sweet fake internet points. Let me know if you find out where I can redeem them...


I've always taken it for granted that the voting system is essentially meaningless, especially for comments, so don't generally use it (I'll downvote egregiously rude or idiotic comments, but that's it).


Pretty wild how many tools are required to get a hermetic Android build:

https://android.googlesource.com/toolchain/

edit: this just means that Android developers can now include Rust-language components in Android itself.


I don't think these are all necessarily required. At least I would be very very surprised if both avr-libc, mingw, and go were needed.


It's been something like 3 years since I've worked in AOSP but IIRC mingw is for windows builds of adb. Someone else called out that AVR stuff is for ADK. The Android build tree is more than Android itself. It also builds includes a lot of the supporting tools and libraries for developers.


For avr-libc, probably this: http://tool.oschina.net/uploads/apidocs/android/guide/topics...

Unsure about mingw/go, but they are likely deps for some Android ecosystem project.


Looks like go is mostly used in a graphics package (platform_external_skia):

https://github.com/search?utf8=%E2%9C%93&q=org%3Aaosp-mirror...


FWIW things may not actually be used anymore, doesn't mean the repo is ever taken down. Usually the manifests that sync these repo's simply "unhook" the repos when they're no longer in use. OP is excited that there's a bunch of links, but that's not the correct measure of "in use."


For comparison, how many tools are needed to build desktop Linux, say, Ubuntu?


1. A large fraction of Garnet (low level components of Fuchsia) is written in Rust. (https://fuchsia.googlesource.com/fuchsia/+/refs/heads/master...)

2. Fuchsia seemingly supports Android apps (https://9to5google.com/2019/01/02/android-runtime-app-suppor...).

3. For 1 + 2, Android may need to include and compile a part of Fuchsia for interop.

My guess is that this addition is mostly for supporting Fuchsia, rather than using Rust directly in Android.


It's not too farfetched to think that some Rust code might be used in Android itself. Google already uses Rust in ChromeOS to build the Linux VM.


Rusty 'Droids: no longer strictly a Star Wars thing.


Microsoft is also considering it for some Windows components as 70% of Windows bugs are memory-related:

https://msrc-blog.microsoft.com/2019/07/16/a-proactive-appro...

I wonder if Google is adding support, because it's also considering replacing the OpenSSL-forked BoringSSL with the Rustls crypto library:

https://news.ycombinator.com/item?id=20480277

That would be pretty cool, although I wonder if they shouldn't opt for a Noise Rust library instead:

https://github.com/mcginty/snow




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: