The document discusses pattern matching in Java. It provides examples of using type patterns to bind variables in if/else statements and instanceof checks. Switch expressions are demonstrated as another way to perform pattern matching by matching on an object's type and extracting variables. The benefits of pattern matching such as conciseness, safety and reducing errors are outlined. It also shows how to handle null values in a switch expression.
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching - Small Enhancement or Major Feature? from Developer Week 202🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching: Small Enhancement or Major Feature? (talk from jLove 2021)🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Perl 5.10 introduces several new features including say for easy printing, smart matching with ~~, switch statement, defined-or operator //, and state variables for persistent data within subs. It also includes improvements to the regex engine, modules like Hash::Util::FieldHash, better Windows support and a faster UTF-8 implementation. The release timeline is 5.8.9 stable by April 1st 2006, 5.10 after lunch before Christmas 2006, and Perl 6 after lunch before Christmas 2006.
Types of Strings in PHP discusses different string data types and functions in PHP. There are single-quoted and double-quoted strings, which can contain variables and escape characters respectively. Common string functions include substr() to extract substrings, str_replace() to replace substrings, and strpos() to find the position of a substring. Other useful functions are strrev() to reverse a string, str_pad() to pad a string to a length, and explode/implode to split/join strings.
This document summarizes key points about working with Marionette.js views:
1) Views have a lifecycle of initialize(), render(), onRender(), destroy(), with events handled in onRender() rather than render().
2) Templates can be JavaScript functions or require'd .ejs files, with .ejs preferred. getTemplate() provides the view's scope.
3) Listen to model events in index.js rather than views, and call sandbox.showContent() rather than view.render() on changes.
4) Marionette has specialized view types - ItemView renders a single model, CollectionView manages child views in a collection, CompositeView is a hybrid, and LayoutView
PHP has special data types like resources and NULL. Functions like var_dump(), gettype(), and settype() can output or change a variable's type. Operators like arithmetic, comparison, logical, and assignment are used to produce values from expressions. Constants are defined with define() and cannot change unlike variables.
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching - Small Enhancement or Major Feature? from Developer Week 202🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching: Small Enhancement or Major Feature? (talk from jLove 2021)🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Pattern Matching: From Small Enhancement to Major Feature (talk from JavaLand...🎤 Hanno Embregts 🎸
At first it seemed to be just a small enhancement: the addition of “Pattern Matching for instanceof” (JEP 305) in Java 14. No more unnecessary casting after an instanceof, that ought to save us a few seconds a day! However, upon further investigation you’ll quickly discover that pattern matching is not just an enhancement, but rather a vital puzzle piece in the grander scheme of things.
Why were switch expressions added to Java, for example? To make them support pattern matching in a later release! And why did Java 14 bring us records and will Java 15 contain sealed types? Because they could work really well with pattern matching in a later release! These new concepts are the foundation upon which advanced pattern matching features will be built.
So attend this session to get all caught up! You’ll hear about type patterns, deconstruction patterns, nested patterns and even how pattern matching could improve serialization in the future. Live coding included, of course!
Perl 5.10 introduces several new features including say for easy printing, smart matching with ~~, switch statement, defined-or operator //, and state variables for persistent data within subs. It also includes improvements to the regex engine, modules like Hash::Util::FieldHash, better Windows support and a faster UTF-8 implementation. The release timeline is 5.8.9 stable by April 1st 2006, 5.10 after lunch before Christmas 2006, and Perl 6 after lunch before Christmas 2006.
Types of Strings in PHP discusses different string data types and functions in PHP. There are single-quoted and double-quoted strings, which can contain variables and escape characters respectively. Common string functions include substr() to extract substrings, str_replace() to replace substrings, and strpos() to find the position of a substring. Other useful functions are strrev() to reverse a string, str_pad() to pad a string to a length, and explode/implode to split/join strings.
This document summarizes key points about working with Marionette.js views:
1) Views have a lifecycle of initialize(), render(), onRender(), destroy(), with events handled in onRender() rather than render().
2) Templates can be JavaScript functions or require'd .ejs files, with .ejs preferred. getTemplate() provides the view's scope.
3) Listen to model events in index.js rather than views, and call sandbox.showContent() rather than view.render() on changes.
4) Marionette has specialized view types - ItemView renders a single model, CollectionView manages child views in a collection, CompositeView is a hybrid, and LayoutView
PHP has special data types like resources and NULL. Functions like var_dump(), gettype(), and settype() can output or change a variable's type. Operators like arithmetic, comparison, logical, and assignment are used to produce values from expressions. Constants are defined with define() and cannot change unlike variables.
Given at GopherFest 2015. This is an updated version of the talk I gave in NYC Nov 14 at GothamGo.
“We need to think about failure differently. Most people think mistakes are a necessary evil. Mistakes aren't a necessary evil, they aren't evil at all. They are an inevitable consequence of doing something new and as such should be seen as valuable. “ - Ed Catmull
As Go is a "new" programming language we are all experimenting and learning how to write better Go. While most presentations focus on the destination, this presentation focuses on the journey of learning Go and the mistakes I personally made while developing Hugo, Cobra, Viper, Afero & Docker.
The document discusses functions in PHP, including defining functions, passing arguments to functions, returning values from functions, and using global variables. Some key points covered include:
- Functions allow code to be reused and separated into logical subsections, making code more modular, readable, and maintainable.
- Arguments passed to functions can make functions more flexible by allowing different inputs to produce different outputs each time they are called.
- Functions can return values to the calling code using the return statement. Returned values can be variables, arrays, or results of calculations.
- The order arguments are passed to a function matters, as arguments are assigned to placeholder variables in the defined order. Default values can be specified for arguments.
This document discusses how Vim can improve productivity for Perl coding. It provides examples of using Vim motions and modes like Normal mode, Insert mode, and Visual mode to efficiently edit code. It also covers Vim features like syntax highlighting, custom syntax files, key mappings, and text objects that are useful for Perl. The document advocates that Vim is a powerful editor rather than an IDE and highlights how it can save significant time compared to less efficient editing methods.
Java 8 Puzzlers as it was presented at Codemash 2017Baruch Sadogursky
We aren’t sure about you, but working with Java 8 made one of the speakers lose all of his hair and the other lose his sleep (or was it the jetlag?). If you still haven’t reached the level of Brian Goetz in mastering lambdas and strings, this talk is for you. And if you think you have, we have some bad news for you, you should attend as well. Baruch and Viktor will show you some surprising, bizarre, and inconceivable parts of Java 8 and make sure that you won’t be (too) surprised when it hits you in production. As with any other puzzlers talk, there will be two speakers, lots of puzzling questions, answers by the audience, T-shirts flying around, and a lot of fun, all for one purpose—to help you better understand Java 8.
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
Puppet 4 introduces several new features and changes including improved performance, scalability, measurability and flexibility. It features a new Puppet Server based on Clojure and Trapperkeeper, packaging changes, improved environment handling, r10k for managing environments from git, new language features like lambdas and EPP templates, improved data binding and overriding, stronger typing support, and various deprecations around node inheritance, hyphens in names, and other changes. Upgrading requires testing modules against the new version and addressing any compatibility issues.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
The document discusses the authors' initial naive expectations for using Scala and Clojure compared to their actual experience. They initially thought the languages would solve issues like boilerplate code and Java compiler problems, but found they still had to deal with interoperability, immutability, and other functional programming concepts. In the end, Clojure met more of their needs due to its emphasis on seamless interoperability, traits, and pattern matching.
The document discusses the F# programming language. It provides an overview of F# including that it is a functional, object-oriented .NET language. It also summarizes key features of F# like strong typing, higher-order functions, pattern matching and compares syntax examples to C#. Additionally, it mentions resources for learning F# such as books, jobs listings, conferences and community sites.
"Will Git Be Around Forever? A List of Possible Successors" from Devoxx 2022🎤 Hanno Embregts 🎸
Ten years ago, only Linux kernel committers and other early adopters used Git. Almost everyone else used Subversion. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now? And what features would YOU want from your version control software in 2032? No history rewrites? Faster? No merge conflicts ever?
In this talk I'll discuss a few post-Git products, including Fossil, Plastic and Pijul, and their support for the features we so dearly desire. I'll also try to predict which one will be 'the top dog' in 2032.
So attend this session if you're excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first. 😀
"Will Git Be Around Forever? A List of Possible Successors" from FrontMania 2022🎤 Hanno Embregts 🎸
Ten years ago, only Linux kernel committers and other early adopters used Git. Almost everyone else used Subversion. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now? And what features would YOU want from your version control software in 2032? No history rewrites? Faster? No merge conflicts ever?
In this talk I'll discuss a few post-Git products, including Fossil, Plastic and Pijul, and their support for the features we so dearly desire. I'll also try to predict which one will be 'the top dog' in 2032.
So attend this session if you're excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first. 😀
JCON 2021 talk - "Wil Git Be Around Forever? A List of Possible Successors"🎤 Hanno Embregts 🎸
What source control software did you use in 2010? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2030. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Plastic, Fossil and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2030 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG🎤 Hanno Embregts 🎸
What source control software did you use in 2010? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2030. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Plastic, Fossil and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2030 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
Optical Character Recognition has evolved into a mature computer science field, with applications in financial transfers, book digitisation and passport scanning. Now if you would want to add OCR to your Java application, you have lots of options; one of which is Tesseract.
Tesseract has become quite popular amongst software developers because of its accuracy, its open-source status and its active development by Google. By using the Tess4J JNA wrapper it is easily integrated into your Java project.
During this session, I will introduce Tesseract, its pros and cons and how & when to use it. I will compare it to its competitors and I will explain why and how we used it in a case study. To top it off I will live-code a Java application that uses Tesseract and Tess4J to process some example images, so you’ll be able to assess its accuracy for yourself.
Now in geometry, a ‘tesseract’ is the four-dimensional analog of a cube. So will Tesseract live up to its name and help your project to ‘enter the fourth dimension’? Attend this session and find out!
When I return from a conference I am dying to try out the new ideas I brought home and convince my colleagues that we should start using them. Turns out my hard skills only get me *so* far. Soft skills play a vital part in the development of a great product.
We need to be able to motivate people, listen to them and treat them with respect. So how do we get there?
The few things I have learned about soft skills came through improving upon my mistakes and asking other developers about it.
So bring your questions to this meetup and let's see if we can put the 'soft' in software development together.
Beware of Survivorship Bias! (conference talk at J-Fall 2019)🎤 Hanno Embregts 🎸
Most talks on a typical conference schedule contain success stories of technology. This could lead to survivorship bias. Survivorship bias causes you to draw false conclusions because you mostly heard about successes, but hardly ever about failures. Yet failures provide us with lots of valuable knowledge: when not to apply a certain technique, pattern or process.
So no success stories in this talk! Just some ‘silver bullets’ we tried to use to solve our problems, but turned out to be Very Bad Ideas™. We’ll share how survivorship bias can easily influence your ideas and cloud your judgement.
After attending this talk you’ll be more aware of survivorship bias and what you can do to keep your head cool, no matter how many ‘silver bullets’ are fired at you.
Will Git Be Around Forever? A List of Possible Successors🎤 Hanno Embregts 🎸
What source control software did you use in 2008? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2028. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Fossil, Veracity and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2028 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
Entering the Fourth Dimension of OCR with Tesseract - Talk from Voxxed Days B...🎤 Hanno Embregts 🎸
This document provides an overview of optical character recognition (OCR) and the Tesseract OCR engine. It discusses the basics of OCR, the history and development of Tesseract, its features such as character recognition and language support, and advanced topics like reporting confidence, image optimization, and custom training. The document also compares Tesseract to competitors like ABBYY FineReader and Google Cloud Vision in terms of cost, capabilities, and accuracy.
QWERTY or DVORAK? Debunking the Keyboard Layout Myths -- from GeeCON 2018🎤 Hanno Embregts 🎸
If you’re reading this summary on a computer, chances are there is a QWERTY keyboard on your desk. This keyboard layout has been around since 1873, and it has been widely adopted ever since. However, its popularity has always remained a mystery to me. Why is everyone using a keyboard layout that doesn’t look that efficient on first sight? I’m not the only one asking this question. A lot of myths exist on the QWERTY keyboard layout, including the one that it was specifically designed to slow down typists. In preparation for a switch to the DVORAK layout, I did some research and found out that a lot of these myths are riddled with factual errors. Also, I started learning DVORAK and kept track of my progress and what I thought were the pros and cons. So was QWERTY designed to slow us down? Is it feasible to adopt an alternative layout like DVORAK? If so, how long will it take you to learn it, and should everyone consider it? Join this session to have your questions answered, and feel free to bring your keyboard layout of choice. :-)
Building a Spring Boot 2 Application - Ask the Audience! (from Voxxed Days Vi...🎤 Hanno Embregts 🎸
Spring Boot makes it easy to create stand-alone Spring-based applications that you can ‘just run’. It uses a ‘convention over configuration’ approach to get you up and running in no-time. And with the release of Spring Boot 2 in February 2018 all Spring 5.0 features will be available for Spring Boot users, as well as Kotlin support. In this session I will demonstrate this by live-coding a Spring Boot 2 application that will ‘just work’.
But audience beware, this is not your standard ‘live-coding session’. Attendees will have a vital say in the session’s content by defining the application’s requirements. Do you want a simple task planner? Or track your favourite movies? It’s up to you! Should it use MongoDB or JPA? You decide! Built with Java or Kotlin? I don’t care! Do you want an Angular front-end with a RESTful back-end or do you prefer a classic web app with Thymeleaf templates? It’s your call! Seriously.
During the session you get to make these decisions by participating in an online vote. And you will discover that Spring Boot is up to the task no matter what choices you make.
So what are you waiting for? Bring your own device, help shape the application that we’re building and learn lots about Spring Boot in the process.
This session is intended for Java software engineers with an interest in Spring Boot. Some Spring experience could come in handy, but is not strictly necessary. After this session, you will know enough to start your own Spring Boot project.
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)🎤 Hanno Embregts 🎸
Spring Boot is a framework for creating stand-alone, production-grade Spring based applications that can be "run" using java -jar without the need for an external web server. It favors convention over configuration and aims to get developers up and running quickly with minimal configuration. Key features include an embedded web server, automatic configuration, and starters that provide prepackaged dependencies. Pros include faster development and deployment, while potential cons include more complex custom configuration and incompatibility with some legacy Spring projects. The documentation provides guidance on creating starter projects with an initial Java file, build script, and dependencies.
Building a Spring Boot Application - Ask the Audience!🎤 Hanno Embregts 🎸
This document provides an overview of building applications with Spring Boot. It discusses key features such as creating stand-alone Spring applications without separate web servers, automatic Spring configuration, and getting started quickly with one Java file and a build script. Pros include faster deployments and no need for web.xml files. Cons can include custom configuration challenges and incompatibility with some legacy Spring projects. The document also demonstrates sample code and references Spring Initializr for project setups.
If you're reading this summary on a computer, chances are there is a QWERTY keyboard on your desk. This keyboard layout has been around since 1873, and it has been widely adopted ever since. However, its popularity has always remained a mystery to me. Why is everyone using a keyboard layout that doesn't look that efficient on first sight?
I'm not the only one asking this question. A lot of myths exist on the QWERTY keyboard layout, including the one that it was specifically designed to slow down typists. In preparation for a switch to the DVORAK layout, I did some research and found out that a lot of these myths are riddled with factual errors. Also, I started learning DVORAK and kept track of my progress and what I thought were the pros and cons.
So was QWERTY designed to slow us down? Is it feasible to adopt an alternative layout like DVORAK? If so, how long will it take you to learn it, and should everyone consider it? Join this session to have your questions answered, and feel free to bring your keyboard layout of choice. :-)
More Related Content
Similar to Pattern Matching: Small Enhancement or Major Feature?
Given at GopherFest 2015. This is an updated version of the talk I gave in NYC Nov 14 at GothamGo.
“We need to think about failure differently. Most people think mistakes are a necessary evil. Mistakes aren't a necessary evil, they aren't evil at all. They are an inevitable consequence of doing something new and as such should be seen as valuable. “ - Ed Catmull
As Go is a "new" programming language we are all experimenting and learning how to write better Go. While most presentations focus on the destination, this presentation focuses on the journey of learning Go and the mistakes I personally made while developing Hugo, Cobra, Viper, Afero & Docker.
The document discusses functions in PHP, including defining functions, passing arguments to functions, returning values from functions, and using global variables. Some key points covered include:
- Functions allow code to be reused and separated into logical subsections, making code more modular, readable, and maintainable.
- Arguments passed to functions can make functions more flexible by allowing different inputs to produce different outputs each time they are called.
- Functions can return values to the calling code using the return statement. Returned values can be variables, arrays, or results of calculations.
- The order arguments are passed to a function matters, as arguments are assigned to placeholder variables in the defined order. Default values can be specified for arguments.
This document discusses how Vim can improve productivity for Perl coding. It provides examples of using Vim motions and modes like Normal mode, Insert mode, and Visual mode to efficiently edit code. It also covers Vim features like syntax highlighting, custom syntax files, key mappings, and text objects that are useful for Perl. The document advocates that Vim is a powerful editor rather than an IDE and highlights how it can save significant time compared to less efficient editing methods.
Java 8 Puzzlers as it was presented at Codemash 2017Baruch Sadogursky
We aren’t sure about you, but working with Java 8 made one of the speakers lose all of his hair and the other lose his sleep (or was it the jetlag?). If you still haven’t reached the level of Brian Goetz in mastering lambdas and strings, this talk is for you. And if you think you have, we have some bad news for you, you should attend as well. Baruch and Viktor will show you some surprising, bizarre, and inconceivable parts of Java 8 and make sure that you won’t be (too) surprised when it hits you in production. As with any other puzzlers talk, there will be two speakers, lots of puzzling questions, answers by the audience, T-shirts flying around, and a lot of fun, all for one purpose—to help you better understand Java 8.
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
Puppet 4 introduces several new features and changes including improved performance, scalability, measurability and flexibility. It features a new Puppet Server based on Clojure and Trapperkeeper, packaging changes, improved environment handling, r10k for managing environments from git, new language features like lambdas and EPP templates, improved data binding and overriding, stronger typing support, and various deprecations around node inheritance, hyphens in names, and other changes. Upgrading requires testing modules against the new version and addressing any compatibility issues.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
The document discusses the authors' initial naive expectations for using Scala and Clojure compared to their actual experience. They initially thought the languages would solve issues like boilerplate code and Java compiler problems, but found they still had to deal with interoperability, immutability, and other functional programming concepts. In the end, Clojure met more of their needs due to its emphasis on seamless interoperability, traits, and pattern matching.
The document discusses the F# programming language. It provides an overview of F# including that it is a functional, object-oriented .NET language. It also summarizes key features of F# like strong typing, higher-order functions, pattern matching and compares syntax examples to C#. Additionally, it mentions resources for learning F# such as books, jobs listings, conferences and community sites.
Similar to Pattern Matching: Small Enhancement or Major Feature? (8)
"Will Git Be Around Forever? A List of Possible Successors" from Devoxx 2022🎤 Hanno Embregts 🎸
Ten years ago, only Linux kernel committers and other early adopters used Git. Almost everyone else used Subversion. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now? And what features would YOU want from your version control software in 2032? No history rewrites? Faster? No merge conflicts ever?
In this talk I'll discuss a few post-Git products, including Fossil, Plastic and Pijul, and their support for the features we so dearly desire. I'll also try to predict which one will be 'the top dog' in 2032.
So attend this session if you're excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first. 😀
"Will Git Be Around Forever? A List of Possible Successors" from FrontMania 2022🎤 Hanno Embregts 🎸
Ten years ago, only Linux kernel committers and other early adopters used Git. Almost everyone else used Subversion. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now? And what features would YOU want from your version control software in 2032? No history rewrites? Faster? No merge conflicts ever?
In this talk I'll discuss a few post-Git products, including Fossil, Plastic and Pijul, and their support for the features we so dearly desire. I'll also try to predict which one will be 'the top dog' in 2032.
So attend this session if you're excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first. 😀
JCON 2021 talk - "Wil Git Be Around Forever? A List of Possible Successors"🎤 Hanno Embregts 🎸
What source control software did you use in 2010? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2030. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Plastic, Fossil and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2030 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
"Will Git Be Around Forever? A List of Possible Successors" at UtrechtJUG🎤 Hanno Embregts 🎸
What source control software did you use in 2010? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2030. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Plastic, Fossil and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2030 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
Optical Character Recognition has evolved into a mature computer science field, with applications in financial transfers, book digitisation and passport scanning. Now if you would want to add OCR to your Java application, you have lots of options; one of which is Tesseract.
Tesseract has become quite popular amongst software developers because of its accuracy, its open-source status and its active development by Google. By using the Tess4J JNA wrapper it is easily integrated into your Java project.
During this session, I will introduce Tesseract, its pros and cons and how & when to use it. I will compare it to its competitors and I will explain why and how we used it in a case study. To top it off I will live-code a Java application that uses Tesseract and Tess4J to process some example images, so you’ll be able to assess its accuracy for yourself.
Now in geometry, a ‘tesseract’ is the four-dimensional analog of a cube. So will Tesseract live up to its name and help your project to ‘enter the fourth dimension’? Attend this session and find out!
When I return from a conference I am dying to try out the new ideas I brought home and convince my colleagues that we should start using them. Turns out my hard skills only get me *so* far. Soft skills play a vital part in the development of a great product.
We need to be able to motivate people, listen to them and treat them with respect. So how do we get there?
The few things I have learned about soft skills came through improving upon my mistakes and asking other developers about it.
So bring your questions to this meetup and let's see if we can put the 'soft' in software development together.
Beware of Survivorship Bias! (conference talk at J-Fall 2019)🎤 Hanno Embregts 🎸
Most talks on a typical conference schedule contain success stories of technology. This could lead to survivorship bias. Survivorship bias causes you to draw false conclusions because you mostly heard about successes, but hardly ever about failures. Yet failures provide us with lots of valuable knowledge: when not to apply a certain technique, pattern or process.
So no success stories in this talk! Just some ‘silver bullets’ we tried to use to solve our problems, but turned out to be Very Bad Ideas™. We’ll share how survivorship bias can easily influence your ideas and cloud your judgement.
After attending this talk you’ll be more aware of survivorship bias and what you can do to keep your head cool, no matter how many ‘silver bullets’ are fired at you.
Will Git Be Around Forever? A List of Possible Successors🎤 Hanno Embregts 🎸
What source control software did you use in 2008? Possibly Git, if you were an early adopter or a Linux kernel committer. But chances are you were using Subversion, as this was the product of choice for the majority of the software developers. Ten years later, Git is the most popular product. Which makes me wonder: what will we use another ten years from now?
In this talk we will think about what features we want from our source control software in 2028. More speed? Better collaboration support? No merge conflicts ever?
I’ll also discuss a few products that have been published after Git emerged, including Fossil, Veracity and Pijul. I’ll talk about the extent to which they contain the features we so dearly desire and I’ll demonstrate a few typical use cases. To conclude, I’ll try to predict which one will be ‘the top dog’ in 2028 (all information is provided “as is”, no guarantees etc. etc.).
So attend this session if you’re excited about the future of version control and if you want to have a shot at beating even (!) the early adopters. Now if it turns out I was right, remember that you heard it here first.
Entering the Fourth Dimension of OCR with Tesseract - Talk from Voxxed Days B...🎤 Hanno Embregts 🎸
This document provides an overview of optical character recognition (OCR) and the Tesseract OCR engine. It discusses the basics of OCR, the history and development of Tesseract, its features such as character recognition and language support, and advanced topics like reporting confidence, image optimization, and custom training. The document also compares Tesseract to competitors like ABBYY FineReader and Google Cloud Vision in terms of cost, capabilities, and accuracy.
QWERTY or DVORAK? Debunking the Keyboard Layout Myths -- from GeeCON 2018🎤 Hanno Embregts 🎸
If you’re reading this summary on a computer, chances are there is a QWERTY keyboard on your desk. This keyboard layout has been around since 1873, and it has been widely adopted ever since. However, its popularity has always remained a mystery to me. Why is everyone using a keyboard layout that doesn’t look that efficient on first sight? I’m not the only one asking this question. A lot of myths exist on the QWERTY keyboard layout, including the one that it was specifically designed to slow down typists. In preparation for a switch to the DVORAK layout, I did some research and found out that a lot of these myths are riddled with factual errors. Also, I started learning DVORAK and kept track of my progress and what I thought were the pros and cons. So was QWERTY designed to slow us down? Is it feasible to adopt an alternative layout like DVORAK? If so, how long will it take you to learn it, and should everyone consider it? Join this session to have your questions answered, and feel free to bring your keyboard layout of choice. :-)
Building a Spring Boot 2 Application - Ask the Audience! (from Voxxed Days Vi...🎤 Hanno Embregts 🎸
Spring Boot makes it easy to create stand-alone Spring-based applications that you can ‘just run’. It uses a ‘convention over configuration’ approach to get you up and running in no-time. And with the release of Spring Boot 2 in February 2018 all Spring 5.0 features will be available for Spring Boot users, as well as Kotlin support. In this session I will demonstrate this by live-coding a Spring Boot 2 application that will ‘just work’.
But audience beware, this is not your standard ‘live-coding session’. Attendees will have a vital say in the session’s content by defining the application’s requirements. Do you want a simple task planner? Or track your favourite movies? It’s up to you! Should it use MongoDB or JPA? You decide! Built with Java or Kotlin? I don’t care! Do you want an Angular front-end with a RESTful back-end or do you prefer a classic web app with Thymeleaf templates? It’s your call! Seriously.
During the session you get to make these decisions by participating in an online vote. And you will discover that Spring Boot is up to the task no matter what choices you make.
So what are you waiting for? Bring your own device, help shape the application that we’re building and learn lots about Spring Boot in the process.
This session is intended for Java software engineers with an interest in Spring Boot. Some Spring experience could come in handy, but is not strictly necessary. After this session, you will know enough to start your own Spring Boot project.
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)🎤 Hanno Embregts 🎸
Spring Boot is a framework for creating stand-alone, production-grade Spring based applications that can be "run" using java -jar without the need for an external web server. It favors convention over configuration and aims to get developers up and running quickly with minimal configuration. Key features include an embedded web server, automatic configuration, and starters that provide prepackaged dependencies. Pros include faster development and deployment, while potential cons include more complex custom configuration and incompatibility with some legacy Spring projects. The documentation provides guidance on creating starter projects with an initial Java file, build script, and dependencies.
Building a Spring Boot Application - Ask the Audience!🎤 Hanno Embregts 🎸
This document provides an overview of building applications with Spring Boot. It discusses key features such as creating stand-alone Spring applications without separate web servers, automatic Spring configuration, and getting started quickly with one Java file and a build script. Pros include faster deployments and no need for web.xml files. Cons can include custom configuration challenges and incompatibility with some legacy Spring projects. The document also demonstrates sample code and references Spring Initializr for project setups.
If you're reading this summary on a computer, chances are there is a QWERTY keyboard on your desk. This keyboard layout has been around since 1873, and it has been widely adopted ever since. However, its popularity has always remained a mystery to me. Why is everyone using a keyboard layout that doesn't look that efficient on first sight?
I'm not the only one asking this question. A lot of myths exist on the QWERTY keyboard layout, including the one that it was specifically designed to slow down typists. In preparation for a switch to the DVORAK layout, I did some research and found out that a lot of these myths are riddled with factual errors. Also, I started learning DVORAK and kept track of my progress and what I thought were the pros and cons.
So was QWERTY designed to slow us down? Is it feasible to adopt an alternative layout like DVORAK? If so, how long will it take you to learn it, and should everyone consider it? Join this session to have your questions answered, and feel free to bring your keyboard layout of choice. :-)
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)🎤 Hanno Embregts 🎸
Spring Boot makes it easy to create stand-alone Spring-based application that you can 'just run'. It uses a 'convention over configuration' approach to get you up and running in no-time, while offering all Spring features that you have grown fond of in the past years. In this session this is demonstrated by live-coding a Spring Boot application that will just work.
But audience beware, this is not your standard live-coding session'. Attendees will have a vital say in the session's content by defining the applications requ irements. Should it be an app to track your kitchen cupboard contents or do you want a simple task planner? It's up to you! Should it use MongoDB or Couchbase? You decide! Do you want an AngularJS front-end with a RESTful backend or do you prefer a classic web app with Thymeleaf templates? It's your call! Seriously.
During the session you get to make these decisions by participating in an online vote. And you will discover that Spring Boot is up to the task no matter what choices you make.
So what are you waiting for? Bring your own device, help shape the application that we're building and learn lots about Spring Boot in the process.
This session is intended for Java software engineers with an interest in Spring Boot. Some Spring experience could come in handy, but is not strictly necessary. After this session, you will know enough to start your own Spring Boot project.
Most developers prefer to spend their time writing code instead of performing build script maintenance. Build scripting may be an essential part of the software development process, but it often lacks maintainability which makes applying and deploying changes a tedious job. So it’s important to make sure your build system encourages simplicity and that changes can be made in a fast and straightforward way. Industry standards Ant and Maven are not quite up to the task; Gradle is a better alternative.
This presentation introduces Gradle – a modern build system that supports all JVM Languages – and shares the result of the Ant-to-Gradle migration that was performed at NS (Dutch Railways). The session will focus on the challenges we faced while trying to replace Ant scripting with the Gradle equivalent and how we handled them.
After attending this session, you will have a good understanding of Gradle and its pros and cons compared to Ant and Maven. On top of that, you will be able to migrate your own project to Gradle, even if your project has a huge code base or relies on ancient technologies. The lessons we learnt at NS could be very helpful to your own situation.
The Power of Visual Regression Testing_ Why It Is Critical for Enterprise App...kalichargn70th171
Visual testing plays a vital role in ensuring that software products meet the aesthetic requirements specified by clients in functional and non-functional specifications. In today's highly competitive digital landscape, users expect a seamless and visually appealing online experience. Visual testing, also known as automated UI testing or visual regression testing, verifies the accuracy of the visual elements that users interact with.
Enhanced Screen Flows UI/UX using SLDS with Tom KittPeter Caitens
Join us for an engaging session led by Flow Champion, Tom Kitt. This session will dive into a technique of enhancing the user interfaces and user experiences within Screen Flows using the Salesforce Lightning Design System (SLDS). This technique uses Native functionality, with No Apex Code, No Custom Components and No Managed Packages required.
Transforming Product Development using OnePlan To Boost Efficiency and Innova...OnePlan Solutions
Ready to overcome challenges and drive innovation in your organization? Join us in our upcoming webinar where we discuss how to combat resource limitations, scope creep, and the difficulties of aligning your projects with strategic goals. Discover how OnePlan can revolutionize your product development processes, helping your team to innovate faster, manage resources more effectively, and deliver exceptional results.
DevOps Consulting Company | Hire DevOps Servicesseospiralmantra
Spiral Mantra excels in providing comprehensive DevOps services, including Azure and AWS DevOps solutions. As a top DevOps consulting company, we offer controlled services, cloud DevOps, and expert consulting nationwide, including Houston and New York. Our skilled DevOps engineers ensure seamless integration and optimized operations for your business. Choose Spiral Mantra for superior DevOps services.
https://www.spiralmantra.com/devops/
A neural network is a machine learning program, or model, that makes decisions in a manner similar to the human brain, by using processes that mimic the way biological neurons work together to identify phenomena, weigh options and arrive at conclusions.
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
14 th Edition of International conference on computer visionShulagnaSarkar2
About the event
14th Edition of International conference on computer vision
Computer conferences organized by ScienceFather group. ScienceFather takes the privilege to invite speakers participants students delegates and exhibitors from across the globe to its International Conference on computer conferences to be held in the Various Beautiful cites of the world. computer conferences are a discussion of common Inventions-related issues and additionally trade information share proof thoughts and insight into advanced developments in the science inventions service system. New technology may create many materials and devices with a vast range of applications such as in Science medicine electronics biomaterials energy production and consumer products.
Nomination are Open!! Don't Miss it
Visit: computer.scifat.com
Award Nomination: https://x-i.me/ishnom
Conference Submission: https://x-i.me/anicon
For Enquiry: Computer@scifat.com
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
Superpower Your Apache Kafka Applications Development with Complementary Open...Paul Brebner
Kafka Summit talk (Bangalore, India, May 2, 2024, https://events.bizzabo.com/573863/agenda/session/1300469 )
Many Apache Kafka use cases take advantage of Kafka’s ability to integrate multiple heterogeneous systems for stream processing and real-time machine learning scenarios. But Kafka also exists in a rich ecosystem of related but complementary stream processing technologies and tools, particularly from the open-source community. In this talk, we’ll take you on a tour of a selection of complementary tools that can make Kafka even more powerful. We’ll focus on tools for stream processing and querying, streaming machine learning, stream visibility and observation, stream meta-data, stream visualisation, stream development including testing and the use of Generative AI and LLMs, and stream performance and scalability. By the end you will have a good idea of the types of Kafka “superhero” tools that exist, which are my favourites (and what superpowers they have), and how they combine to save your Kafka applications development universe from swamploads of data stagnation monsters!
Unlock the Secrets to Effortless Video Creation with Invideo: Your Ultimate G...The Third Creative Media
"Navigating Invideo: A Comprehensive Guide" is an essential resource for anyone looking to master Invideo, an AI-powered video creation tool. This guide provides step-by-step instructions, helpful tips, and comparisons with other AI video creators. Whether you're a beginner or an experienced video editor, you'll find valuable insights to enhance your video projects and bring your creative ideas to life.
The Rising Future of CPaaS in the Middle East 2024Yara Milbes
Explore "The Rising Future of CPaaS in the Middle East in 2024" with this comprehensive PPT presentation. Discover how Communication Platforms as a Service (CPaaS) is transforming communication across various sectors in the Middle East.
Liberarsi dai framework con i Web Component.pptxMassimo Artizzu
In Italian
Presentazione sulle feature e l'utilizzo dei Web Component nell sviluppo di pagine e applicazioni web. Racconto delle ragioni storiche dell'avvento dei Web Component. Evidenziazione dei vantaggi e delle sfide poste, indicazione delle best practices, con particolare accento sulla possibilità di usare web component per facilitare la migrazione delle proprie applicazioni verso nuovi stack tecnologici.
WWDC 2024 Keynote Review: For CocoaCoders AustinPatrick Weigel
Overview of WWDC 2024 Keynote Address.
Covers: Apple Intelligence, iOS18, macOS Sequoia, iPadOS, watchOS, visionOS, and Apple TV+.
Understandable dialogue on Apple TV+
On-device app controlling AI.
Access to ChatGPT with a guest appearance by Chief Data Thief Sam Altman!
App Locking! iPhone Mirroring! And a Calculator!!
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
DECODING JAVA THREAD DUMPS: MASTER THE ART OF ANALYSISTier1 app
Are you ready to unlock the secrets hidden within Java thread dumps? Join us for a hands-on session where we'll delve into effective troubleshooting patterns to swiftly identify the root causes of production problems. Discover the right tools, techniques, and best practices while exploring *real-world case studies of major outages* in Fortune 500 enterprises. Engage in interactive lab exercises where you'll have the opportunity to troubleshoot thread dumps and uncover performance issues firsthand. Join us and become a master of Java thread dump analysis!
Photoshop Tutorial for Beginners (2024 Edition)alowpalsadig
Photoshop Tutorial for Beginners (2024 Edition)
Explore the evolution of programming and software development and design in 2024. Discover emerging trends shaping the future of coding in our insightful analysis."
Here's an overview:Introduction: The Evolution of Programming and Software DevelopmentThe Rise of Artificial Intelligence and Machine Learning in CodingAdopting Low-Code and No-Code PlatformsQuantum Computing: Entering the Software Development MainstreamIntegration of DevOps with Machine Learning: MLOpsAdvancements in Cybersecurity PracticesThe Growth of Edge ComputingEmerging Programming Languages and FrameworksSoftware Development Ethics and AI RegulationSustainability in Software EngineeringThe Future Workforce: Remote and Distributed TeamsConclusion: Adapting to the Changing Software Development LandscapeIntroduction: The Evolution of Programming and Software Development
Photoshop Tutorial for Beginners (2024 Edition)Explore the evolution of programming and software development and design in 2024. Discover emerging trends shaping the future of coding in our insightful analysis."Here's an overview:Introduction: The Evolution of Programming and Software DevelopmentThe Rise of Artificial Intelligence and Machine Learning in CodingAdopting Low-Code and No-Code PlatformsQuantum Computing: Entering the Software Development MainstreamIntegration of DevOps with Machine Learning: MLOpsAdvancements in Cybersecurity PracticesThe Growth of Edge ComputingEmerging Programming Languages and FrameworksSoftware Development Ethics and AI RegulationSustainability in Software EngineeringThe Future Workforce: Remote and Distributed TeamsConclusion: Adapting to the Changing Software Development LandscapeIntroduction: The Evolution of Programming and Software Development
The importance of developing and designing programming in 2024
Programming design and development represents a vital step in keeping pace with technological advancements and meeting ever-changing market needs. This course is intended for anyone who wants to understand the fundamental importance of software development and design, whether you are a beginner or a professional seeking to update your knowledge.
Course objectives:
1. **Learn about the basics of software development:
- Understanding software development processes and tools.
- Identify the role of programmers and designers in software projects.
2. Understanding the software design process:
- Learn about the principles of good software design.
- Discussing common design patterns such as Object-Oriented Design.
3. The importance of user experience (UX) in modern software:
- Explore how user experience can improve software acceptance and usability.
- Tools and techniques to analyze and improve user experience.
4. Increase efficiency and productivity through modern development tools:
- Access to the latest programming tools and languages used in the industry.
- Study live examples of applications
4. #JFall #PatternMatching @hannotify @PeterWessels
Small Enhancement
Small Enhancement
Small Enhancement
Small Enhancement
Small Enhancement
https://gph.is/g/ZPJNoPQ
5. #JFall #PatternMatching @hannotify @PeterWessels
Major Feature
Major Feature
Major Feature
Major Feature
Major Feature
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
6. #JFall #PatternMatching @hannotify @PeterWessels
Pattern
Pattern
Pattern
Pattern
Pattern
Matching for
Matching for
Matching for
Matching for
Matching for
instanceof
instanceof
instanceof
instanceof
instanceof
https://pxhere.com/en/photo/752901
9. #JFall #PatternMatching @hannotify @PeterWessels
Instanceof-and-cast
Instanceof-and-cast
if (product instanceof Guitar) { // 1. is product a Guitar?
1
Guitar lesPaul =
2
(Guitar) product;
3
// use lesPaul
4
}
5
10. #JFall #PatternMatching @hannotify @PeterWessels
Instanceof-and-cast
Instanceof-and-cast
(Guitar) product; // 2. perform conversion
if (product instanceof Guitar) { // 1. is product a Guitar?
1
Guitar lesPaul =
2
3
// use lesPaul
4
}
5
11. #JFall #PatternMatching @hannotify @PeterWessels
Instanceof-and-cast
Instanceof-and-cast
Guitar lesPaul = // 3. declare variable, bind value
if (product instanceof Guitar) { // 1. is product a Guitar?
1
2
(Guitar) product; // 2. perform conversion
3
// use lesPaul
4
}
5
12. #JFall #PatternMatching @hannotify @PeterWessels
Improve the situation
Improve the situation
if (product instanceof Guitar) { // 1. is product a Guitar?
Guitar lesPaul = // 3. declare variable, bind value
(Guitar) product; // 2. perform conversion
// use lesPaul
}
1
2
3
4
5
13. #JFall #PatternMatching @hannotify @PeterWessels
Improve the situation
Improve the situation
if (product instanceof Guitar lesPaul) {
1
2 // use lesPaul
3 }
14. #JFall #PatternMatching @hannotify @PeterWessels
Type pattern
Type pattern
Type pattern
Type pattern
Type pattern
Consists of a predicate that specifies a
type, along with a single binding variable.
https://www.pexels.com/photo/person-holding-white-chalk-625219/
15. #JFall #PatternMatching @hannotify @PeterWessels
Pattern matching
Pattern matching
Pattern matching
Pattern matching
Pattern matching
Allows the conditional extraction of
components from objects to be
expressed more concisely and safely.
https://www.pexels.com/photo/person-holding-white-chalk-625219/
17. #JFall #PatternMatching @hannotify @PeterWessels
Declaring 'in the middle'
Declaring 'in the middle'
if (product instanceof Guitar lesPaul) {
// use lesPaul
}
1
2
3
18. #JFall #PatternMatching @hannotify @PeterWessels
Scoping
Scoping
Pattern binding variable ('flow scoping')
Pattern binding variable ('flow scoping')
The set of places where it would definitely be assigned.
if (product instanceof Guitar lesPaul && lesPaul.isInTune()) {
// can use lesPaul here
} else {
// can't use lesPaul here
}
1
2
3
4
5
19. #JFall #PatternMatching @hannotify @PeterWessels
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
pattern example
type pattern Guitar lesPaul
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
20. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Type Patterns
Type Patterns
Java version Feature status JEP
14 Preview
15 Second preview
16 Final
JEP 305
JEP 375
JEP 394
21. #JFall #PatternMatching @hannotify @PeterWessels
Pattern
Pattern
Pattern
Pattern
Pattern
Matching for
Matching for
Matching for
Matching for
Matching for
switch
switch
switch
switch
switch https://pxhere.com/en/photo/752901
30. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
case Delay de -> String.format("Delay active of %d ms.", de.getT
case Reverb re -> String.format("Reverb active of type %s and roo
String apply(Effect effect) {
1
return switch(effect) {
2
3
4
5 default -> String.format("Unknown effect active: %s.", eff
6 };
7 }
31. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
1 String apply(Effect effect) {
2 return switch(effect) {
3 case Delay de -> String.format("Delay active of %d ms.", de.get
4 case Reverb re -> String.format("Reverb active of type %s and ro
5 case Overdrive ov -> String.format("Overdrive active with gain %d."
6 case Tremolo tr -> String.format("Tremolo active with depth %d an
7 case Tuner tu -> String.format("Tuner active with pitch %d. Mut
8 default -> String.format("Unknown effect active: %s.", ef
9 };
10 }
32. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
String apply(Effect effect) {
1
return switch(effect) {
2
case Delay de -> String.format("Delay active of %d ms.", de.get
3
case Reverb re -> String.format("Reverb active of type %s and ro
4
case Overdrive ov -> String.format("Overdrive active with gain %d."
5
case Tremolo tr -> String.format("Tremolo active with depth %d an
6
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
7
8
9 default -> String.format("Unknown effect active: %s.", ef
10 };
11 }
33. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
String apply(Effect effect) {
return switch(effect) {
case Delay de -> String.format("Delay active of %d ms.", de.get
case Reverb re -> String.format("Reverb active of type %s and ro
case Overdrive ov -> String.format("Overdrive active with gain %d."
case Tremolo tr -> String.format("Tremolo active with depth %d an
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
default -> String.format("Unknown effect active: %s.", ef
};
}
1
2
3
4
5
6
7
8
9
10
11
35. #JFall #PatternMatching @hannotify @PeterWessels
Sensible operations to the effect
Sensible operations to the effect
loop
loop
apply()
setVolume(int volume)
contains(Effect... effect)
36. #JFall #PatternMatching @hannotify @PeterWessels
Nonsensical operations to the
Nonsensical operations to the
effect loop
effect loop
isTunerActive()
isDelayTimeEqualToReverbRoomSize()
isToneSuitableToPlayPrideInTheNameOfLove()
37. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
String apply(Effect effect) {
return switch(effect) {
case Delay de -> String.format("Delay active of %d ms.", de.get
case Reverb re -> String.format("Reverb active of type %s and ro
case Overdrive ov -> String.format("Overdrive active with gain %d."
case Tremolo tr -> String.format("Tremolo active with depth %d an
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
default -> String.format("Unknown effect active: %s.", ef
};
}
1
2
3
4
5
6
7
8
9
10
11
38. #JFall #PatternMatching @hannotify @PeterWessels
Switch expression
Switch expression
static String apply(Effect effect) {
return switch(effect) {
case Delay de -> String.format("Delay active of %d ms.", de.get
case Reverb re -> String.format("Reverb active of type %s and ro
case Overdrive ov -> String.format("Overdrive active with gain %d."
case Tremolo tr -> String.format("Tremolo active with depth %d an
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
case EffectLoop el -> el.getEffects().stream().map(Effect::apply).co
default -> String.format("Unknown effect active: %s.", ef
};
}
1
2
3
4
5
6
7
8
9
10
11
39. #JFall #PatternMatching @hannotify @PeterWessels
Benefits of pattern
Benefits of pattern
matching
matching
No need for the Visitor pattern or a common supertype
A single expression instead of many assignments
Less error-prone (in adding cases)
More concise
Safer - the compiler can check for missing cases
40. #JFall #PatternMatching @hannotify @PeterWessels
But what if
But what if effect
effect is
is null
null?
?
return switch(effect) { // throws NullPointerException!
static String apply(Effect effect) {
1
2
case Delay de -> String.format("Delay active of %d ms.", de.get
3
case Reverb re -> String.format("Reverb active of type %s and ro
4
case Overdrive ov -> String.format("Overdrive active with gain %d."
5
case Tremolo tr -> String.format("Tremolo active with depth %d an
6
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
7
case EffectLoop el -> el.getEffects().stream().map(Effect::apply).co
8
default -> String.format("Unknown effect active: %s.", ef
9
};
10
}
11
41. #JFall #PatternMatching @hannotify @PeterWessels
Combining case labels
Combining case labels
case null, default -> String.format("Unknown or malfunctioning effec
static String apply(Effect effect) {
1
return switch(effect) {
2
case Delay de -> String.format("Delay active of %d ms.", de.get
3
case Reverb re -> String.format("Reverb active of type %s and ro
4
case Overdrive ov -> String.format("Overdrive active with gain %d."
5
case Tremolo tr -> String.format("Tremolo active with depth %d an
6
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
7
case EffectLoop el -> el.getEffects().stream().map(Effect::apply).co
8
9
};
10
}
11
43. #JFall #PatternMatching @hannotify @PeterWessels
Guarded patterns
Guarded patterns
String apply(Effect effect, Guitar guitar) {
return switch(effect) {
// (...)
case Tremolo tr -> String.format("Tremolo active with depth %d and ra
case Tuner tu -> String.format("Tuner active with pitch %d. Muting al
case EffectLoop el -> el.getEffects().stream().map(this::apply).colle
default -> String.format("Unknown effect active: %s.", effect);
};
}
1
2
3
4
5
6
7
8
9
44. #JFall #PatternMatching @hannotify @PeterWessels
Guarded patterns
Guarded patterns
case Tuner tu && !tu.isInTune(guitar) -> String.format("Guitar is in
String apply(Effect effect, Guitar guitar) {
1
return switch(effect) {
2
// (...)
3
case Tremolo tr -> String.format("Tremolo active with depth %d and ra
4
5
case EffectLoop el -> el.getEffects().stream().map(this::apply).colle
6
default -> String.format("Unknown effect active: %s.", effect);
7
};
8
}
9
45. #JFall #PatternMatching @hannotify @PeterWessels
Guarded patterns
Guarded patterns
case Tuner tu when !tu.isInTune(guitar) -> String.format("Guitar is i
String apply(Effect effect, Guitar guitar) {
1
return switch(effect) {
2
// (...)
3
case Tremolo tr -> String.format("Tremolo active with depth %d and ra
4
5
case EffectLoop el -> el.getEffects().stream().map(this::apply).colle
6
default -> String.format("Unknown effect active: %s.", effect);
7
};
8
}
9
46. #JFall #PatternMatching @hannotify @PeterWessels
Guarded patterns
Guarded patterns
switch(effect) {
// ...
case Tuner tu:
if (!tu.isInTune(guitar)) { // tuning is needed }
else { // no tuning is needed }
break;
// ...
}
1
2
3
4
5
6
7
8
47. #JFall #PatternMatching @hannotify @PeterWessels
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
pattern example
guarded pattern Tuner tu when
!tu.isInTune(guitar)
type pattern Guitar lesPaul
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
48. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Pattern Matching for Switch
Pattern Matching for Switch
Java version Feature status JEP
17 Preview
18 Second preview
19 Third preview
20 Fourth preview
JEP 406
JEP 420
JEP 427
JEP 433
49. #JFall #PatternMatching @hannotify @PeterWessels
Deconstructio
Deconstructio
Deconstructio
Deconstructio
Deconstructio
n Patterns
n Patterns
n Patterns
n Patterns
n Patterns
https://pxhere.com/en/photo/752901
50. #JFall #PatternMatching @hannotify @PeterWessels
Disclaimer
Disclaimer
Disclaimer
Disclaimer
Disclaimer
We can't tell you when the following
features are coming to Java. Also: syntax
and implementation specifics may still
change.
https://pxhere.com/en/photo/1359311
51. #JFall #PatternMatching @hannotify @PeterWessels
Deconstruction patterns
Deconstruction patterns
String apply(Effect effect) {
return switch(effect) {
case Delay de -> String.format("Delay active of %d ms.", de.get
case Reverb re -> String.format("Reverb active of type %s and ro
case Overdrive ov -> String.format("Overdrive active with gain %d."
case Tremolo tr -> String.format("Tremolo active with depth %d an
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
default -> String.format("Unknown effect active: %s.", ef
};
}
1
2
3
4
5
6
7
8
9
10
11
52. #JFall #PatternMatching @hannotify @PeterWessels
Deconstruction patterns
Deconstruction patterns
case Overdrive(int gain) -> String.format("Overdrive active with gai
String apply(Effect effect) {
1
return switch(effect) {
2
case Delay de -> String.format("Delay active of %d ms.", de.get
3
case Reverb re -> String.format("Reverb active of type %s and ro
4
5
case Tremolo tr -> String.format("Tremolo active with depth %d an
6
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
7
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
8
default -> String.format("Unknown effect active: %s.", ef
9
};
10
}
11
53. #JFall #PatternMatching @hannotify @PeterWessels
Pattern definition
Pattern definition
public class Overdrive implements Effect {
private final int gain;
public Overdrive(int gain) {
this.gain = gain;
}
}
1
2
3
4
5
6
7
54. #JFall #PatternMatching @hannotify @PeterWessels
Pattern definition
Pattern definition
1 public class Overdrive implements Effect {
2 private final int gain;
3
4 public Overdrive(int gain) {
5 this.gain = gain;
6 }
7
public pattern Overdrive(int gain) {
8
gain = this.gain;
9
}
10
11 }
55. #JFall #PatternMatching @hannotify @PeterWessels
Deconstruction patterns
Deconstruction patterns
case Overdrive(int gain) -> String.format("Overdrive active with gai
String apply(Effect effect) {
1
return switch(effect) {
2
case Delay de -> String.format("Delay active of %d ms.", de.get
3
case Reverb re -> String.format("Reverb active of type %s and ro
4
5
case Tremolo tr -> String.format("Tremolo active with depth %d an
6
case Tuner tu -> String.format("Tuner active with pitch %d. Mut
7
case EffectLoop el -> el.getEffects().stream().map(this::apply).coll
8
default -> String.format("Unknown effect active: %s.", ef
9
};
10
}
11
57. #JFall #PatternMatching @hannotify @PeterWessels
Deconstruction patterns
Deconstruction patterns
String apply(Effect effect) {
return switch(effect) {
case Delay(int timeInMs) -> String.format("Delay active of %d ms.",
case Reverb(String name, int roomSize) -> String.format("Reverb acti
case Overdrive(int gain) -> String.format("Overdrive active with gai
case Tremolo(int depth, int rate) -> String.format("Tremolo active w
case Tuner(int pitchInHz) -> String.format("Tuner active with pitch
case EffectLoop(Set<Effect> effects) -> effects.stream().map(this::a
default -> String.format("Unknown effect active: %s.", effect);
};
}
1
2
3
4
5
6
7
8
9
10
11
58. #JFall #PatternMatching @hannotify @PeterWessels
Can we combine patterns?
Can we combine patterns?
static boolean isDelayTimeEqualToReverbRoomSize(EffectLoop effectLoop) {
}
1
2
3
61. #JFall #PatternMatching @hannotify @PeterWessels
Var patterns
Var patterns
// Pre-Java 10
Guitar telecaster = new Guitar("Fender Telecaster Baritone Blacktop", GuitarT
// Java 10
var telecaster = new Guitar("Fender Telecaster Baritone Blacktop", GuitarType
1
2
3
4
5
https://openjdk.java.net/jeps/286
https://openjdk.java.net/jeps/286
62. #JFall #PatternMatching @hannotify @PeterWessels
Var patterns
Var patterns
static boolean isDelayTimeEqualToReverbRoomSize(EffectLoop effectLoop) {
if (effectLoop instanceof EffectLoop(Delay(int timeInMs), Reverb(String n
return timeInMs == roomSize;
}
return false;
}
1
2
3
4
5
6
63. #JFall #PatternMatching @hannotify @PeterWessels
Var patterns
Var patterns
if (effectLoop instanceof EffectLoop(Delay(var timeInMs), Reverb(var name
static boolean isDelayTimeEqualToReverbRoomSize(EffectLoop effectLoop) {
1
2
return timeInMs == roomSize;
3
}
4
return false;
5
}
6
64. #JFall #PatternMatching @hannotify @PeterWessels
Benefits of
Benefits of
deconstruction patterns
deconstruction patterns
Better encapsulation
a case branch only receives data that it actually references.
More elegant logic
by using pattern composition
65. #JFall #PatternMatching @hannotify @PeterWessels
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
pattern example
deconstruction pattern Delay(int timeInMs)
type pattern Guitar lesPaul
guarded pattern Tuner tu when
!tu.isInTune(guitar)
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
66. #JFall #PatternMatching @hannotify @PeterWessels
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
pattern example
var pattern var timeInMs
type pattern Guitar lesPaul
guarded pattern Tuner tu when
!tu.isInTune(guitar)
deconstruction pattern Delay(int timeInMs)
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
67. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Deconstruction patterns
Deconstruction patterns
Java
version
Feature status JEP
19 Preview (deconstruction with record
patterns only)
n/a Second preview (deconstruction with
record patterns only)
JEP
405
JEP
432
68. #JFall #PatternMatching @hannotify @PeterWessels
Pattern Matching Plays
Pattern Matching Plays
Nice With
Nice With
Sealed Types
Sealed Types
Sealed Types
Sealed Types
Sealed Types
and Records
and Records
and Records
and Records
and Records
https://pxhere.com/en/photo/752901
70. #JFall #PatternMatching @hannotify @PeterWessels
Sealed types yield completeness
Sealed types yield completeness
static String apply(Effect effect) {
return switch(effect) {
case Delay(int timeInMs) -> String.format("Delay active of %d ms.",
case Reverb(String name, int roomSize) -> String.format("Reverb acti
case Overdrive(int gain) -> String.format("Overdrive active with gai
case Tremolo(int depth, int rate) -> String.format("Tremolo active w
case Tuner(int pitchInHz) -> String.format("Tuner active with pitch
case EffectLoop(Tuner(int pitchInHz), _) -> String.format("The Effec
case EffectLoop(var effects) -> effects.stream().map(Effect::apply).
default -> String.format("Unknown effect active: %s.", effect);
};
}
1
2
3
4
5
6
7
8
9
10
11
12
71. #JFall #PatternMatching @hannotify @PeterWessels
Sealed types yield completeness
Sealed types yield completeness
static String apply(Effect effect) {
return switch(effect) {
case Delay(int timeInMs) -> String.format("Delay active of %d ms.",
case Reverb(String name, int roomSize) -> String.format("Reverb acti
case Overdrive(int gain) -> String.format("Overdrive active with gai
case Tremolo(int depth, int rate) -> String.format("Tremolo active w
case Tuner(int pitchInHz) -> String.format("Tuner active with pitch
case EffectLoop(Tuner(int pitchInHz), _) -> String.format("The Effec
case EffectLoop(var effects) -> effects.stream().map(Effect::apply).
1
2
3
4
5
6
7
8
9
10 };
11 }
https://openjdk.org/projects/amber/design-notes/patterns/pattern-matching-for-java
72. #JFall #PatternMatching @hannotify @PeterWessels
Records
Records
Input:
Input:
Commit to the class being a transparent carrier for its
data.
Output:
Output:
73. #JFall #PatternMatching @hannotify @PeterWessels
Patterns in enhanced for
Patterns in enhanced for
record Delay(int timeInMs) implements Effect {}
1
static void printDelays(List<Delay> delays) {
for (Delay delay : delays) {
System.out.println("Delay found with timeInMs=" + delay.timeInMs());
}
}
1
2
3
4
5
74. #JFall #PatternMatching @hannotify @PeterWessels
Patterns in enhanced for
Patterns in enhanced for
record Delay(int timeInMs) implements Effect {}
1
static void printDelays(List<Delay> delays) {
for (Delay(int timeInMs) : delays) {
System.out.println("Delay found with timeInMs=" + timeInMs);
}
}
1
2
3
4
5
75. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Sealed Types
Sealed Types
Java version Feature status JEP
15 Preview
16 Second preview
17 Final
JEP 360
JEP 397
JEP 409
76. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Completeness
Completeness
Java version Feature status JEP
17 Preview
18 Second preview
19 Third preview
JEP 406
JEP 420
JEP 427
77. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Record Patterns
Record Patterns
Java version Feature status JEP
19 Preview
n/a Second preview
JEP 405
JEP 432
78. #JFall #PatternMatching @hannotify @PeterWessels
A Better
A Better
A Better
A Better
A Better
Serialization?
Serialization?
Serialization?
Serialization?
Serialization?
https://pxhere.com/en/photo/752901
79. #JFall #PatternMatching @hannotify @PeterWessels
Here be dragons!
Here be dragons!
Here be dragons!
Here be dragons!
Here be dragons!
We can't be sure at all that the following
features will appear in Java as depicted.
They can change a lot in the meantime.
https://www.pexels.com/photo/dragon-festival-during-nighttime-6068535/
80. #JFall #PatternMatching @hannotify @PeterWessels
Opposites
Opposites
Deconstruction pattern
Deconstruction pattern
transforms an object into a set of typed fields
Constructor
Constructor
transforms a set of typed fields into an object
81. #JFall #PatternMatching @hannotify @PeterWessels
Serialization
Serialization
very important feature
but many people hate its current implementation
Drawbacks
Drawbacks
it undermines the accessibility model
serialization logic is not 'readable code'
it bypasses constructors and data validation
86. #JFall #PatternMatching @hannotify @PeterWessels
Some challenges remain
Some challenges remain
Q:
Q: How to support multiple versions of one class?
How to support multiple versions of one class?
A: @Serializer and @Deserializer annotations could
get a property version in the future.
87. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Java
version
Feature status JEP
n/a Exploratory
document
Towards Better
Serialization
https://cr.openjdk.java.net/~briangoetz/amber/serialization.html
91. #JFall #PatternMatching @hannotify @PeterWessels
Optimization
Optimization
static String apply(Effect effect) {
return switch(effect) {
case Delay(int timeInMs) -> String.format("Delay active of %d ms.",
case Reverb(String name, int roomSize) -> String.format("Reverb acti
case Overdrive(int gain) -> String.format("Overdrive active with gai
case Tremolo(int depth, int rate) -> String.format("Tremolo active w
case Tuner(int pitchInHz) -> String.format("Tuner active with pitch
case EffectLoop(var effects) -> effects.stream().map(Effect::apply).
default -> String.format("Unknown effect active: %s.", effect);
};
}
1
2
3
4
5
6
7
8
9
10
11
94. #JFall #PatternMatching @hannotify @PeterWessels
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
It's a kind of Pattern
pattern example
unnamed pattern _
type pattern Guitar lesPaul
guarded pattern Tuner tu when
!tu.isInTune(guitar)
deconstruction pattern Delay(int timeInMs)
var pattern var timeInMs
https://thumbs.gfycat.com/DefiantElasticGadwall.webp
95. #JFall #PatternMatching @hannotify @PeterWessels
Feature Status
Feature Status
Unnamed Patterns
Unnamed Patterns
Java version Feature status JEP
n/a JEP draft 8294349
https://openjdk.org/jeps/8294349
https://openjdk.org/jeps/8294349
96. #JFall #PatternMatching @hannotify @PeterWessels
Here be dragons!
Here be dragons!
Here be dragons!
Here be dragons!
Here be dragons!
We can't be sure at all that the following
features will appear in Java as depicted.
They can change a lot in the meantime.
https://www.pexels.com/photo/dragon-festival-during-nighttime-6068535/
97. #JFall #PatternMatching @hannotify @PeterWessels
Pattern bind statements
Pattern bind statements
var reverb = new Reverb("ChamberReverb", 2);
__let Reverb(String name, int roomSize) = reverb;
// do something with name & roomSize
1
2
3
4
5
https://openjdk.org/projects/amber/design-notes/patterns/pattern-matching-for-java
98. #JFall #PatternMatching @hannotify @PeterWessels
Pattern bind statements
Pattern bind statements
else throw new IllegalArgumentException("not a Reverb!");
var reverb = new Reverb("ChamberReverb", 2);
1
2
__let Reverb(String name, int roomSize) = reverb;
3
4
5
6 // do something with name & roomSize
99. #JFall #PatternMatching @hannotify @PeterWessels
Array patterns
Array patterns
record EffectLoop(String name, int volume, Effect... effects) { }
1
static String apply(EffectLoop effectLoop) {}
return switch(effectLoop) {
case EffectLoop(var name, var volume) -> "Effect loop contains no eff
}
}
1
2
3
4
5
100. #JFall #PatternMatching @hannotify @PeterWessels
Array patterns
Array patterns
record EffectLoop(String name, int volume, Effect... effects) { }
1
static String apply(EffectLoop effectLoop) {}
return switch(effectLoop) {
case EffectLoop(var name, var volume) -> "Effect loop contains no eff
case EffectLoop(_, _, var effect) -> "Effect loop contains exactly on
1
2
3
4
5 }
6 }
101. #JFall #PatternMatching @hannotify @PeterWessels
Array patterns
Array patterns
record EffectLoop(String name, int volume, Effect... effects) { }
1
static String apply(EffectLoop effectLoop) {}
return switch(effectLoop) {
case EffectLoop(var name, var volume) -> "Effect loop contains no eff
case EffectLoop(_, _, var effect) -> "Effect loop contains exactly on
case EffectLoop(_, _, var effect, ...) -> "Effect loop contains more
1
2
3
4
5
6 }
7 }
102. #JFall #PatternMatching @hannotify @PeterWessels
Array patterns
Array patterns
record EffectLoop(String name, int volume, Effect... effects) { }
1
static String apply(EffectLoop effectLoop) {}
return switch(effectLoop) {
case EffectLoop(var name, var volume) -> "Effect loop contains no eff
case EffectLoop(_, _, var effect) -> "Effect loop contains exactly on
case EffectLoop(_, _, var effect, ...) -> "Effect loop contains more
case EffectLoop(_, _, var effect1, var effect2) -> "Effect loop conta
case EffectLoop(_, _, var effect1, var effect2, ...) -> "Effect loop
1
2
3
4
5
6
7
8 }
9 }
103. #JFall #PatternMatching @hannotify @PeterWessels
Other ideas
Other ideas
Deconstruction patterns for arbitrary classes
Enhanced array patterns
String[] { [8] -> var eighthElement, [9] -> var ninthElement}
AND patterns
Patterns in catch clauses
Collection patterns
https://mail.openjdk.java.net/pipermail/amber-spec-experts/2021-January/002758.html
105. #JFall #PatternMatching @hannotify @PeterWessels
Pattern Contexts
Pattern Contexts
Pattern
context
Example Purpose
instanceof
predicate
product instanceof
Guitar guitar
Test if target matches the
indicated pattern.
switch
statement or
expression
switch (effect) {
case Delay d ->
}
Test if target matches one (or
more) of the indicated patterns.
enhanced for for (Delay(int
timeInMs) : delays) {
}
Perform a iteration for each
target that matches the indicated
pattern.
bind
statement
__let Reverb(var
name, var roomSize) =
Destructure a target using a
pattern.
107. #JFall #PatternMatching @hannotify @PeterWessels
Pattern matching...
Pattern matching...
is a rich feature arc that will play out over several
versions.
allows us to use type patterns in instanceof.
improves switch expressions.
makes destructuring objects as easy as (and more similar
to) constructing them.
holds the potential to simplify and streamline much of
the code we write today.