News for hackers. Stuff that matters.
Re:Java record pattern matching in JDK 19 by peterkelly on Saturday May 14, 2022 @08:05PM (#31383956)
The downside to that is if you want to write a new function that deals different subclasses, you can't keep all the logic in one place; you have to spray its implementation across all the different types it has to handle. This is the #1 reason I prefer languages with sum types and pattern matching (or the ability to emulate it via unions and instanceof checks, e.g. TypeScript or Python + mypy).
Re:Java record pattern matching in JDK 19 by pharmakom on Sunday May 15, 2022 @04:02AM (#31386044)
You could implement a crappy union type in Java with a type-safe API, but if you want to program in that style you are really better off using an ML or Scala.