Hacker News new | ask | show | jobs
by brabel 2091 days ago
While this is cool, it doesn't look like something very different from other existing JVM compiler plugins... it seems quite similar to Javac plugins[0] and perhaps somewhere in between that and Groovy AST transformers[1].

Manifold[2] is basically a javac plugin if I'm not mistaken, and it shows just how powerful stuff can be accomplished with this approach (including e.g. auto-generation of Java types from common modelling languages like GraphQL, JSON, YAML etc. adds extension methods, unit expressions, ranges, C++-like preprocessors, structural subtyping, even crazy stuff like type-safe reflection - like Ceylon used to have!).

For Groovy, besides the built-in AST annotations like `@Immutable` and `@Canonical` (which turns a class into a data class, basically), you can achieve stuff like the Spock Testing Framework[3] which changes the Groovy syntax a little bit to make it really awesome for testing.

[0] https://www.baeldung.com/java-build-compiler-plugin

[1] https://groovy-lang.org/metaprogramming.html

[2] http://manifold.systems/

[3] https://spockframework.org/spock/docs/1.0/spock_primer.html

3 comments

Interesting! However I wonder if building Java plugins is harder. For example: JPA entities have for requirement to have a no-arg constructor. Both Java records and Kotlin data classes have not such a constructor by default. However kotlin has a no arg compiler plugin that autogenerate it for data classes (without any annotation) and Java Records don't have anything similar yet to my knowledge. (however they would still remain incompatible with jpa anyway because unfortunately they are immutable)
Manifold is very interesting. There is also a tail call recursion optimizer at the bytecode level https://github.com/Sipkab/jvm-tail-recursion

It would be nice to have a list of such extensions of the language/bytecode

> crazy stuff like type-safe reflection - like Ceylon used to have

I regret so much losing Ceylon :(