Blog: Comparing Rust & Java

Wherein we look at the similarities and differences of Rust and Java.

6 Likes

It's a quite long blog post. Java GC is probably the best GC. I didn't know that Java interfacing to C was done "badly" on purpose. I think the two languages have quite different purposes, so their niches don't overlap much.

java.io and java.nio, though I’ll admit the latter builds upon the former

It's the other way around - the former builds upon the latter. Most of InputStream/OutputStream implementations are implemented over the corresponding *Channels from NIO.

Also I have a remark about one of flow control "mappings":

if let _ = _ { _ } else { _ } -> if (_ = _) { _ } else { _ }

In Java if (_ = _) only works when the assignment of boolean values happens (because there are no automatic to-boolean coercions, and in Java ifs do not accept arbitrary values, only booleans), and in that case there is little to no sense to check it this way. I don't think there is even a remotely direct counterpart of if let in Java.

Anyway, the post is very nice and informative. I even learned about a library I never heard of before :slightly_smiling:

java.io was there before java.nio – the latter basically built interfaces for the lower level code that was underneath the former all the time.

And it should probably read if (_ == (_ = _)) { .. } else { .. } but that's even longer and doesn't exactly help understand the code.

I didn't know that Java interfacing to C was done "badly" on purpose. I
think the two languages have quite different purposes, so their niches
don't overlap much.

Yes and it has been confessed at Java ONE and other Java related conferences by the language team. Just search for talks related to present and future of Java 9.

Java's uptake in HPT and big data has risen the pressure for value types and a more programmer friendly JNI replacement, but they are only planned for Java 10+ onwards.

@llogiq you have been shamelessly plagiarized by jaxenter.com:

Compare this paragraph:

Another aspect which matters is that a typical Rust program consumes orders of magnitude less memory than an ordinary Java program. Although Java’s GC is very optimized and makes programming rather painless, Rust has a zero-sized runtime, for some large values of zero. There is a runtime, but it consists of establishing landing pads for panics which can even be overridden.

Which appeared on blog - devmio - Software Know-How

With this:

Java’s GC is very optimized, and should be considered world-class. While it doesn’t solve all problems Rust’s ownership system is designed to solve, it makes programming fairly painless. […] Rust on the other hand has a zero-sized runtime, for some large values of zero. Actually there is a runtime, but it consists of setting up landing pads for panics, and even that can be overridden for e.g. embedded or OS development.

Which appeared in https://llogiq.github.io/2016/... no 24 hours before the former was published.

Without giving attribution to you whatsoever. You probably aren't even the only source the "author" stole from.

Something felt unusually familiar when reading the former. Was right. This is just wrong.

6 Likes

The "author" has since silently deleted the article while not admitting any wrong-doing:

https://twitter.com/gabriela_motroc/status/752412692875476992

Luckily we have tools to prove stuff these days:

And luckily the web doesn't forget: Rust vs Java: A tale of two competitive programming languages - JAXenter

3 Likes

Thanks regexident for your stellar detective work. While I personally have no problem with being copied (after all I'm doing this out of a general wish to communicate and spread knowledge), I would have been happier had I at least been asked before the fact.

Which software is that? :slight_smile:

The "software" is a simple Ruby command-line tool of mine that's implementing the "greedy string tiling" algorithm that I happened to have lying around from my NLP course at university. :slight_smile:

2 Likes