Live data from Hacker News

Java is becoming more like Rust, and I am here for it

joshaustin.tech

31–40 of 71 posts

Re: Java is becoming more like Rust, and I am here for it

#31

What "immutable" means in Rust is very different from Java or any FP language for thar matter. In Rust you can take any data structure and mutate it. There are hardly any invariants that you can force, unlike in Java. For example, strings are mutable in Rust. This, coupled with not being a language managed by GC, makes persistent data structures not practical or desirable. Of course, mutability in Rust is very contro…

> In Rust you can take any data structure and mutate it.

What if a memory location not marked "mut" is allocated by the compiler in the executable TEXT segment, so the virtual memory page is itself mapped read only?

Are you certain you can get away with what you said, within the promises of the compiler?

Re: Java is becoming more like Rust, and I am here for it

#32
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

This was my knee-jerk too. It’s great to see some of the good bits of ML flow into new languages, but this isn’t some Rust-specific feature. As an annoying side-effect tho, it’s been harder to pitch FP in these existing spaces since now “we have FP at home” in the existing language (even if the ergonomics are worse, it looks uglier, the language idioms & existing programs don’t match the style, & ’the bad parts’ + footguns still exist).

Re: Java is becoming more like Rust, and I am here for it

#33
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

Haskell + Ada + '{}' == Rust

Re: Java is becoming more like Rust, and I am here for it

#35
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

Everyone hasn't forgotten, they just aren't learning things from the bottom-up. It's Rust-like to the author because that's probably where he learned about it in the first place.

Re: Java is becoming more like Rust, and I am here for it

#36

I'm surprised there aren't more people using Java nowadays. The JVM is rock solid, the speed is really good, and the latest changes are making the language much more modern. Maybe people are actually using it but not talking about it? Not sure.

Why do I want an unnecessary VM in the way, and no access to native APIs?

Re: Java is becoming more like Rust, and I am here for it

#37
post #9
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

> Disclaimer: In no way am I claiming that these Rust features caused their counterparts to appear in Java > I would not be surprised if Kotlin and/or Scala were more influential in bringing this to life. But yeah, I agree, generally weak article. I don't think it shows that "Java is becoming more like Rust" at all, because of the two listed features.

A better way to say it is that Java is becoming more like Kotlin, which in turn was halfway between Java and Scala.

Re: Java is becoming more like Rust, and I am here for it

#38
post #3

The article is using immutable records and sum types as “more like Rust” and I am just sitting in the corner, wondering whether everyone has forgotten that these things came from FP in the first place. In my mind, a language isn’t “Rust-like” because it uses concepts we learned in FP. We have languages like Haskell and, before it, ML. And I know ML didn’t invent it. We also have Scala, and for Scala, we don’t even ha…

They didn't come from FP either. Records and variant records were common features of imperative languages (Algol, Pascal, Ada, Modula). They were considered to be subsumed by classes when OOP became popular.

I believe FP did give us the pattern matching syntax for destructuring variants though.

Re: Java is becoming more like Rust, and I am here for it

#39
post #7

The examples are good but I am not really a fan of the title. It's not really Java becoming more Rust like, Rust didn't invent these concepts. I talked to dl about some of these concepts going into Java a decade ago because of Scala. In PL a lot of concepts have been around for a very long time. Java is becoming more type safe, or more functional would be better titles I think. But the comparison code between Rust an…

>It's not really Java becoming more Rust like, Rust didn't invent these concepts.

I see what you're saying, and definitely agree in a way, but also those two things aren't incompatible.

Rust didn't invent those concepts, but Java is becoming more like it by incorporating them. If Rust is much more widely known about than other languages that have those things, it may be more informative to people to hear "Java is getting some stuff from Rust" than to hear a statement that apportions the credit in more detail.

Re: Java is becoming more like Rust, and I am here for it

#40

I'm surprised there aren't more people using Java nowadays. The JVM is rock solid, the speed is really good, and the latest changes are making the language much more modern. Maybe people are actually using it but not talking about it? Not sure.

Generic erasure inside the JVM is a fundamental flaw.
Post reply on HN