Our great sponsors
-
expressive-java
Example of matching Scala's case class expressiveness in Java 8, Java 15 and Java 17
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I wanted to share this little project I found. The author has been writing Java re-implementations of the same Scala interpreter over the years as newer JDK versions & features are released.
With JDK17 and the introduction of Record types, sealed classes/interfaces, and pattern-matching the implementation can come close to ver-batim mirroring the Scala 2 one:
https://github.com/Randgalt/expressive-java/blob/master/java...
Unfortunately, the Scala org website is down right now, so the original code can be viewed here for the moment:
https://web.archive.org/web/20200103022853/https://www.scala...
(Or also in the repo: https://github.com/Randgalt/expressive-java/blob/master/scal...)
The final feature that is needed to really seal the deal, is part of JEP 405 for destructuring + binding to values in patterns ("Deconstruction patterns"):
https://github.com/Randgalt/expressive-java/issues/3
https://openjdk.java.net/jeps/405
Related posts
- Deconstructing Records in Pattern Matching - Inside Java Newscast #26
- ExpressiveJava: Re-implementing a simple Scala interpreter in JDK 8/15/17. JDK 17 code nearly identical with use of Records + Pattern Matching + Sealed Types.
- Java 23: The New Features Are Officially Announced
- "xAI will open source Grok"
- What is Load Testing? Complete Tutorial With Best Practices