News for hackers. Stuff that matters.
Re:Java is becoming more like Rust, and I am here for it by klodolph on Monday March 04, 2024 @01:17PM (#39593871)
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 have to leave the JVM. There’s also F#, which is a kind of cousin-of-a-cousin to Java.

Rust has sum types and immutability because tons of people thought these features were important, and lots of languages adopted them in parallel with the appearance of Rust.

Re:Java is becoming more like Rust, and I am here for it by diggan on Monday March 04, 2024 @01:19PM (#39593893)
> 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.

Re:Java is becoming more like Rust, and I am here for it by lolinder on Monday March 04, 2024 @01:31PM (#39594053)
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 by oefrha on Monday March 04, 2024 @01:36PM (#39594127)
“Java is becoming more like Kotlin” lands you on the lower half of front page at best. “More like Rust”? Instant upvotes, #2 right now.
Re:Java is becoming more like Rust, and I am here for it by vips7L on Monday March 04, 2024 @03:59PM (#39596006)
Except its not becoming more like Kotlin. It's becoming more like ML and OCaml
Re:Java is becoming more like Rust, and I am here for it by mpalmer on Monday March 04, 2024 @01:30PM (#39594045)
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 by anonzzzies on Monday March 04, 2024 @01:40PM (#39594187)
> It's Rust-like to the author because that's probably where he learned

I like about HN that everyone is so friendly about this type of thing. I personally don’t have a lot of patience for people who think new things are the greatest inventions and ‘the old is catching up’ (in this case Java catching up with Rust) while everything came from elsewhere originally. If you want to openly say these things, please research them first and attribute properly. But indeed it is good here we try to educate not shame or insult like some other communities.

Anyway: I would say people should learn bottom-up as we don’t need to invent the wheel every few years that way.

Re:Java is becoming more like Rust, and I am here for it by mpalmer on Monday March 04, 2024 @03:04PM (#39595277)
I feel the same lack of patience often, but in the end I respect anyone for putting themselves and their knowledge out there for critique.
Re:Java is becoming more like Rust, and I am here for it by MajimasEyepatch on Monday March 04, 2024 @01:23PM (#39593944)
Very interesting to see concepts from ML/Haskell/Scala and other FP languages being attributed to Rust. If you tell me that a language is “Rust-like,” my mind goes to borrow checking and memory safety, not FP, so I opened this expecting to see some memory safety features added to JNI or something like that.
Re:Java is becoming more like Rust, and I am here for it by toastal on Monday March 04, 2024 @01:28PM (#39594007)
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 by vineyardmike on Monday March 04, 2024 @01:33PM (#39594087)
Hey, incremental improvements are still improvements. Convincing everyone to change the world is hard just for immutable types or sum types or something. But I’ve seen that slowly adding in functional programming to Java caused my team to get aggressive about using it, and demand it in code reviews. Sometimes you just need the Trojan horse and people will like what they find. I don’t think I’ll convince my team to drop Java, but they’re convinced that FP is important to include, at least in little bits.
Re:Java is becoming more like Rust, and I am here for it by edflsafoiewq on Monday March 04, 2024 @01:31PM (#39594060)
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 by cangeroo on Monday March 04, 2024 @01:26PM (#39593987)
Isn't F# more like a nephew of OCaml and cousin of C#?

F# "originated as an OCaml implementation", which runs on .NET with some C# interop support?

Re:Java is becoming more like Rust, and I am here for it by klodolph on Monday March 04, 2024 @05:16PM (#39596891)
You can have more than one cousin. C# and Java are cousins, obviously, I don’t think I need to explain that one. F# and C# are also cousins, naturally.
Re:Java is becoming more like Rust, and I am here for it by spullara on Monday March 04, 2024 @01:24PM (#39593961)
The Java stuff is definitely coming from FP and not Rust at all.
Re:Java is becoming more like Rust, and I am here for it by queuebert on Monday March 04, 2024 @01:28PM (#39594020)
Haskell + Ada + '{}' == Rust