Back to Home11/13/2025, 6:32:36 PM

Rust in Android: move fast and fix things

409 points
402 comments

Mood

supportive

Sentiment

positive

Category

tech

Key topics

Rust

Android

Security

Programming Languages

Debate intensity60/100

Google discusses the adoption of Rust in Android to improve security and performance, highlighting its benefits and future plans.

Snapshot generated from the HN discussion

Discussion Activity

Very active discussion

First comment

2h

Peak period

151

Day 1

Avg / period

80

Comment distribution160 data points

Based on 160 loaded comments

Key moments

  1. 01Story posted

    11/13/2025, 6:32:36 PM

    5d ago

    Step 01
  2. 02First comment

    11/13/2025, 8:18:38 PM

    2h after posting

    Step 02
  3. 03Peak activity

    151 comments in Day 1

    Hottest window of the conversation

    Step 03
  4. 04Latest activity

    11/15/2025, 1:14:04 AM

    4d ago

    Step 04

Generating AI Summary...

Analyzing up to 500 comments to identify key contributors and discussion patterns

Discussion (402 comments)
Showing 160 comments of 402
mk89
5d ago
6 replies
This is the bomb that sank C++ in 2026.

Have fun justifying that Rust is "also" unsafe, with the right tools you can achieve the same in C++, if you're a great dev you can do even better, etc.

gchamonlive
5d ago
1 reply
I personally have zero interest in these feud wars. I'm only glad there are more quality options for Devs to develop safer system tools.
josephg
5d ago
The only people I’ve met who seem to think it’s a feud war are a few dyed in the wool C++ fans who implicitly hate the idea of programming anything else. Rust is just a language. It has some strengths and weaknesses just like every programming language. Some of its strengths are incredibly compelling.

