r/java • u/jaccomoc • May 27 '26
Announcing Jactl 2.8: Compilation performance improvements and for-in loops with pattern matching and destructuring
Jactl is a secure, embeddable, scripting language for Java applications. Release 2.8 adds a new for-in statement and major compilation speed improvements.
The new for loop looks like:
for (pattern in collection) { ... }
This matches a structural pattern with variable binding against elements of a collection and iterates over all matched elements.
An alternative version uses strict matching and will fail if any element does not match:
for (pattern: collection) { ... }
Some examples:
for (i in collection) {} // match all elements and bind each one to i
for (int i in collection) {} // match all ints and bind to i
for ([i,j] in collection) {} // bind i,j to each 2-element sublist in collection
for ([i,_] in collection) {} // bind i to first element of each 2-element sublist
for ([i,i] in collection) {} // match all 2-element sublists with identical elements
for ([x,*] in collection) {} // bind x to head of all sublists of size >= 1
for ([h,*t] in collection) {} // bind h to head and t to remaining elements of each sublist
// More complex structures can be used:
for ([a, [_, int b, a]] in collection) {}
Patterns can also match Map instances and class instances. See Jactl 2.8.0 release notes for more details.
Compilation speed is the other big improvement in this release. Compilation speed is now over three times faster than the previous release (based on the Jactl Compilation Benchmark):

View all comments
Show parent comment
2
u/jaccomoc May 27 '26 edited May 28 '26
Jactl does not have a way to flag things as immutable and doesn't currently have immutable data structures like lists and maps as such but it does offer functional programming constructs for transforming lists of values by applying closures to perform map/flatMap/filter/etc.
It doesn't have a concurrency library due to its primary aim being to provide flexible "call outs" from a Java application. It is something to consider for the future. I will have a look at the dataweave stuff and see what is involved.
I am not really sure why it compiles faster than Java. It was on par in previously releases and I spent some time improving it for this release but I don't really know why it is faster. I certainly don't claim to have written the fastest compiler ever. It is just a simple recursive descent parser followed by a resolve, analyse, and compile phase. Java does more things in terms of supporting generics, optimisations, reachability analysis, annotation processing, etc that Jactl doesn't and may need more phases to accomplish everything.