upvote
> That's where these unsafe calls occur.

No, it's not. A relatively common case for unsafe in Rust is in data structures. The data structures in the Java runtime are all written in Java and has almost no use of unsafe (there might be a few, but not becsause of language limitation, but because of initialisation order).

As for the JVM, much of it is a compiler. It doesn't matter what language it's written in, as it generates machine code. Indeed, the vulnerability disclosed yesterday was in a compiler intrinsic, but those are just as common in Rust.

Other than that, the other big piece in the JVM is memory management, and it does, indeed, use C and C++ for memory management, but Rust also uses C (the various implementations of malloc/free in whatever runtime the Rust program is using; BTW, some popular malloc/free implementations are almost as big as Java's most complicated GC).

As for native C/C++ libraries (outside the JVM itself), Java programs do use some, but generally not more than Rust programs.

reply
Not accurate. Most datastructures that use unsafe in Rust are primitives; `Box`, `Vec`, `Rc`/`Arc`, `HashMap` and `BTreeMap`. Of those, only the equivalent to `HashMap` and `BTreeMap` are written in Java, and they can be written in safe Rust as well if you're willing to give up some of the performance (e.g. always initializing - thing that happens in Java as well). More complex data structures (e.g. graphs) can and often are implemented without unsafe at all.
reply