Personally I’m relieved that we’re starting to see real competition to the C & C++ duopoly. For awhile there all the new languages were GC, and paid for their shiny features with poor runtime performance. (Eg java, C#, Ruby, Python, lua, go, etc etc)

Rust is a fine language. Personally I can’t wait to see what comes after it. I’m sure there’s even better ways to implement some of rust’s features. I hope someone out there is clever enough to figure them out.

beeflet
5d ago
5 replies
rust has other advantages. I think cargo is better than cmake. I think the syntax is better, I think the way dependencies and modules are handled is better.

It can be annoying to write "safe" code, but once it meets a certain standard I can be confident in multithreaded applications I write.

I would like to use rust to write android apps. I don't really like the whole android studio java thing.

gpm
5d ago
3 replies
> I think cargo is better than cmake

I expect that Google is using neither of these for most of their own code, but rather their own build system (which I think is the same between the languages).

I absolutely agree if you aren't Google though.

petcat
5d ago
1 reply
Yeah my understanding is that google has some sort of God program they use that can compile anything and has 10,000 command line options.
kridsdale1
5d ago
1 reply
Google3 uses Blaze which is an internal Bazel. And it’s fantastic. I like Facebook’s BUCK too but it’s basically the same thing.

If I were to go to another company I’d promote using either of the above.

vlovich123
5d ago
1 reply
What does Android do for Rust?
surajrmal
5d ago
It uses Soong which internally calls rustc: https://source.android.com/docs/setup/build/rust/building-ru...
ncruces
5d ago
Android uses Soong: https://source.android.com/docs/setup/build

Proprietary code uses the internal version of Bazel: https://bazel.build/

mk89
5d ago
6 replies
I cannot like Rust syntax, sorry.

For me the ideal syntax is C/Go, just to be clear what I like.

But I agree that the tooling that cargo introduced is a breath of fresh air in a world dominated by huge makefiles, libraries copied in the repository (I know, there is Conan, vcpkg etc)...

dontlaugh
5d ago
1 reply
All three have very similar syntax when compared even to something like Python or Ruby, let alone ML or Haskell. Seems like a spurious complaint.
gf000
5d ago
I mean, Rust is quite a different category than C or Go, if this is the 3 languages you reference.

Rust has plenty of syntax coming straight from ML (okay, not straight, probably through OCaML)

Pattern matching, destructuring, expressions everywhere, etc are stuff that C/Go never even heard about.

MBCook
5d ago
1 reply
I don’t disagree, that’s part of why I like Swift so much. Rust looks very C++ to me.

But if I was working in C++ and had a choice of C++ or Rust, I’d go Rust based on this.

mk89
5d ago
Agree! Swift I forgot to mention. What a nice and elegant language.
guywithahat
5d ago
7 replies
Go is such a great language. If your code base doesn't mind garbage collection and doesn't depend on some external library, everyone should really look at go. Great multithreading, memory safe, great error handling, and a familiar syntax for people coming from C++/Java/etc.
mkehrt
5d ago
2 replies
> great error handling

Go get this completely wrong! It use a tuple rather than an enum for potential errors. This means you can forget to check errors and just use the invalid (nil?) return value from the function.

On the other hand, rust uses the Either enum to force you to handle the error. Alternatively you can use the ? operator to pass it to the calling function, which is reflected in the enclosing function's type.

ikety
5d ago
1 reply
Yep Rust approach won. Pretty much every new language is adopting Result style errors and it's been adapted to plenty of existing languages.

It's a product of functional programming, and for me I can't see how you would ever want to handle errors outside of the functional programming railway-oriented style. For me it's just superior.

tczMUFlmoNk
5d ago
1 reply
Umm, actually, it's specifically a coproduct of functional programming. ;-)

https://en.wikipedia.org/wiki/Coproduct

ikety
4d ago
Ha learned something
Mond_
5d ago
Pet peeves nitpick: it's not even a tuple. Go doesn't have tuples. It just has special-cased "multiple return values", which means that it's often impossible to just stuff the return of a function call (error value and all) into any data structure to aggregate them. You just can't do without first defining a struct since tuples don't exist in Go.
Zambyte
5d ago
1 reply
Zig in spirit is essentially Go without GC. If GC is not reasonable for your usecase Zig seems like an awesome choice. Unfortunately it's probably about 5 to 10 years out from being stable enough for most people being able to write serious applications in it though (notable exceptions being Bun and Ghostty, but they have solid effort behind them keeping them up to date with Zig).
pjmlp
4d ago
More like Modula-2 in C clothing, given the safety guarantees.
tuetuopay
5d ago
2 replies
How is Go memory safe? Memory safety does not mean "leaking memory".

It's absolutely possible to compute wrong pointer offsets. It's absolutely possible to dereference nil. It's absolutely possible to bork ownership and have multiple thread trample a struct. It's absolutely possible to reinterpret memory the wrong way.

I do agree that UAF is not possible (in most cases) due to the GC. That array indexing out of bounds is not possible. But it is by no means "memory safe" to the level Rust is.

rascul
5d ago
1 reply
Rust doesn't consider leaking memory to be unsafe.
tuetuopay
4d ago
I mentioned it because I often hear people (not in this thread though) that thanks to its GC preventing memory leaks, Go is memory safe. The GC's role in memory safety is preventing dangling pointers though.
gpm
5d ago
2 replies
> It's absolutely possible to bork ownership and have multiple thread trample a struct.

This is specifically the one place where go is not memory safe IMO.

> It's absolutely possible to compute wrong pointer offsets.

In Go? Without the `unsafe` package (at which point you are explicitly opting out)? How? There's no pointer offset in the first place.

> It's absolutely possible to dereference nil.

Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

It's (really the lack of non-nil types) is one of many reasons why go doesn't produce as reliable software as rust, but it's not a memory safety issue.

> It's absolutely possible to reinterpret memory the wrong way.

Again, without the unsafe package? How?

uaksom
5d ago
1 reply
gpm
5d ago
Right, that's the first category, "It's absolutely possible to bork ownership and have multiple thread trample a struct" resulting in undefined behavior.
tuetuopay
4d ago
My Go is a bit rusty (pun intended), so I may have misremembered, especially with the pointer offsets. (just googled it, I did remember it, sorry for the confusion).

>> It's absolutely possible to reinterpret memory the wrong way. > Again, without the unsafe package? How?

Again my go is rusty, but I saw quite a bit of shenanigans in go with pointer casting from what's essentially a collection of void*. However perhaps those casts blow up at runtime? I'm too used to rust where it's explicit where it'll blow up.

>> It's absolutely possible to dereference nil. > Yeah, but that's safe defined behavior in go equivalent to "unwrap"ing a None option in rust. It reliably crashes. It's not like C where it's undefined behavior and you might crash of you might just corrupt random memory or have the optimizer make your code do something even stranger.

Agreed. I conflated "safety" and "robustness" here. The existence of nil is a thorn in the language.

Thanks for the corrections!

array_key_first
5d ago
Go has some of the worst error handling I've ever seen, even worse than most exception implementations IMO, and the type system is stupid enough that it's still very easy to write bugs. Go is only surface-level memory safe, you can definitely segfault in Go. And I mean real segfault, not nullptr dereference.
ViewTrick1002
5d ago
> Great multithreading

Until you stumble upon the countless footguns. At least they generally don’t lead to memory unsafety, just garbage data.

Data Race Patterns in Go

https://www.uber.com/blog/data-race-patterns-in-go/

gf000
5d ago
> If your code base doesn't mind garbage collection and doesn't depend on some external library, everyone should really look at go

I mean, at that point pretty much every language would be a decent choice.

tonyhart7
5d ago
>mention Go

>great error handling

why people so confident being so wrong???

josephg
5d ago
3 replies
> I cannot like Rust syntax, sorry. For me the ideal syntax is C/Go, just to be clear what I like.

I’m sorry if this comes across as dismissive, but I find it hard to take people seriously with complaints about syntax like this. Learning new syntax is really easy. Like, if you’re familiar with C & Go, you could probably learn all the syntax of rust in under an hour. The only surprising part of rust’s syntax is all the weird variants of match expressions.

Rust has some surprising semantics. Like how lifetimes work (and when you need to specify them explicitly). That stuff is legitimately difficult. But learning that if statements don’t need parenthesis is like - seriously whatever dude. If you want to spend your career never learning new stuff, software isn’t for you.

I picked up objective C about 15 years ago. The only thing most of my friends knew about it was that it had “that weird syntax”. It took no time at all to adjust. It’s just not that hard to type [] characters.

samdoesnothing
5d ago
1 reply
It's not about learning syntax, it's about finding it generally tolerable to read. I personally find Rust syntax repulsive and would opt for a different language unless Rust was literally the only option. Thankfully it's never the only option, now or in the future.
josephg
4d ago
Can you give some examples? Its hard to agree or disagree if you're not going to make any substantive claims.
cogman10
5d ago
1 reply
I'd say that rust has a weird level of being both verbose and terse in strange ways.

If you ever have to deal with lifetimes, then the verbosity goes up pretty significantly. And, dealing with pointers ultimately introduces multiple layers of concepts that you don't necessarily run into with C++/Go/Java.

Yet, with the type inference by default, rust can often feel shockingly terse. Doing collection manipulation is just as terse as any language you could imagine.

I think that's probably where complaints about syntax comes in.

C++ hides a lot of that complexity with move semantics, shorthands, autocoersion, and by making lifetime issues runtime problems. Languages like Go/Java/Python simply push everything onto the heap and try to avoid exposing low level memory semantics.

It's easy for me to see why someone wouldn't like rust. I think it's fine, but I'm also brain broken from perl and php.

josephg
5d ago
> I'd say that rust has a weird level of being both verbose and terse in strange ways. If you ever have to deal with lifetimes, then the verbosity goes up pretty significantly.

I find rust generally more terse than both C and - especially Go, to which rust was compared upthread. Writing out lifetimes explicitly can be confusing. But I don't think it adds that much syntactic noise. Maybe 1/20 functions in my code have explicit lifetimes. That will confuse beginners, but I don't think its too bad once you're used to them.

> And, dealing with pointers ultimately introduces multiple layers of concepts that you don't necessarily run into with C++/Go/Java.

This is my #1 complaint about rust's syntax. If you ever need to interact with raw pointers within unsafe blocks, I feel like the language really fights you. It seems so strange, too - since unsafe blocks are exactly the place where it matters the most that my code is easy to read. Improving the syntax around pointers (for example by adding C's -> operator) would make unsafe blocks clearer.

vacuity
5d ago
I'm very vocal that I don't like Python syntax, but I wouldn't refuse to write Python because of the syntax. If I had reason to write Python, I would grumble a bit but write the Python.
baq
5d ago
No need to like it. It isn’t brainfck and does the job.
claudiug
5d ago
in the beginning I also hate it, but now is fine.
tux3
5d ago
1 reply
>I think cargo is better than cmake

That is an understatement. I can't think of a build system that has spawned more attempts to find something better than CMake has.

There have been so many people trying to make their own C/C++ build system and/or package manager out of sheer spite for CMake that it's frankly hard to keep track.

In fairness to them and to CMake, it's not a simple problem to solve. To truly know CMake is to wish you didn't, that way someone else would have to maintain it.

bluGill
5d ago
1 reply
You seem to forget about autotools. Cmake is ugly but I'll take it over autotools.
danudey
5d ago
1 reply
As an end user: at least with autotools it's easy for me to see the available configuration options with ./configure --help in a nicely readable way. cmake has -LAH but it's still... kind of awful.

At least it knows how to use ninja though.

bluGill
5d ago
2 replies
Problem is autotools doesn't work when cross compiling - the options are there but there is always something wrong, and it isn't easy to fix. cmake can at least get that right. Note that I cross compile a lot of code so this matters to me, if you just do the common thing autolools might work - but make would as well then.
apitman
5d ago
1 reply
If you find yourself doing a lot of cross compiling C check out the Zig build system.
bluGill
4d ago
I am not going to rewrite the build system of a third party library.
josephg
5d ago
Yeah; generally I find CMake rules are much easier to read and modify than autotools and makefiles. With Makefiles there’s about 18 different ways to write a rule to compile something, and I find I need to go hunting through a bunch of files to figure out how this makefile in particular defined a rule for compiling this C file in particular. CMake is much higher level. I can just see all the higher level targets, and how they’re built. Then - orthogonally - I can modify the build system that CMake uses to compile C code. It makes a lot more sense.

But I’d take cargo over any of this stuff. Cargo means I don’t have to think about compiler flags at all.

WhyNotHugo
5d ago
5 replies
Cargo is absolutely awful. It might be better than cmake, but it still the worst part about Rust. It’s completely opaque, and intermixes a huge pile of different functionality.

Distributing Rust software is the pain that it is mostly because of how Cargo works. It’s pretty much impossible to sanely distribute something that isn’t a headache for downstream to consume.

ModernMech
5d ago
1 reply
Can you expand on your reasoning? Because the opposite seems to be true when it comes to projects like uv. People love the single-file executable -- easy to just compile that for a platform and have your users download it. It seems like the uv project is having a good time with that model, so I think they show it's not "impossible". Maybe they're doing something different I'm not aware of? Or maybe your use case is different, so what's impossible about your situation?
quantummagic
5d ago
Isn't it also the npm model?
josephg
5d ago
1 reply
Can you say more?

I’ve found it a joy to use compared to CMake and friends. How does it make it harder to consume something downstream? Seems easy enough to me - just share the source crate.

Are you trying to distribute pre compiled code or something like that? I can see how that would be harder - cargo doesn’t really support that use case.

How would you improve cargo?

WhyNotHugo
4d ago
1 reply
> just share the source crate

That’s a nice concrete example of something that sounds simple but is a nightmare.

Let’s be clear: the goal is to distribute a tarball which the receiver can build. Crates won’t be packaged in the target host (that’s part of Rust’s design), so we don’t have any choice but to include them too.

But there’s no simple way of gathering all of these. “cargo vendor” fetches all transitive dependencies for all platforms. So if any dependency supports windows, you end up with 400MB(!) of windows-only dependencies, even if your project doesn’t target windows. This makes “cargo target” useless.

There’s “cargo-vendor-filtered”, a huge hack around this bug, but it’s also broke in subtle ways.

In the end, if you want to distribute a tarball which a downstream can build, you can’t. Cargo works online only.

Like I said: cargo is too opaque. There’s no command to generate a list of files that it would download for a build. There’s no command to fetch all “real” dependencies. It too opaque an monolithic, doing everything in one indivisible way. This is a great experience for the developer, but awful for anyone else.

josephg
4d ago
> Let’s be clear: the goal is to distribute a tarball which the receiver can build.

Thanks for clearing that up. What problem does that solve? I've never tried to do that, but I can see how it would be a pain in the neck.

I wonder how hard that would be to fix. It doesn't sound like a difficult feature to implement in cargo. I wonder how amenable the cargo devs would be to adding something like that?

hardwaresofton
5d ago
> Cargo is absolutely awful. It might be better than cmake, but it still the worst part about Rust. It’s completely opaque, and intermixes a huge pile of different functionality.

"Absolutely awful" strikes me as wild hyperbole -- you also meant it this way as well, right? What toolchains are not absolutely awful in your mind?

Cargo isn't perfect by any stretch of the imagination -- there are a few common complaints that people have and a bunch of sharp edges (most of which have a github issue that has been open for years), but... "absolutely awful" has to be hyperbole.

crote
5d ago
That sounds a lot like the issues some Linux distros are running into, where they expect to be able to ship one single blessed pre-compiled version of every library, and have each app load it dynamically at runtime.

But that's just not how Rust works: it's trying to fit a square peg in a round hole, and it isn't Cargo's fault that you have trouble with it.

tuetuopay
5d ago
Uuuh how so?

Cargo is a blessing for any source-available project. All bundled up, a `cargo build` away. Because don't you dare say CMake or autotools are better, that's just the stockholm syndrome kicking in because you're familiar with it.

Seriously, how a CMakeLists.txt can even be compared to a Cargo.toml file? One is imperative full of arcane conditions everywhere filled with boilerplate, while Cargo.toml is a declarative manifest of the package?

Though there is one very sore point when distributing software, and that is for distribution package maintainers, because the whole ecosystem has been built around the C model and dynamic linking. That is not even the fault of cargo, since Rust's ABI is not stable thus dynamic linking would not work most of the time. Another thorn is generic stuff, which needs to be monomorphized, and as such don't work with dynamic linking (without Box<dyn>); C++ actually has the same issue and is why there are so many "header only" libraries for it.

johnisgood
5d ago
I dislike Rust, but I would definitely prefer it over the "Android Studio Java / Kotlin thing", for sure.
tick_tock_tick
5d ago
3 replies
I mean we know for sure Rust is unsafe there is whole bug tracker dedicated to all the ways it's unsafe. My favorite is that you can cast any lifetime to static no matter how short it actually is in 100% safe Rust.

(doesn't mean it's not an improvement on C++)

j-krieger
5d ago
1 reply
This doesn't 'cast' anything. The compiler prevents this because it would allow references that outlive their owners. Freely 'casting' only works for data that is static in nature anyways, at which point a coercion is taking place. Any other way involves `std::mem::transmute` or `Box::leak` and the like.
tick_tock_tick
5d ago
1 reply
Here is a nice segfault in perfectly legal safe Rust https://play.rust-lang.org/?version=stable&mode=debug&editio...

I'd call it casting thought technically maybe it's not you might want to call it something else? You don't need transmute or leak. The issue is only 10 years old now https://github.com/rust-lang/rust/issues/25860

dwattttt
5d ago
Yes, that's an existing soundness hole in the compiler. You won't accidentally code it up yourself though.

If the bar is "deliberately malicious code results in a segfault", get back to me when they fix

  memcpy(0x10000, 0x20000, 0x10);
EDIT: and even that's being charitable; the Rust issue is viewed as a compiler bug which should be fixed.
krukah
5d ago
I think referencing the well-known cases in cve-rs[1] is quite a bad faith effort. Of course if you try reeeally hard to write unsound code, you can write unsound code. An edge case in the type system downstream of lifetime variance rules is simply not something that matters in any practical attempt to write safe software. I find the tracker interesting since it probes the boundary of the compiler, but it says absolute nothing to the effect of "Rust is unsafe".

[1] https://github.com/Speykious/cve-rs

ViewTrick1002
5d ago
The unsound bug tracker is were my heart gets all warm and fuzzy in Rust land.

All the ways to coerce and poke the implementation of what should be safe constructs to produce unexpected garbage - and people spending time fixing the issues because they are treated as bugs.

It’s like the best possible advertisement for ”we enable soundness and correctness for all your programs.”

https://github.com/rust-lang/rust/issues?q=state%3Aopen%20la...

ActorNightly
5d ago
2 replies
Id like to see dev time in Rust vs C++, but generally, I sort of agree. If you use modern C++ with all its features, Rust is generally a better alternative.

That being said, it would be pretty easy to implement some pointer semantics even in C that can do 95% of what Rust does.

kibwen
5d ago
1 reply
> That being said, it would be pretty easy to implement some pointer semantics even in C that can do 95% of what Rust does.

Making a language with memory-safe pointers isn't hard. Making a language with memory-safe pointers that doesn't rely on sandboxing, a virtual machine, or other dynamic checks which produce runtime overhead--thereby disqualifying one from being considered for this domain in the first place--is nontrivial.

ActorNightly
4d ago
Rust has things that have dynamic runtime check overhead that are often used. Reference counters, array size, e.t.c You have to have runtime checks because of Rice's theorem.

The only way around this would be to have a absolutely strict type system that defines the finite sets of data that memory can hold.

But for compile time checks, its not hard. For example, the I would do it C is that every pointer gets an optional permission id through some syntax when created. Any expression involving modifying that pointer needs to have the appropriate permission id stated, any dereference operation needs to have the appropriate permission stated, and free is only limited to the function where the pointer was created with malloc. Then any pointer created in assignment from an expression involving that pointer inherits the permission id.

So you simply have a system of tracing where memory gets used.

But all of this is overkill tbh, when you can just use existing static memory analyzers that pretty much do the same thing. And coupled with dynamic memory analyzers like valgrind with appropriate testing, you don't even need to do runtime checks within your code.

super_flanker
4d ago
And tell me how that pointer semantics would do * a very strict type checking * Pattern matching * Algeberic data type

Plenty of people don't write Rust for additional memory safety, they write Rust because the features provided by it is overall very balanced & encourages developer to write code which handles almost all edge cases.

pjmlp
4d ago
Nope, Rust compiler depends on LLVM and GCC (ongoing), both written in C++.

Then there are enough industry standards that are defined for C and C++, where Rust isn't even visible.

jandrewrogers
5d ago
It really depends on the type of software.
masklinn
5d ago
4 replies
Most of these is confirmation of easily observable reality, but the 4x difference in rollback rates, jesus christ.
bla3
5d ago
2 replies
If they use Rust for new code and C++ changes are all in old code, this could be explained just by older code being more risky to change.
nixpulvis
5d ago
2 replies
Funny, another commenter on this post was saying the opposite, that Rust was likely being used to just port existing features and that was easier because there were probably good tests for it already.

If you've actually written considerable amounts of Rust and C++, these statistics don't require justification. In my opinion it's completely expected that Rust code is easier to write correctly.

kridsdale1
5d ago
2 replies
I’d say the same applies for Swift vs ObjC.

Let’s end the C era.

manmal
5d ago
2 replies
Apple should have modernized ObjC instead of making Swift the lingua franca. Both speed of iteration and flexibility (on which web-stack-rivaling productivity features would have been possible) are gone forever.

Swift Concurrency is a tire fire that not even their async-algorithms team can use completely correctly, and useful feature like typed throws are left half finished. The enormous effort the constant further bastardization of Swift takes, is at least in part the reason for the sorry state dev tooling is in. Not even a 4T dollar company can make a reliable SwiftUI preview work, in their own IDE. Variadic generics (a seemingly pure compiler feature) crash at runtime if you look at them the wrong way. Actors, the big light tower of their structured concurrency, are unusable because calls to them are unordered. They enforce strict concurrency checking now, but the compiler is too dumb to infer common valid send patterns; and their solution to make this abomination work in real codebases? Intro a default that lets _everything_ in a module run on the main thread per default!

</rant>

ModernMech
5d ago
1 reply
Swift has so many issues they would honestly be better off just moving to Rust rather than fix Swift. Seriously. The fact that it's so easy to get the compiler to spend exponential time resolving types that it very often just shits the bed and begs you to rewrite your code for it to stand a chance is shameful coming from, as you say, a $4T company. Points to deep problems with Swift.
manmal
5d ago
I fully, totally agree with this. The recent fixes for concurrency makes Swift look like a poor man’s Rust anyway.
kridsdale1
5d ago
I don’t disagree with anything you said.
girvo
5d ago
While the C calling convention continues to rule operating systems and FFIs, I think it’ll continue to limp along. Hopefully one day that can be fixed, it’s annoying that C is what I have to reach for to call SomeLib no matter what language I’m using
danudey
5d ago
3 replies
As a relatively novice programmer who's worked in tech for decades but not as a software developer: I take issue with the idea that you need to write considerable amounts of Rust and C++ for these statistics to be expected. In fact, despite Rust's initial vertical learning curve I'd say that any junior developer trying to implement anything with any degree of complexity at all in Rust and C++ would see the benefits.

At the very least, the fact that IDE integration can tell you all kinds of stuff about what you're doing/doing wrong and why accelerates things greatly when you're starting out.

baq
5d ago
1 reply
The problem with junior developers is that Rust will be incredibly frustrating to learn by perturbation, because the compiler will reject most random changes to the code. Which is the point of course, but C++ will compile programs which then crash, giving you a very misguided feeling that you’re making progress, but this is very important in the process of gaining new skills.

I don’t see a way around it, programming without garbage collection is hard, Rust makes it very clear very quickly, which is also the point, but this is at odds with making the learning curve accessible.

danudey
4d ago
> The problem with junior developers is that Rust will be incredibly frustrating to learn by perturbation

Yes, this is the biggest issue with Rust that I've seen; most language will let you do something wrong and then as you learn you get better. Rust will refuse to compile if you're not doing things correctly (and normally I would put 'correctly' in quotes but correctness in Rust is well defined).

The first time I tried to experiment with learning Rust was a disaster. I just wanted to decode some JSON and filter it, but -- oops! -- I don't own that variable. Okay, well I can pass it somewhere else mutably, right? But then that function does the work and returns something that... what's a lifetime? What's a 'a mean? How do I... screw it, I'll go back to Python.

Eventually, after the tooling and the tutorials got better I came back to it and really enjoyed what I've seen so far and even rewrote one of my own personal tools in Rust[1] to experiment with. It's nothing impressive, but it was fun to do.

[1] https://github.com/danudey/rust-downloader

marcosdumay
5d ago
Oh, the more junior the developers, the quicker they will get any benefit. That's common for any language that enforces correctness, but the C++ vs. Rust comparison isn't even fair; C++ is an incredibly hard language to use.

Now, if they actually "see" it is another matter.

nixpulvis
5d ago
Oh I totally agree with you.

The logic in my comment wasn't that you need to have written considerably amounts of code to be expecting this, just that to not be expecting this would make me think you hadn't. If that makes sense.

On your second point, I think IDE integration for C++ is similar as it is for Rust. Just Rust errors and tooling are a million times better regardless of IDE.

nicoburns
5d ago
I think they're comparing new code in Rust vs new code in C++.
ActorNightly
5d ago
4 replies
The issue with most codebases is nobody thinks about starting out with acceptance testing system.

The way it should work is that before even writing code, you design a modular acceptance system that runs full suite of tests or a subset based on what you are working on.

This is essentially your contract for software. And on a modular level, it means that it scopes down the contracts to the individual sub systems. And things like memory and cpu runtime constraints are a part of this.

If you have this, you basically replace what the Rust compiler is doing for you with tests. Memory leaks are caught. However, as a benefit, you also can verify changes in the dev cycle with things like performance degradation, all in the same system.

ikety
5d ago
1 reply
I'm not sure that nobody thinks of this. We just have a finite amount of time. Usually with a solid approach, you get solid performance. Fixing a performance related bug rarely when it comes up, is still a time savings over designing this kind of rigorous process from scratch, and getting everyone on board with it.

Getting rid of a whole host of bugs due to the compiler is a big deal because you won't have to design this extra acceptance system or deal with keeping an entire organization disciplined by it. If you can solve this seamlessly I think that's an interesting product that others would be very interested in.

ActorNightly
4d ago
> because you won't have to design this extra acceptance system or deal with keeping an entire organization disciplined by it.

This is just a matter of tooling. (On that note, here is a free business idea, prompt engineer an LLM agent that sets this up for you)

While the compiler does do a lot of things for you, you still end up with things that you should check because compiler doesn't understand your program logic. If Rust was a absolutely strict typed language, where basically everything had a type that defined what data it could hold, then it would be a different story. For example, when parsing a json into an object, instead of strings/numbers/bools, every single field has a finite set of values that it can hold. Then the compiler can figure out a lot of things. For example, if you try to convert a string to int, if the string field type doesn't have a defined regex expression it must match, then the compiler can catch this.

Anything less then that, you are better of writing the validation system once and reusing it for all your code bases now and in the future.

IshKebab
5d ago
1 reply
Writing the tests before the code only really works if there's an interface that's fully defined and well specified in advance. There are definitely times where that is the case, but in my experience it usually doesn't work like that.
ActorNightly
4d ago
1 reply
It doesn't work like that because people are afraid to change things up. Lots of time people want to see working code that works for nominal use cases before hand.
IshKebab
4d ago
No it's because often designing the interface and writing the implementation go hand-in-hand.
joshuamorton
5d ago
1 reply
I will simply say that Google is one of the few places that, to a first approximation, has this. We have our (pretty good) suite of tests. We can run only affected tests. We can them with instrumentation (*SAN), we can run them under various memory and CPU limits, we can run them 1000 times in parallel to deflake.

Anyway Google has all of that, and yet still finds this improvement.

surajrmal
5d ago
Android testing standards aren't necessarily the same as the rest of Google. At least historically it wasn't, I'm sure things have improved.
josephg
5d ago
1 reply
> The way it should work is that before even writing code, you design a modular acceptance system that runs full suite of tests …

Sometimes. It depends on what you’re working on.

Part of the fun challenge in writing software is that the act of programming can teach you that you’re wrong at every level. The syntax can be wrong. The algorithm you’re implementing can be wrong. The way you’re designing a module can be misguided. And you might be solving the wrong problem entirely! Like, maybe you spend weeks adding a feature to a game and it makes the game less fun! Oops!

Tests formalise beliefs about what you want your code to do, at some level of abstraction. But if those beliefs turn out to be wrong, the tests themselves become a headwind when you try and refactor. You want those early refactoring to be as easy as possible while you’re learning a problem space.

Now, some programs don’t suffer from this as much. If you’re implementing a C compiler or drop in replacement for grep, you have some clear acceptance tests that will almost certainly not change through your project’s lifecycle.

But not all problems have clear constraints like that. Sometimes you’re inventing a programming language. Or writing a game. Or making a user interface. In my opinion, problems that are fully constrained from the start are some of the least interesting to work on. Where’s the discovery?

baq
5d ago
> Part of the fun challenge in writing software is that the act of programming can teach you that you’re wrong at every level. The syntax can be wrong. The algorithm you’re implementing can be wrong. The way you’re designing a module can be misguided.

I see you sir haven’t had experience with writing drivers for prerelease hardware. You’re right in these cases of course, you just aren’t right enough - the real fun starts when you can trust neither the hardware, nor the BIOS, nor the OS in addition to all the above.

anttiharju
5d ago
I found it interesting that the rollback rate remained more or less constant despite size differences.
MBCook
5d ago
We all knew rust was safer. It was the 1000x number that surprised me.

Which is more that rust isn’t that safe in my mind, it’s that bugs are that prevalent. I never would have guessed that.

That 4x rate is very impressive too.

Great seeing all this data from a large big complicated codebase.

pjmlp
5d ago
2 replies
Note that Google still doesn't have official support for using Rust in Android userspace, though.

Despite all pluses on the blog, NDK only supports C and C++ tooling, same on Android Studio, and it is up to the community to do the needful work, if anyone feels like using Rust instead.

quotemstr
5d ago
1 reply
Nobody's stopping you from using the NDK to compile Rust though. Android's ABI is just an ABI like any other. The system doesn't care if you built an .so using Rust or anything else so long as it plays by the rules.
pjmlp
5d ago
1 reply
Some people rather reach out for first party support, instead of filling in the gaps for the big boys.
dwattttt
5d ago
1 reply
By first party support, would you be expecting a Rust toolchain shipped in the NDK, or maybe Rust bindings shipped in the NDK?

I could see the latter, although I'd still question whether they should be special cased in terms of a Rust dependency compared to bindings being hosted on crates.io.

Or maybe they should ship scripts that shell out to an existing Rust toolchain.

pjmlp
5d ago
2 replies
I expect Rust being documented here,

https://developer.android.com/ndk

I expect the whole Rust build process being part of Android Studio, including mixed language debugging between Java, Kotlin and Rust.

I expect all NDK APIs to have Rust bidding crates.

I expect that Android developer forums also care to support devs using Rust.

And anything else that I forgot to mentioned, that is provided for Java, Kotlin, C and C++.

flohofwoe
5d ago
3 replies
The Android NDK just barely supports C and C++ either, unless you're ok with 1990's tooling standards. The whole thing feels like it's maintained by two dudes locked in a Google basement somewhere. I doubt they have the capacity to deal with Rust support in the NDK, unless there's a big strategic change in Android tooling.
cogman10
5d ago
1 reply
I'm not sure what you mean by this. Looking at a sample app [1] for the NDK, the tooling appears to be gradle and Cmake. Cmake isn't the newest of tools, but it's also not that dated.

[1] https://github.com/android/ndk-samples/tree/main/endless-tun...

flohofwoe
5d ago
1 reply
Both Gradle and CMake have a strong late 1990's smell to them. While CMake is sort of a necessary evil in the C/C++ world, there's no excuse for dragging Gradle into the NDK, combining both build tools leads to a complexity explosion that rarely works and tends to break after either the NDK or SDK is updated, or somebody merely looks the wrong way at the build files.
pjmlp
5d ago
1 reply
CMake is the defacto tool adopted by the industry, regardless how many love to hate it.

You can use BSD Make instead of Gradle, isn't UNIX great?

flohofwoe
5d ago
> You can use BSD Make instead of Gradle, isn't UNIX great?

So the NDK officially supports creating an APK just with a Makefile? That would be news to me (and great news at that).

It is possible to cobble together a build process that directly calls various Android SDK command line tools to build an APK directly from a C/C++ build tool without involving Gradle, but as far as I know, most of those invoked cmdline tools are deprecated and building APKs outside Gradle is not 'supported' by the Android SDK/NDK (e.g. it may stop working at any time).

quotemstr
5d ago
1 reply
Huh? "Barely"? What are you talking about? The NDK supports compiling C++ just fine. There are CMake files, among other things, ready to use --- as well as Soong native configurations. CMake is under active development. Other toolkits are within easy reach: for example, Meson works fine. Also Bazel. Hell, even autotools can be made to work.
flohofwoe
5d ago
2 replies
Sure, building C/C++ code into an .so file kinda works but that's about it, try building the APK entirely with cmake, that's simply not supported, you'll have to integrate with Gradle. The result is a complexity clusterf*ck that's a nightmare to maintain.

The NDK team should take a long hard look at Emscripten to get some inspiration how native code development is integrated into a 'native-hostile' runtime platform.

pjmlp
4d ago
1 reply
Interesting that you give Emacripten as example, given how badly documented its whole tooling is, and is a pain to prevent it from downloading the Java tooling and everything else that is already downloaded, unless using the Github installation from source.
flohofwoe
4d ago
The one great feature of Emscripten is that you can do:

    emcc hello.c -o hello.html
...and it produces an output that's immediately runnable in a web browser instead of just a bare .wasm file which needs to be wrapped in a html with additional steps.

E.g. emcc is a drop-in replacement for gcc/clang which can be used directly in a C/C++ build tool as a C/C++ compiler and linker while still doing the right thing (producing a runnable .html).

The NDK equivalent would be a gcc-compatible compiler wrapper which can do this:

    ndkcc hello.c -o hello.apk
...such a simple and obvious thing to do, yet it doesn't happen because the Android SDK/NDK developers have no clue about developer workflows outside of their precious Java ivory tower.

> and is a pain to prevent it from downloading the Java tooling and everything else that is already downloaded,

That's a feature, not a bug. It's trivial to install different emsdk versions side by side, each entirely self-contained and without polluting the system or requiring external dependencies.

The separate Java dependency also has been dropped a while ago, since the only remaining component that depends on Java is the optional Closure compiler step, and that comes now with an embedded Java runtime (as far as I'm aware at least).

quotemstr
4d ago
1 reply
I've never understood why developers fixate on having "pure" NDK-based apps. It's really not that hard to implement Activity, Service, etc. as JVM in Kotlin or Java and call the native code via JNI. What do you think the "pure native" app layer in Android is doing if not that?
flohofwoe
4d ago
It's not about the idea of writing a pure native app, but about making it easier to build a hybrid app without an exploding build process complexity.

Emscripten is again a perfect example of how it should be done: FFI calls into Javascript are trivial (it's even possible to embed JS code into C/C++ source files), and I can build a complete hybrid WASM/JS app without having to bring in a completely different build system that's completely alien to the C/C++ world.

It even works without any build system at all since the emcc compiler/linker wrapper is also the Javascript bundler, yet the entire emcc wrapper acts like a GCC/Clang compatible compiler/linker with some extra Emscripten specific flags. The Emscripten SDK didn't jump into existance like this, the difference to the NDK team is that the Emscripten team actually listens to their users.

pjmlp
5d ago
Nope it clearly supports ISO C 11 and ISO C++17.

I do agree the NDK team is rather small.

eggy
5d ago
2 replies
Don't forget this list of expectations for SPARK [1] too, if you want even safer, high-integrity, and formally verified code on Android!

[1] https://www.adacore.com/about-spark

pjmlp
5d ago
Android has zero lines of Ada code, why should I care about it in this case?
iknowstuff
5d ago
I think we can indeed forget about it.
apitman
5d ago
1 reply
They've been trying to strangle the NDK for years. You can't even make an app without a ton of glue code on the JVM.
pjmlp
5d ago
True, NDK was never intended to make apps, only for games and as helper for native methods, since it was introduced in Android 2.1.

The point is about the official support for using Rust exactly for the same use cases.

petcat
5d ago
3 replies
At this point I feel like it's no longer an uphill climb to get Rust into foundational, mission-critical code adoption. The benefits are so obvious. Maybe it's just a lingering religious war?

In any case, I'm glad we're seeing more and more evidence and case-studies of why "rewrite it in Rust" isn't just a meme.

vbarrielle
5d ago
4 replies
But the approach here is "write new code in rust", not rewrite.
gpm
5d ago
2 replies
Eh, I don't think it's actually one or the other. Google has taken on rewriting some more problematic components in rust. See for example:

Binder kernel driver: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...

Media codecs: https://www.androidauthority.com/android-16-in-process-softw...

GeekyBear
5d ago
This is also happening at Microsoft:

> Rewriting SymCrypt in Rust to modernize Microsoft’s cryptographic library

https://www.microsoft.com/en-us/research/blog/rewriting-symc...

nicoburns
5d ago
Yeah, there's also a freetype replacement https://github.com/googlefonts/fontations

I think they're trying to avoid rewriting things for no reason though. The things being rewritten tend to have a history of security problems or other issues that would be cause for a rewrite even if it wasn't in Rust.

wiseowise
5d ago
1 reply
Google rewrote Android's Bluetooth stack in Rust.
robocat
5d ago
Also mentioned:

  Chromium: Parsers for PNG, JSON, and web fonts have been replaced with memory-safe implementations in Rust
VWWHFSfQ
5d ago
Sure, but at a macro level the approach is still to "rewrite" Android subsystems in Rust. Just slowly.
SAI_Peregrinus
4d ago
That ends up being "rewrite it in Rust" because new code includes changes to existing code. A nice thing about Rust is that you can generally rewrite things piecewise there's no need to switch everything at once.
danudey
5d ago
2 replies
Go look at the comments on any Phoronix article involving Rust in any way and you'll see that it's 80% rust haters making all the same arguments every Rust hater makes. You can implement the same safety features in C++ and assembly if you know what you're doing! You can still write bugs in Rust! I know someone who tried to learn rust and he accidentally deleted his home directory so everyone may as well stick to C!

It's all nonsense, but it would be hilarious if it weren't so ignorant.

ActorNightly
5d ago
4 replies
>It's all nonsense,

How is any of that wrong?

IshKebab
5d ago
2 replies
1. You don't know what you're doing - everyone makes mistakes.

2. You can still write bugs in Rust but the point is you are far less likely to.

tonyhart7
5d ago
1 reply
Yeah but 1000x less mistake ????? I mean these people behind android project is atleast one of the better engineer but jesus christ if they can improve so much then I dont know how much average joe can benefit from that
AlotOfReading
5d ago
It's not 1000x fewer mistakes overall, it's 1000x fewer mistakes of this one specific family that Rust is designed to eliminate.

They've also seen improvements in developer confidence and onboarding time, but not to the same degree.

ActorNightly
4d ago
1 reply
>You don't know what you're doing - everyone makes mistakes.

I mean if you don't know what you are doing you are going to make mistakes that go beyond memory safety. Look at Log4shell for example.

IshKebab
4d ago
The important thing is the likelihood of mistakes getting past the compiler. According to Google's numbers the likelihood for memory safety reduces by several orders of magnitude, and the likelihood for other kinds of mistakes reduces by a factor of ~4 (depending on how you interpret their numbers).

Just saying "but you can still make mistakes" is dumb and irrelevant and it's kind of disappointing that it's such a commonly bandied non-argument that Google still had to address it in this post.

baq
5d ago
1 reply
It isn’t wrong, it’s misguided. You can write the same code in a Turing machine, too.
ActorNightly
4d ago
1 reply
Sure, but the discussion against Rust is basically saying that you can have the same features without the downsides of using Rust, which is objectively true. For example, memory analyzers like valgrind work great.
danudey
4d ago
If you assume that the only benefit of using rust is built-in valgrind, sure, but there's more to the language than preventing off-by-one errors.

If people don't want to use the language then that's fine, no problem, but a lot of people do want to use the language because it's just a great language to use as well as having memory safety.

danudey
4d ago
It's all correct and also pointless and irrelevant. It all boils down to "Rust doesn't fix every possible problem so why not stick with something that still has every possible problem?"

In other words, they're upset that a new thing isn't popular so they're trying to think of any argument against it, but none of their arguments are relevant. Yes, you can still write bugs in Rust; of course you can. What you can't do is write memory safety bugs in Rust, which are a huge proportion of security bugs that occur. Rust gives you a massive decrease in attack surface automatically.

This is ignoring the ecosystem, which is full of better tooling, better library packaging, better testing, and just in general an overall better language, but instead of trying to argue the language on its merits they're trying to argue that it's not perfect so why bother.

I've also heard the same arguments about C++; 'anything you can do in C++ you can do in C!', which is technically true but ignores the fact that if I want to do something C++ does it usually makes more sense to use C++ to do it rather than e.g. trying to hack the concept of objects, private methods, templates, etc. into C myself.

marcosdumay
5d ago
On the sense that you can write a Rust compiler in C and use it to program your software in a better language, yes, all of that is correct.
pjmlp
4d ago
The irony is that those haters have been doing the same speech since Ada, Modula-2 and Object Pascal early days.

Multics got an higher security score than UNIX, thanks to PL/I.

During the USENET flamewar days, they used to call programming with straightjacket languages.

Also note how proudly they keep digging out Brian Kerninghan complains against Pascal, that disregard the dialects have taken out those issues, and that while Pascal was designed for teaching, Modula-2 was already available, taking care of those pain points, designed for systems programming.

ActorNightly
5d ago
3 replies
Rust makes sense in the case of Android, where the kernel and software is rolled by Google. In the same way that Java made sense for a lot of the backend services in 2010s despite its drawbacks before Node and Python got major improvements in speed and compute became cheaper.

That however is a very niche case where Rust is applicable. The anti-rust people (like me) aren't saying that Rust is bad. We are just arguing against its adoption for everything.

When you see shit like "[...] should be rewritten in Rust because memory safe", it shows that people have no idea what memory safety even is. There is this dumb belief stemming from lack of proper CS education that any code you write can just randomly have memory safety issues.

The downsides of Rust is that its ownership semantics are often cumbersome to write, which slows down development. Rust is also still evolving because of the stuff that happens under the hood. And for a lot of things, where network latency is dominant and cpu cycles are spent sleeping waiting for responses to come back, you don't need natively compiled code in lieu of python or node that are way more flexible and faster to develop in.

So in most cases, Rust is not applicable, when you can write perfectly memory safe code faster.

iknowstuff
5d ago
1 reply
> There is this dumb belief stemming from lack of proper CS education that any code you write can just randomly have memory safety issues.

lol. this take is hilarious in the face of the article you are commenting on. holy cognitive dissonance.

> The downsides of Rust is that its ownership semantics are often cumbersome to write

skill issue

ActorNightly
4d ago
1 reply
>skill issue

Lol, this is actually very ironic considering Rust is handholding you because you don't have the skills to write memory safe code.

Like I said in my other posts, Rust makes sense in very niche situations. The article just proves that it works for the niche case where its applicable. That doesn't mean Rust automatically wins.

iknowstuff
4d ago
Readers, feast your eyes on direct evidence of how facts don’t change people’s minds. You can almost see him putting fingers in his ears and going lalala
AlotOfReading
5d ago
1 reply

    There is this dumb belief stemming from lack of proper CS education that any code you write can just randomly have memory safety issues.
This is effectively true in C and C++ though. Show me a nontrivial project in either of those languages that has never had a memory safety issue and I'll show you a project that doesn't look at quality. Even SQlite doesn't meet this bar, despite incredibly skilled programmers and an obsessive commitment to quality.
ActorNightly
4d ago
1 reply
>Show me a nontrivial project in either of those languages that has never had a memory safety issue

I mean, the linux kernel is a pretty good example. Static analyzers and things like valgrind exist for a reason.

AlotOfReading
4d ago
There's been over a thousand memory safety CVEs in the kernel this year alone [0], the most recent published 2 days ago. Most of these aren't exploitable and are caught before stable, so I went to LWN instead and "scrolled down" until I saw an article that mentioned a memory safety vuln in stable kernels. "Scrolled down" is in quotes because there was no scrolling involved. Today's Friday security updates post links USN-7861-3 [1], which includes fixes for memory safety issues like CVE-2025-37838 [2].

[0] https://www.cvedetails.com/vulnerability-list/vendor_id-33/p...

[1] https://lwn.net/Articles/1046495/

[2] https://nvd.nist.gov/vuln/detail/CVE-2025-37838

baq
5d ago
1 reply
> There is this dumb belief stemming from lack of proper CS education that any code you write can just randomly have memory safety issues.

I sense a lack of statistical education here.

ActorNightly
4d ago
1 reply
If you say that something can happen, then whether to use a tool to mitigiate it should also be qualified. The conversation around Rust is that bugs WILL happen, which is not true.
baq
4d ago
we'll have to agree to disagree.
pizlonator
5d ago
1 reply
This isn't control for confounding factors.

For example: folks are more likely to rewrite stuff that is well-understood, and stuff that is well-understood is going to have shorter review times and lower rollback rate.

That gnarly horrid mess that only a few greybeards grok and has massive test coverage, a long tail of requirements enforced by tests and experience, and a culture of extreme rigor? Longer reviews, more rollbacks, and less likely to be rewritten.

littlestymaar
5d ago
1 reply
> That gnarly horrid mess that only a few greybeards grok and has massive test coverage, a long tail of requirements enforced by tests and experience, and a culture of extreme rigor? Longer reviews, more rollbacks, and less likely to be rewritten.

I'd say that this is likely the most likely to be rewritten actually, because high test coverage is a massive enabler in such a rewrite, and because having a project that “only a few greybeards grok” sounds like a big organizational liability.

That being said, and while I'm pretty convinced that Rust bring massive benefits, I agree with you that these measurements shouldn't be taken as if it was a rigorous scientific proof. It's more of one additional anecdotal evidence that Rust is good.

pizlonator
5d ago
1 reply
> It's more of one additional anecdotal evidence that Rust is good.

But that means it's likely to be the worst kind of science:

- Group of people agree that Rust is good. This is a belief they hold.

- Same group of people feel the need to search for argument that their belief is good.

- The group does "science" like this.

And then the rest of us have a data point that we think we can trust, when in reality, it's just cherry picked data being used to convey an opinion.

dwattttt
5d ago
1 reply
> And then the rest of us have a data point that we think we can trust, when in reality, it's just cherry picked data being used to convey an opinion.

Calling what Google did here "science" and cherry picked is quite a disservice. It's observational data, but do you have any objection to the methodology they used? Or just (assumed?) bad vibes?

pizlonator
5d ago
2 replies
In science, you go out of your way to control for confounding factors.

This isn't that.

dwattttt
5d ago
Having been close to someone who went through the PhD process to a career in research, this is a sadly common but romantic and incorrect view of science as practiced in the world today.
gpm
5d ago
> In science, you go out of your way to control for confounding factors.

There's tons of observational science done in a very similar fashion to the article where there is simply no way to control for confounding factors for the same reason that there is simply no way to properly control for it in the data available.

242 more comments available on Hacker News

ID: 45918616Type: storyLast synced: 11/16/2025, 9:42:57 PM

Want the full context?

Jump to the original sources

Read the primary article or dive into the live Hacker News thread when you're ready.