3 ms·
Pattern matching is going to be a hard sell in Java, because languages based around pattern matching place a much, much higher emphasis on values rather than id
by silentbicycle 14y ago
Pattern matching is going to be a hard sell in Java, because languages based around pattern matching place a much, much higher emphasis on values rather than identity. You need good data structure literals, and to have two things with the same content be interchangeable, not just two objects that currently happen to have the same fields.
In other words, I think OOP and pattern matching are inherently antagonistic language features. They can coexist in a language (OCaml also has both), but not really in the same code.
I figured this out working on a library for pattern matching in Lua (https://github.com/silentbicycle/tamale https://github.com/silentbicycle/tamale); Lua is less pervasively object-oriented, and uses literal "tables" (basically, JSON) quite a bit, so it's a better fit.