5 ms·
Kotlin is JVM compatible and has ADTs. Java has https://github.com/functionaljava/functionaljava https://github.com/functionaljava/functionaljava which is uns
by lupire 2y ago
Kotlin is JVM compatible and has ADTs.
Java has https://github.com/functionaljava/functionaljava https://github.com/functionaljava/functionaljava
which is unsupported but stable.
- tombert 2y agoSure, and Scala has had ADTs since its inception as well I think, and that's also JVM. It's not ADTs, but Clojure does have some level of pattern matching/destructuring as well. It wasn't that I though that the JVM was incapable of doing something like an ADT, just that vanilla Java didn't support it. While it's easy to say that "companies should just use Kotlin", that's a bit of a big ordeal if you already have a 15 year old codebase that's written in Java. I've heard of but never used the Functional Java library, though it'd be a tough sell to get my work to let me import a library that hasn't been updated in two years.
- Tainnor 2y ago> that's a bit of a big ordeal if you already have a 15 year old codebase that's written in Java. JetBrains has prioritised compatibility with Java and it shows. Of course, there are some gotchas (such as nullability or checked exceptions which don't exist in Kotlin), but you can really mix Kotlin and Java code relatively freely.
- brabel 2y agoJava 21's pattern matching (you don't need functionaljava, and shouldn't really use that unless you're really into FP) is kind of nicer than Kotlin's, because you can automatically "destruct" records in your matches. For Java, see https://www.baeldung.com/java-lts-21-new-features https://www.baeldung.com/java-lts-21-new-features Kotlin's: https://www.baeldung.com/kotlin/when https://www.baeldung.com/kotlin/when Make up your own mind.
- ackfoobar 2y ago> kind of nicer than Kotlin's, because you can automatically "destruct" records in your matches. I find positional destructuring of records a bad idea. https://news.ycombinator.com/item?id=31399737 https://news.ycombinator.com/item?id=31399737
- deleted 2y ago[deleted]