Hacker News new | ask | show | jobs
by jeroenhd 979 days ago
There's a reason Chrome is mostly written in C++. Android's JVM system is a collection of Java wrappers around C++ libraries. There's some overhead in that translation layer, and it's unfortunate that you can't skip it. Even Google's own Flutter uses a C++ engine to run Dart applications.

Kotlin (and Java) is fast enough for many applications, but even with the recent advancements in ART, does have overhead compared to pure native code. I can't think of a reason why the API interaction overhead would pose a problem, but if Google themselves can find use cases for almost JVM-less apps, I'm sure there are reasons to give a Rust version a try.

4 comments

> Android's JVM system is a collection of Java wrappers around C++ libraries.

This isn't even remotely true and it's obvious if you'd ever looked closely at Android. This take is as bizarre as saying that whole web/JS/React ecosystem is "just" wrappers on top of Skia.

> There's a reason Chrome is mostly written in C++.

And for that same reason, you don't see many apps do the same thing. Any time Chrome needs to request a permission (access files, location, etc), it _has_ to use the system-provided Java APIs.

> Even Google's own Flutter uses a C++ engine to run Dart applications.

As do most games, so you can essentially think of Flutter as a game engine that renders apps.

> Android's JVM system is a collection of Java wrappers around C++ libraries.

As others have mentioned, this is very much not the case.

> it _has_ to use the system-provided Java APIs.

My original comment was against this. Why should this be the case?

At the same time, GUIs really don’t work nicely/as idiomatically without a GC. Most Rust GUIs do immediate mode only, which is a much more easier problem, and you won’t have to “argue” with the borrow checker constantly. But it would drain the battery of a phone in an hour (it would be the equivalent of running a proper 3D game as your notes app or whatever).
> There's a reason Chrome is mostly written in C++

Yea, security is not a concern. Apparently.

They didn't have Rust around when they started.
That doesn't change anything. Security was simply never what chrome (or webkit to be fair) was built around compared to speed of the insanely inefficient browser stack.