Live data from Hacker News

Bare-metal Rust in Android

security.googleblog.com

11–20 of 124 posts

Re: Bare-metal Rust in Android

#11

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

You can technically create an Android app without any Java code. There are native APIs for graphics and input. However, as these are intended for games, you get a window into which you can draw... something. With OpenGL, for example. You don't get access to Android's regular UI framework. You will also have to go through the Java layer to do many things you might want to do — like requesting permissions or launching other apps' activities.

Here's all the APIs you get: https://developer.android.com/ndk/reference?hl=en

Re: Bare-metal Rust in Android

#12
post #6

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

What would rust achieve aside from just enabling another, entirely distinct from the existing workflow, language? Haven’t android apps been compiled to native code since like 2012? (I actually don’t know, I left android a while ago and stopped caring what they do)

Not having to use Java or any of its weird derivatives.

Re: Bare-metal Rust in Android

#13

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

Isn't this what Tauri wants to achieve? At least it's on the roadmap I mean.

https://tauri.app/

Does anyone have any experience creating production apps with Tauri? Seems like a sane alternative to Electron, especially if they can target all major platforms and keep the promise of smaller footprints.

Re: Bare-metal Rust in Android

#14

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

You can already. The ndk allows any language to be compiled to android. For rust see

https://github.com/rust-mobile/ndk

Which has the tools to do this.

Re: Bare-metal Rust in Android

#15
Ideally, Android wouldn’t have any security vulnerabilities, but that’s not realistic. Rust won’t prevent every bug (and it’s even possible to cause segmentation faults in an ostensibly safe language like Python), but “better” is still a huge leap forward.

Re: Bare-metal Rust in Android

#16
post #6

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

What would rust achieve aside from just enabling another, entirely distinct from the existing workflow, language? Haven’t android apps been compiled to native code since like 2012? (I actually don’t know, I left android a while ago and stopped caring what they do)

I don't think it's a good idea, mainly because android is multiplatform and rust, by it's nature, is only available for what it's built for. Unless you are giving google your rust code to compile, your app will be limited on it's reach.

All that said.

Rust doesn't have a GC so it'd (likely) have a lower memory consumption and could possibly be lighter on the CPU.

Native compilation helps mainly with startup time and memory consumption. It's not exactly great for runtime performance as it takes away some key optimizations.

Another benefit of rust assuming you are distributing binaries is you'll be able to use the latest version of Rust rather than being pinned to older versions of the SDK with partial support based on the whims of google.

Re: Bare-metal Rust in Android

#17
post #12
post #6

Earlier quoted context omitted.

What would rust achieve aside from just enabling another, entirely distinct from the existing workflow, language? Haven’t android apps been compiled to native code since like 2012? (I actually don’t know, I left android a while ago and stopped caring what they do)

Not having to use Java or any of its weird derivatives.

I implore you to try Kotlin; it’s a fantastic language and is a wonder to code in

Re: Bare-metal Rust in Android

#18
post #6

Earlier quoted context omitted.

What would rust achieve aside from just enabling another, entirely distinct from the existing workflow, language? Haven’t android apps been compiled to native code since like 2012? (I actually don’t know, I left android a while ago and stopped caring what they do)

I don't think it's a good idea, mainly because android is multiplatform and rust, by it's nature, is only available for what it's built for. Unless you are giving google your rust code to compile, your app will be limited on it's reach. All that said. Rust doesn't have a GC so it'd (likely) have a lower memory consumption and could possibly be lighter on the CPU. Native compilation helps mainly with startup time and…

>mainly because android is multiplatform and rust, by it's nature, is only available for what it's built for

Android is one platform: android. I thought rust worked across multiple operating systems.

>Rust doesn't have a GC so it'd (likely) have a lower memory consumption and could possibly be lighter on the CPU.

So what? I have never used G.C.

>Native compilation helps mainly with startup time and memory consumption. It's not exactly great for runtime performance as it takes away some key optimizations.

That is fair I suppose

I think the main benefit of rust/c++/ndk on android is that I can just port desktop programs and I don't have to learn android's java/kotlin and sdk.

Re: Bare-metal Rust in Android

#19

Ok, now enable us to let create Android Applications entirely in Rust (including the GUI). Let's get rid of Kotlin/Java monopoly in Android App development. Shall we?

Tell me you've never done any Android development, without telling me...

This is such a low-effort "take" without any effort to justify _why_ you'd want something like this. There's a high amount of impedance mismatch trying to write GUIs in a non-GC language like Rust which _has_ to run on what's essentially a Java VM (ART).

At least with a language like Go, it somewhat makes sense, and has been attempted: https://gioui.org/

All this Java/Kotlin bashing is getting really old, especially for a forum like this one.

Post reply on HN