Topics
Published on August 2, 2017 by java
Want create site? Find Free WordPress Themes and plugins.

This talk highlights the pain points that need to be solved in order to implement the pattern matching in Java and proposes ways to solve those different issues. I’ve already an implementation that works and I hope to be able to demonstrate the use of value types under the hood for performance without leaking them to the user code. In term of performance, one of the goals is to guarantee that pattern matching on types should be as fast as a code is written using method dispatch, or at least in the same ballpark in case of megamorphic callsites. Moreover, for the matching part, the implementation use three principles in hope to get good performance: there is no side effect, there is no object creation and if the whole pattern matching is not inlininable, try to favor inlining between the actions than the inlining between the different pattern recognition codes.

Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

10 Comments on "Pattern Matching with Brian Goetz @BrianGoetz"

Notify of
avatar

Benjamin Shults
Guest
Benjamin Shults
2 months 5 days ago

Did I miss something or is this done without new JVM instructions?

ebu zer
Guest
ebu zer
2 months 11 days ago

is it possible for java to have a inverse feature such as for f(x)=y , f(y).inverse=x ?

cmyanmar13
Guest
cmyanmar13
2 months 15 days ago

Adding out parameters seems more of a priority, because then it can be used to do this and more, and without the mucking around with carrier objects.

Solomon Ritzow
Guest
Solomon Ritzow
2 months 15 days ago

I like the idea of the matches operator but destructuring (and esentially multiple return values) seems like a completely random thing to add when you can just use the getters/setters of the object you get from the pattern matching.

jFrenetic
Guest
jFrenetic
2 months 15 days ago

Destructuring is pretty much the main idea of pattern matching. I think he demonstrated its benefits very well in the video. Imagine you have an object like (Node(Node(Node(a))). Do you really want to call getters to get to the a? Are you sure you'll call the right number of getters, or you might accidentally introduce a bug by adding an extra getter?

tohopes
Guest
tohopes
2 months 15 days ago

Bringing pattern matching to Java is wrong. You should instead come up with a way to make Visitor easier to implement with less boilerplate.

tohopes
Guest
tohopes
2 months 7 days ago

nice lambdas in there

Jean-Baptiste Giraudeau
Guest
Jean-Baptiste Giraudeau
2 months 14 days ago

> a way to make Visitor easier to implement with less boilerplate.that's already exist: github.com/derive4j/derive4j

Solomon Ritzow
Guest
Solomon Ritzow
2 months 15 days ago

I like the idea of reducing an instanceof and a cast to a "matches" operation, but destructuring just sound awful and not worth the costs in language complexity and implementation cost. This just seems like too much of a functional language thing for it to be added to Java.

jFrenetic
Guest
jFrenetic
2 months 15 days ago

That would be so cool if this feature was introduced in Java!JEP link (I don't think it was mentioned in the video): openjdk.java.net/jeps/305

wpDiscuz