4 ms·
At least Java supports covariance and contravariance where Go only supports invariant generics.
by karmakaze 1y ago
At least Java supports covariance and contravariance where Go only supports invariant generics.
- PaulHoule 1y agoJava has evolved to contain much of “ML the good parts” such as that languages like Kotlin or Scala that offer a chance to be just a bit better in the JVM look less necessary
- throwaway2037 1y ago> Java has evolved to contain much of “ML the good parts” Can you give some examples?
- yz453 1y agoNot OP. IMO the recent Java changes, including pattern matching (especially when using along with sealed interface), virtual threads (and structured concurrency on the way), string templates, are all very solid additions to the language. Using these new features one can write very expressive modern code while still being interoperable with the Java 8 dependency someone at their company wrote 20 years ago.
- PaulHoule 1y agoLike a lot of other languages, Java has gotten a big dose of https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_system https://en.wikipedia.org/wiki/Hindley%E2%80%93Milner_type_sy... To defy it's reputation for verbosity, Java's lambda syntax is both terse and highly flexible. Sum and product types are possible with records and sealed classes. Pattern matching.
- karmakaze 1y agoI even found a way to make ad-hoc union types of element types from other packages that does exhaustive switch/case checking. I quickly wrote down a PoC so I wouldn't forget[0]. It needs wrapper types and sealed interfaces in the consuming app/package but is manageable and turned out better than other attempts I'd made. [0] https://github.com/karmakaze/AdHocUnion https://github.com/karmakaze/AdHocUnion