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
Jactl is optionally typed so if you use
int,long,etc, orvar i = 1, then Jactl can avoid boxing. If everything is untyped (declared withdef) then it will box/unbox when necessary. With for-in loop, there is a special case for arrays where it can avoid boxing/unboxing:int[] arr = [1,2,3]for (i in arr) { println i } // i will be an int, no boxing/unboxingBut, in general, if the collection is a list, then boxing/unboxing will take place if you need to treat the elements as a primitive.
Here is a chart showing compilation speed when everything is running on Java 25: chart
The Java 21 results are very similar to the Java 25 results: