Hacker News new | ask | show | jobs
by klodolph 843 days ago
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.

8 comments

> 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.
“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.
Except its not becoming more like Kotlin. It's becoming more like ML and OCaml
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.
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.
> 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.

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.
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).
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.
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?

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.
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.

The Java stuff is definitely coming from FP and not Rust at all.
Haskell + Ada + '{}' == Rust