expressive-java
record-builder
Our great sponsors
expressive-java | record-builder | |
---|---|---|
6 | 35 | |
14 | 650 | |
- | - | |
0.0 | 7.3 | |
almost 2 years ago | 17 days ago | |
Java | Java | |
- | Apache License 2.0 |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
expressive-java
- 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.
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: - Scala: https://www.scala-lang.org/old/node/56.html - JDK 17 Java: https://github.com/Randgalt/expressive-java/blob/master/java-17/src/main/java/examples/SimpleInterpreter.java
-
ExpressiveJava: Rewriting simple Scala interpreter – JDK17 code nearly identical
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
-
Why Co–Star Uses Haskell
using records and ADTs (sealed types) with pattern match "switch" and the net result is an almost verbatim translation.
https://github.com/Randgalt/expressive-java/issues/1
There is one ugly line which JDK18 will fix, "destructuring in pattern captures/match".
record-builder
-
JEP Draft – Derived Record Creation (Preview) – Java
The problem with this approach is that the people will have to build crutches like https://github.com/Randgalt/record-builder and by the time Java adds missing features all the codebases will be forever polluted with legacy workarounds that nobody will dare to remove because of backwards compatibility.
It also hinders adoption of new features as people will prefer to maintain consistency in their codebases.
-
Any library you would like to recommend to others as it helps you a lot? For me, mapstruct is one of them. Hopefully I would hear some other nice libraries I never try.
Record builder is pretty good for making builders for your Java 17 records
-
Useful & Unknown Java Libraries - Piotr's TechBlog
I always have to bring up RecordBuilder simply because of the included Withers and it being a source generator instead of the Lombok weirdness.
-
How to use Java Records
The above is not particularly user-friendly. Luckily compiler plugins can provide the missing feature, most notably RecordBuilder:
-
Named Parameters in Java
For records, instead of lombok you can use https://github.com/Randgalt/record-builder which is a valid annotation processor and will not break on JDK changes
-
has anyone written custom annotations using Lombok ?
In this particular case you can generate the builder with something like https://github.com/Randgalt/record-builder that is both valid java and lombok-like enough
-
I made a java client for the todoist api
Records + Record Builder or immutables + the trick to hide the implementing class w/sealed are your friend. Both the mutability and naming conventions this generates are vomitus.
-
"With" for records -- Brian Goetz
Did you use https://github.com/Randgalt/record-builder ?
-
What's your top Java pet peeve?
Try my annotation processor. It generates withers. https://github.com/Randgalt/record-builder
-
Stay with Java(+Spring) or pivot towards Go/Python?
I personally don't use that one much, but you could use this library instead.