julienledem / brennus

Builder pattern to generate java classes
Apache License 2.0
17 stars 2 forks source link

Collaborate with linq4j? #1

Open julianhyde opened 12 years ago

julianhyde commented 12 years ago

My projects linq4j and optiq need to generate and execute Java, so I created some code similar to brennus. See the net.hydromatic.linq4j.expressions package:

https://github.com/julianhyde/linq4j/tree/master/src/main/java/net/hydromatic/linq4j/expressions

There are some differences; I use janino to compile, where brennus uses asm directly. I suspect that I need to generate more complex expressions (anonymous and inner classes, and soon lambdas). As far as i can tell, brennus can't "unparse" (generate java source code from a model). But of course brennus has nice builder classes.

Janino is a mixed blessing for me. It is mature and the bugs have all been worked out, for what it does. But it does not support newer features like generics, boxing/unboxing, and suspect it will not support lambdas.

What are your plans for brennus? Do you think it would be useful to pool our resources? What is your preferred communication channel?

Julian

julienledem commented 12 years ago

Hi Julian, I would be happy to collaborate. Brennus is designed to make it easy to generate domain specific data objects at runtime, as well as related operations (equals, expressions, etc). I'd like to use it in Pig for example. The brennus model is higher level than bytecode so that it can take care of autoboxing and similar things (in bytecode instructions vary depending on the type handled). At the same time it is not a full representation of the java language syntax tree which would be huge and would make the builder too verbose. Which means you can't turn java bytecode into the brennus model. The builder makes it easy to generate the model. Then the model can be used to generate bytecode or source or something else by implementing a visitor. Currently there is a bytecode generator that creates classes using ASM and a printer that generates something very close to java source code with some caveats (not dealing with unreachable code ...) The current builder pattern API is now stable, which was my priority. All the operators are not yet supported but it just a matter of adding them, the general framework being defined.

For new features in Brennus, issues on Github are good. For a more informal chat I'd be happy to meet in person.

julianhyde commented 12 years ago

Can you take a look at the net.hydromatic.linq4j.expressions package? Would you be willing to include all of that functionality? It has a model for most of the Java language syntax (and it really isn't that huge).

I can see that you wouldn't want to commit to supporting the whole model in the builder. I think it would be acceptable if the builder supported less than the full model, and was extended as needed.