4 ms·
Most of the reasons to use Scala still apply. Java has made some improvements but is still a long way behind, e.g. Java "has" "pattern matching" but only a very
by lmm 4y ago
Most of the reasons to use Scala still apply. Java has made some improvements but is still a long way behind, e.g. Java "has" "pattern matching" but only a very basic, very restricted form of it, and that's if you're using the latest version. Java "has" "optionals" but limited in a way that makes them useless in practice. Fibers have finally landed, about a decade later than promised, but the ecosystem hasn't even begun to adopt them yet and who knows what edge cases or issues may turn up. The type system has made some limited progress, but writing Java still means chafing under many of the same restrictions that were noticeable 20 years ago.
It's great to see Java finally starting to move again, but frankly if you think "modern Java" is good then you could've had all that for 15+ years with Scala - why do you want to wait 15 more years for the other half of what Scala offers?
- zaphirplane 4y agoWhat makes option useless
- lmm 4y agoDeliberate weird behaviour around nulls. In particular you can't have Some(null), which means you can't really use it to solve the problems it's meant to solve - one of the key motivating examples for why you want optionals is that if Map.get(x) returns null, you don't know if that means there's no mapping for x in the map, or there's an entry with key x and value null. So the idea would be to add Map.safeGet or some such which returns Option<V>, and then if it returns None there's really no mapping, and if it returns Some(null) then there's a mapping with value null. But you can't do that in Java because in the standardisation process they decided they... didn't want to allow it.
- AzzieElbab 4y agoI thought it was wrapping successful Java calls that return nulls. Try.toOption caught me off guard with this behaviour
- lmm 4y agoDid you reply to the wrong comment? I'm talking about Java's Optional implementation.
- zaphirplane 4y agoIsn’t that a map of optionals Optional::Empty, optional with value or null ? Your 3 states
- lmm 4y agoThat's a lot more cumbersome to work with, and only possible at all if you're controlling the construction/population of the map rather than getting it back from a library or framework.
- kasperni 4y ago> Fibers have finally landed, about a decade later than promised, but the ecosystem hasn't even begun to adopt them yet and who knows what edge cases or issues may turn up. First, Project Loom was announced in late 2017 [1]. So I don't really understand where you get that decade from? Second, it is available as a preview feature in latest JDK. Why would people adopt a preview feature in their production systems? A lot of frameworks have already added support or as a minimum started working on support for virtual threads. I'm sure all major frameworks will support them once they are out of preview. [1] https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1....
- lmm 4y ago> First, Project Loom was announced in late 2017 [1]. So I don't really understand where you get that decade from? I might've been mixing them up with value types. Or I may have been thinking of an earlier effort that was then subsumed into Project Loom. > Second, it is available as a preview feature in latest JDK. Why would people adopt a preview feature in their production systems? Exactly my point. If someone is arguing "I don't need Scala's support for lightweight concurrency because modern Java has that" - well, it sort of does, but they're not actually production ready. > A lot of frameworks have already added support or as a minimum started working on support for virtual threads. I'm sure all major frameworks will support them once they are out of preview. This is purely speculative, but I think there are going to be a lot of unforseen bugs and edge cases when people start actually using them. So I think it's really important to be clear that they're not in actual production use at the moment.