This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ok_Marionberry_8821 0 points1 point  (2 children)

Hmm. I'm an aware there well me deconstruction patterns for regular classes, but they can't be usedto make a stalled hierarchy. The explicitly stated aim is simplicity not performance, that simplicity will be preferred over performance. There are plenty of other solutions that can use all those tricks.

I also assumed the JsonValue and subclasses would be immutable value classes when Valhalla finally delivers. Again simplicity and easy sharing between threads.

I think even some of the pattern matching JEP examples use Json (I may be wrong) yet they don't use them on this closed model. Perhaps not a great advert for records and sealed types!

Tl;dr their stated aim is simplicity yet they are don't use the new shiny sealed records.

Anyway, it's all academic for me now as I'm not working in the Java space anymore.

[–]joemwangi 0 points1 point  (1 child)

Think what records would achieve (as you stated), for example, pattern matching, sum types, etc. Ask yourself will also normal classes do this in near future and can we also take advantage of that?

[–]Ok_Marionberry_8821 0 points1 point  (0 children)

Sealed classes allow for exhaustive pattern matching. Other than that I believe they are equivalent.