This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodeGen API Simplification #34
Comments
Hi @sirinath , thanks for your suggestion! The main concept behind code generation is implementing an interface that will be used by calling its methods. And ActiveCodegen perfectly supports this use case. The methods that are generated by ActiveCodegen can be called from a Java class only if the implemented interface declares this method. Thus, you don’t need to generate getter and setter methods. As for the builder pattern for creating methods and fields, ActiveCodegen has a very flexible and universal DSL that allows for generating any methods and fields with the help of AST expressions composition. |
I think you can make reflection-based calls, The AST scheme is difficult to use. If the building is more close to Java code it would be better. E.g. JavaPoet. |
The higher-level API can generate and return the AST representation. |
The primary goal of ActiveCodegen is to dynamically construct, generate and manipulate generated code directly in runtime, with respect to runtime parameters. The methods are not just static plaintext code (which could have been written as regular Java code without any code generators at all). That's why AST DSL is an optimal solution for that. In this way, you don’t need to use any additional template engines to generate dynamic plaintext. |
I am not looking to generate any plain text but directly working with the AST is not easy other than for trivial use cases. So that is why I am asking for a helper API which is more high level and easier to use. |
Hello, @sirinath |
Since this is on top of ASM can ActiveCodegen be enhanced to utilise all of ASM capabilities.
This is what I am after also. I feel maybe the API surface and be reduced and simplifies retaining the current functionality. Also add more API to expose more functionality, but what is added should be simple and focused. If the the API functionality follows most generalised Java constructs then the API will become minimal and simple. |
Here we have provided some of the goals and design decisions behind ActiveCodegen. It is a tool for dynamic class generation based on runtime parameters and information available in runtime. It supports code generation using functional composition of LISP-like expressions and ASTs. The current API is completely suitable for this task. |
Since LISP like expressions and ASTs is supported. Perhaps some additional abilities which might prove to be useful:
|
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I believe the codegen API can be simplified. E.g.
can become
or
as
Person
defines the arguments and types this is implied.Similarly
can become
Also,
can become
or
as
Person
defines the argumentsetc.
Basically,
The text was updated successfully, but these errors were encountered: