Variants/case classes/algebraic data types/sums/oh my!

Brian Goetz brian.goetz at oracle.com
Sat Jun 11 16:24:06 UTC 2016


To amplify John's comments -- we are very interested in these topics, 
but we believe there are some fundamentals that have to be addressed 
first.  No need to dive into great detail about how great case classes / 
destructuring pattern matches are; we are more than aware :)

> I believe that all of the existing languages could benefit from both
> JVM and Java language support for the types, and I believe that support
> could be provided with minimal, non-intrusive changes to the virtual
> machine (an extra piece of class metadata, no new bytecode
> instructions, a couple of extra syntax rules in the Java language that
> likely build upon the existing switch statement, and no new keywords).

By way of setting expectations .... there are no minimal, non-intrusive 
language or JVM features.  Usually, it requires a tremendous amount of 
work to make a feature merely *seem* less intrusive; consider lambdas, 
which are "just" function literals -- except making them work required 
entirely overhauling type inference and method overload selection -- 
which if done right, no one notices.

That said, we're willing to invest in big features -- but as John 
mentioned, there are some things ahead of this one on the queue, which 
are probably prerequisites for doing this well.  (For example, value 
types are a prerequisite for useful tuples.)

So, with those expectation-settings comments aside, we're interested to 
see what you come up with, and we encourage you to follow the valhalla 
discussions to see where we're going.  (In particular, I'm interested in 
hearing what you think the VM is missing for these features.)



More information about the valhalla-dev mailing list