Pattern Matching in Java - Past, Present, Future

  Рет қаралды 9,600

Java

Java

Күн бұрын

`switch` and `instanceof` have been the gates of data introspection in Java since 1.0. In modern times, the same constructs have been rehabilitated to enable full-blown pattern matching and offer a vision of data-oriented programming to Java developers. In this talk we are going to have a look into what `switch` and `instanceof` are for Java developers today and offer a holistic view of all the exciting directions that can be a possible future for Java's pattern matching abilities.
Presented by Angelos Bimpoudis - Principal Member of Technical Staff (Java Platform Group - Oracle) during Devoxx Belgium 2024 ➤ devoxx.be
Q&As with Angelos Bimpoudis ➱ www.youtube.co...
More ... ➱ inside.java/ta...
Tags: #Java #OpenJDK

Пікірлер: 17
@prdoyle
@prdoyle 3 ай бұрын
The first half hour covers a lot of material we already knew. A few points of interest that are perhaps less well-known: 12:08 - If the condition is negated, the scope of the pattern variable is the "else" block. 25:38 - Synthesized default case that throws MatchException. The future arrives starting at 32:45 38:35 - Primitive pattern matching safeguards based on value ranges 42:06 - Potential future features 46:15 - Deconstruction of classes 49:20 - Reconstruction of records 50:15 - Reconstruction of classes 51:25 - New serialization
@ZeroUm_
@ZeroUm_ 3 ай бұрын
Hopefully we will get a for(var k, v : map) someday.
@julianjupiter5890
@julianjupiter5890 3 ай бұрын
And for (var (id, name) : users), where User is a record.
@Ewig_Luftenglanz
@Ewig_Luftenglanz Ай бұрын
But isn't it just syntax sugar for for(var entry: map.entryset)? I supposed se it would be a nice to have tho, we already can do map.stream().forEach( (k, v) -> ...);
@haroldpepete
@haroldpepete 2 ай бұрын
great talk sr, it really greafull see how java has been improving in a solid manner, thanks again, you did a great job
@freebusdoctor
@freebusdoctor 3 ай бұрын
LETS GO
@ianbrown8408
@ianbrown8408 Ай бұрын
Am I the only one who expected “Pattern Matching in Java” to at least mention Pattern() or Matcher()? Co-opting the well established use of the words pattern and matcher to mean something completely different in one language is crazy. This is going to make Java more confusing from now to the end of Java’s days. If they want to call it shape matching, or data matching fine. Just don’t call it pattern matching - that is already taken and these new features have nothing to do with it. Searching on the terms -java pattern match- is going to be a mess giving results for completely different ideas.
@claudemartin5907
@claudemartin5907 3 ай бұрын
will they ever change that nightmarish background image?
@nisonatic
@nisonatic 3 ай бұрын
They'd better not, I've developed a whole industrial process that depends on it to horrify the one guy who does all the work in case he's slacking.
@greatso9018
@greatso9018 3 ай бұрын
Verbosity is something Java is already mocked for, so adding the concept of deconstructor is odd to me. Wasn't it possible to have a syntax like : case MyClass {fieldName, fieldNameThatIsAnArray[index], fieldNameThatIsARecord(type,type) } -> ....
@VuLinhAssassin
@VuLinhAssassin 3 ай бұрын
Yes, I like the concept of with object { field } more
@sjzara
@sjzara 3 ай бұрын
One thing Java is praised for is readability. That’s far more important than conciseness.
@prdoyle
@prdoyle 3 ай бұрын
Records are already quite concise in this way. It's harder for general classes. Once they get the semantics worked out (with deconstructors) they could follow up with improved syntax.
@adambickford8720
@adambickford8720 3 ай бұрын
@@sjzara This is a false dichotomy
@Ewig_Luftenglanz
@Ewig_Luftenglanz Ай бұрын
IMHO deconstruction is going to be easier and mostly be used with records. Records have many features (thanks to it's more restrictive nature and more specification rules) that make Deconstruction not only more convenient there but also easier to implement. For starters records only have one constructor so there is only one "deconstructor" and this deconstructors is implicitly given "for free" (just as hashCode, to string, equals and so on) that's why we have records deconstruction in pattern matching (what they call record patterns) Another festure records' have is that records' field names are part of the record specification, so things like nominal parameters (with defaults) and even nominal destructuring (very like what JavaScript/typescript already do) is far easier to implement and use in records than anywhere else in the language. I wouldn't be surprised is most of these festires arrive to records first and then to classes (if ever) developing festires about records it's almost like coding only thinking in the happy case, because most of wrong cases and variants tha would make hard the development are straight up ilegal in records
ZGC Automatic Heap Sizing #JVMLS
47:51
Java
Рет қаралды 4,6 М.
Java 21 Pattern Matching Tutorial #RoadTo21
23:28
Java
Рет қаралды 27 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
(Hearthstone) A Casual 30 Charge Damage! Protoss Priest
10:54
Brian Kibler
Рет қаралды 10 М.
Serialization - A New Hope
50:53
Java
Рет қаралды 16 М.
A Sneak Peek at StableValue and SegmentMapper in Java
45:48
Java 23 - Better Language, Better APIs, Better Runtime
57:39
Java Language Futures - Fall 2024 Edition
51:51
Java
Рет қаралды 11 М.
Java Performance Update
52:56
Java
Рет қаралды 57 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 201 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН