Home » Modeling » M2T (model-to-text transformation) » [JET] About the status of JET or JET2.
|
Re: [JET] About the status of JET or JET2. [message #61683 is a reply to message #61635] |
Mon, 25 May 2009 19:35 |
|
Xtext is not itself used for code generation, rather M2T Xpand is the
technology used for code generation in Xtext. And it does not produce
"code in one line", when you mean that it outputs just one line of code.
M2T Xpand is a highly comfortable templating technology.
Best,
~Karsten
On 25.05.09 19:08, Michael wrote:
> Hi,
> I am implementing a tool involving a code generator. I have come across
> a number of tools for code generation, such as Xtext, TCS and JET. I
> have spent
> much time on reviewing XText and TCS. I found XText just produces code
> in one line and TCS is not maitained at all. It seems both of them can
> not suit my use.
> I really have no time to review JET. If you can summarize the latest
> status of JET, especially its usability, you will be highly appreciated.
>
> Regards
> Michael.
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
Re: [JET] About the status of JET or JET2. [message #61727 is a reply to message #61635] |
Tue, 26 May 2009 07:15 |
Sven Efftinge Messages: 1823 Registered: July 2009 |
Senior Member |
|
|
Hi Michael,
the formatting of Xtext will be improved / fixed till the relase in
June. At that point it will be possible to specify pretty printing
information for your models.
But if you're really just looking for a solution to do code generation
this is the right newsgroup since all our code generation languages live
here.
We have three wonderful template languages:
- Jet2 (JSP-like, highly configurable, Xpath expressions, etc.)
- Acceleo (Implementation of Model 2 Text Spec from OMG)
- Xpand (statically typed, template language, supporting OCL-like
expressions with Java-like syntax)
So you have the choice, I guess all three work nice :-)
Cheers,
Sven
Michael schrieb:
> Hi,
> I am implementing a tool involving a code generator. I have come
> across a number of tools for code generation, such as Xtext, TCS and
> JET. I have spent
> much time on reviewing XText and TCS. I found XText just produces code
> in one line and TCS is not maitained at all. It seems both of them can
> not suit my use.
> I really have no time to review JET. If you can summarize the latest
> status of JET, especially its usability, you will be highly appreciated.
>
> Regards
> Michael.
|
|
|
Re: [JET] About the status of JET or JET2. [message #61774 is a reply to message #61727] |
Tue, 26 May 2009 12:05 |
Mikai Yang Messages: 149 Registered: July 2009 |
Senior Member |
|
|
Sven Efftinge wrote:
> Hi Michael,
>
> the formatting of Xtext will be improved / fixed till the relase in
> June. At that point it will be possible to specify pretty printing
> information for your models.
>
> But if you're really just looking for a solution to do code generation
> this is the right newsgroup since all our code generation languages live
> here.
> We have three wonderful template languages:
> - Jet2 (JSP-like, highly configurable, Xpath expressions, etc.)
> - Acceleo (Implementation of Model 2 Text Spec from OMG)
> - Xpand (statically typed, template language, supporting OCL-like
> expressions with Java-like syntax)
>
> So you have the choice, I guess all three work nice :-)
>
> Cheers,
> Sven
>
> Michael schrieb:
>> Hi,
>> I am implementing a tool involving a code generator. I have come
>> across a number of tools for code generation, such as Xtext, TCS and
>> JET. I have spent
>> much time on reviewing XText and TCS. I found XText just produces code
>> in one line and TCS is not maitained at all. It seems both of them
>> can not suit my use.
>> I really have no time to review JET. If you can summarize the latest
>> status of JET, especially its usability, you will be highly appreciated.
>>
>> Regards
>> Michael.
Hi Sven:
Thanks for your help. I surfed to the download page of M2T project to look for the build of Jet2, however I just found the
the one for Jet rather than Jet2. I am quite confused; What does Jet2 refer to: the second version of Jet? Has Jet2
already become stable now? What's the major difference between Jet and Jet2?
Thanks.
Regards.
Michael.
|
|
|
Re: [JET] About the status of JET or JET2. [message #61798 is a reply to message #61774] |
Tue, 26 May 2009 13:04 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Michael:
The JET version you get from the M2T download site is what is JET2. For
the record, JET1 would be the version of JET that is part of EMF (in the
org.eclipse.emf.codegen plug-in).
The main similarities and differences between JET1 and JET2
* both are based on JSP concepts. But, JET1 only allows use of scriptlets
(embedded Java statements) and expressions (embedded Java expressions),
while JET2 supports tag libraries as well.
* JET1 assumes you are going to write a Java program that will invoke your
templates and handle the template results. JET2 provides tag libraries
that allow you to write entire transformations without Java code and
without needing to be familiar with the Eclipse APIs.
* At the template interface level, JET1 and JET2 templates implement
different interfaces. For JET1, each compiled template implements a method:
String generate(Object argument)
For JET2, each compiled template implements a method:
void generate(JET2Context context, JET2Writer out)
(This only matters if you want to invoke templates from Java code. As I
said above, it is generally possible to avoid the writing of any Java code
when using JET2.
* JET2 allows you to navigate your model using XPath expressions. Although
XPath is typically used for XML documents, JET2 can handle other input
models, including anything based on EMF/ECore.
Hope this helps.
|
|
|
Re: [JET] About the status of JET or JET2. [message #61890 is a reply to message #61798] |
Wed, 27 May 2009 19:45 |
Mikai Yang Messages: 149 Registered: July 2009 |
Senior Member |
|
|
Hi Paul:
Your reply is extremely helpful. However I still have the following quesitons:
> * JET1 assumes you are going to write a Java program that will invoke
> your templates and handle the template results. JET2 provides tag
> libraries that allow you to write entire transformations without Java
> code and without needing to be familiar with the Eclipse APIs.
1) You meant that JET2 supports both Java scriplets and tag. Does this mean that tags and Java scripts can make apperance in the same JET2 template?
2) Do you have any example JET2 template including Java scriplets and tags simulataneously?
> * JET2 allows you to navigate your model using XPath expressions.
> Although XPath is typically used for XML documents, JET2 can handle
> other input models, including anything based on EMF/ECore.
3) What a pity! I failed to find examples about GET2 handling an EMF ecore model? Would you please provide one?
4) In fact, I would like to incorporate a code generator into a standalone ATL tranformation application. How can I do it with GET2-produced code generator? I prefer the code generator to
produce code directly from in-memory target models produced by atl transformations, rather than from serialized xmi files. So, is this possible
for JET2?
Thanks. So sorry for these silly questions.
Regards!
Michael.
Paul Elder wrote:
> Michael:
>
> The JET version you get from the M2T download site is what is JET2. For
> the record, JET1 would be the version of JET that is part of EMF (in the
> org.eclipse.emf.codegen plug-in).
>
> The main similarities and differences between JET1 and JET2
>
> * both are based on JSP concepts. But, JET1 only allows use of
> scriptlets (embedded Java statements) and expressions (embedded Java
> expressions), while JET2 supports tag libraries as well.
>
> * JET1 assumes you are going to write a Java program that will invoke
> your templates and handle the template results. JET2 provides tag
> libraries that allow you to write entire transformations without Java
> code and without needing to be familiar with the Eclipse APIs.
>
> * At the template interface level, JET1 and JET2 templates implement
> different interfaces. For JET1, each compiled template implements a method:
>
> String generate(Object argument)
>
> For JET2, each compiled template implements a method:
>
> void generate(JET2Context context, JET2Writer out)
>
> (This only matters if you want to invoke templates from Java code. As I
> said above, it is generally possible to avoid the writing of any Java
> code when using JET2.
>
> * JET2 allows you to navigate your model using XPath expressions.
> Although XPath is typically used for XML documents, JET2 can handle
> other input models, including anything based on EMF/ECore.
>
> Hope this helps.
>
|
|
| |
Re: [JET] About the status of JET or JET2. [message #61936 is a reply to message #61914] |
Thu, 28 May 2009 12:21 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Fabio:
Thanks for the example! Michael I hope that helps.
On a point if style, I prefer to write as little Java as possible in my
templates. Some reasons:
* Java code (and JET tags, for that matter) get in the way of seeing the
static part of the template - if you can't 'see' the structure of the
text you are generating, it is hard to justify using a template in the
first place.
* I have probably been too heavily influenced by JSP, where some
cultures feel it is bad practice to use Java code.
* I particularly don't like scriptlets that open a statement block that
is closed later...
<% for(...) { %>
... lots of template text ...
<% } %>
That looks nice a neat here, but when you have lots of text, and lots of
these blocks, it becomes hard to read (and get right). For an example of
this, take a look at the JET template that generates Java code from a
JET template:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/plugins/org.eclipse.jet/templates/v2/jet2java.j et?revision=1.9&root=Modeling_Project&view=markup
I wrote this, but I can barely read it. And I typically inject a Java
compile error every time I modify it. It's on my 'someday, I should
change this list'.
Here is some advice on making Java code in templates work better...
1) put large blocks of Java code into a utility class. Having:
<% MyUtil.somethingComplicated(...); %>
in a template is much more appealing than having the code inline. As an
added bonus, you get to use the Java editor to edit your Java code.
2) Consider whether you code could be moved to a custom JET tag or
custom XPath function.
3) Keep things short. Try not to do calculation in the template that is
producing content. (This applies JET tags as well as to Java code.)
Finally, the upcoming release of JET includes some improvements on the
'keep things short' front. Take a look at these 'What's New' items:
http://wiki.eclipse.org/M2T-JET/Whats_New_in_1.0_%28Galileo% 29#Compact_alternative_to_c:get_tag
http://wiki.eclipse.org/M2T-JET/Whats_New_in_1.0_%28Galileo% 29#JET_tags_can_now_change_the_XPath_context_object.2C_allow ing_for_shorter_expressions
Paul
|
|
|
Re: [JET] About the status of JET or JET2. [message #61956 is a reply to message #61890] |
Thu, 28 May 2009 12:42 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Michael wrote:
> 1) You meant that JET2 supports both Java scriplets and tag. Does this
> mean that tags and Java scripts can make apperance in the same JET2
> template?
Yes. Fabio gave an example in another reply.
> 2) Do you have any example JET2 template including Java scriplets and
> tags simulataneously?
Yes. Again, Fabio's response showed that.
>
> 3) What a pity! I failed to find examples about GET2 handling an EMF
> ecore model? Would you please provide one?
I don't think I have a public example right now. But here is a link to a
newsgroup post on how JETs XPath engine works with EObjects (and UML2
elements, which are EObjects)
http://dev.eclipse.org/newslists/news.eclipse.modeling.m2t/m sg01117.html
The bottom line is, it works quite nicely.
> 4) In fact, I would like to incorporate a code generator into a
> standalone ATL tranformation application. How can I do it with
> GET2-produced code generator? I prefer the code generator to
> produce code directly from in-memory target models produced by atl
> transformations, rather than from serialized xmi files. So, is this
> possible
> for JET2?
From a 'Run Configuration', JET expects to 'load' a model from disk.
How that is done is determined by a 'modelLoader'. In the case of an XMI
file generated by an EMF model, specify the 'org.eclipse.jet.emf' model
loader in your JET transforms plugin.xml. With that JET will do its best
to find the right EMF resource factory, and load the model as EObjects!
If you have an model in memory already, JET has an API:
JET2Plaform.runTransformOnObject("jet-plugin-id", rootOfYourModel,
[predefinedJETVariablesMap,] progressMonitor);
For behavior equivalent to what you see from the Run dialog, pass an EMF
Resouce object as 'rootOfYourModel'.
You mention 'stand-alone application'. JET2 requires Eclipse, but you
can run it headlessly (that is, without a UI). Ask if you want more details.
> Thanks. So sorry for these silly questions.
>
There are no silly questions :-)
Paul
|
|
|
Re: [JET] About the status of JET or JET2. [message #62029 is a reply to message #61956] |
Thu, 28 May 2009 17:34 |
Mikai Yang Messages: 149 Registered: July 2009 |
Senior Member |
|
|
Hi Paul:
Your reply in in great detail. Now I am so clear about my previuos questions. As for incorporating Jet2-produced generator in a standalone Java application, I think it is better for somebody to
list library required at least.
Thanks.
Michael
Paul Elder wrote:
> Michael wrote:
>> 1) You meant that JET2 supports both Java scriplets and tag. Does this
>> mean that tags and Java scripts can make apperance in the same JET2
>> template?
>
> Yes. Fabio gave an example in another reply.
>
>> 2) Do you have any example JET2 template including Java scriplets and
>> tags simulataneously?
>
> Yes. Again, Fabio's response showed that.
>
>>
>> 3) What a pity! I failed to find examples about GET2 handling an EMF
>> ecore model? Would you please provide one?
>
> I don't think I have a public example right now. But here is a link to a
> newsgroup post on how JETs XPath engine works with EObjects (and UML2
> elements, which are EObjects)
>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2t/m sg01117.html
>
> The bottom line is, it works quite nicely.
>
>> 4) In fact, I would like to incorporate a code generator into a
>> standalone ATL tranformation application. How can I do it with
>> GET2-produced code generator? I prefer the code generator to
>> produce code directly from in-memory target models produced by
>> atl transformations, rather than from serialized xmi files. So, is
>> this possible
>> for JET2?
>
> From a 'Run Configuration', JET expects to 'load' a model from disk.
> How that is done is determined by a 'modelLoader'. In the case of an XMI
> file generated by an EMF model, specify the 'org.eclipse.jet.emf' model
> loader in your JET transforms plugin.xml. With that JET will do its best
> to find the right EMF resource factory, and load the model as EObjects!
>
> If you have an model in memory already, JET has an API:
>
> JET2Plaform.runTransformOnObject("jet-plugin-id", rootOfYourModel,
> [predefinedJETVariablesMap,] progressMonitor);
>
> For behavior equivalent to what you see from the Run dialog, pass an EMF
> Resouce object as 'rootOfYourModel'.
>
> You mention 'stand-alone application'. JET2 requires Eclipse, but you
> can run it headlessly (that is, without a UI). Ask if you want more
> details.
>
>
>> Thanks. So sorry for these silly questions.
>>
>
> There are no silly questions :-)
>
> Paul
|
|
|
Re: [JET] About the status of JET or JET2. [message #62123 is a reply to message #61936] |
Fri, 29 May 2009 12:07 |
fabio boldrini Messages: 4 Registered: July 2009 |
Junior Member |
|
|
I agree.
I overused java in this case, and on debug it was painful.
Customtag scared me(i'm not a plugin/extension point master) but the
static method in a java class would have been i nice idea!
ps.the 1.0 features are very nice!
Paul Elder wrote:
> Fabio:
> Thanks for the example! Michael I hope that helps.
> On a point if style, I prefer to write as little Java as possible in my
> templates. Some reasons:
> * Java code (and JET tags, for that matter) get in the way of seeing the
> static part of the template - if you can't 'see' the structure of the
> text you are generating, it is hard to justify using a template in the
> first place.
> * I have probably been too heavily influenced by JSP, where some
> cultures feel it is bad practice to use Java code.
> * I particularly don't like scriptlets that open a statement block that
> is closed later...
> <% for(...) { %>
> ... lots of template text ...
> <% } %>
> That looks nice a neat here, but when you have lots of text, and lots of
> these blocks, it becomes hard to read (and get right). For an example of
> this, take a look at the JET template that generates Java code from a
> JET template:
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/plugins/org.eclipse.jet/templates/v2/jet2java.j et?revision=1.9&root=Modeling_Project&view=markup
> I wrote this, but I can barely read it. And I typically inject a Java
> compile error every time I modify it. It's on my 'someday, I should
> change this list'.
> Here is some advice on making Java code in templates work better...
> 1) put large blocks of Java code into a utility class. Having:
> <% MyUtil.somethingComplicated(...); %>
> in a template is much more appealing than having the code inline. As an
> added bonus, you get to use the Java editor to edit your Java code.
> 2) Consider whether you code could be moved to a custom JET tag or
> custom XPath function.
> 3) Keep things short. Try not to do calculation in the template that is
> producing content. (This applies JET tags as well as to Java code.)
> Finally, the upcoming release of JET includes some improvements on the
> 'keep things short' front. Take a look at these 'What's New' items:
>
http://wiki.eclipse.org/M2T-JET/Whats_New_in_1.0_%28Galileo% 29#Compact_alternative_to_c:get_tag
>
http://wiki.eclipse.org/M2T-JET/Whats_New_in_1.0_%28Galileo% 29#JET_tags_can_now_change_the_XPath_context_object.2C_allow ing_for_shorter_expressions
> Paul
|
|
|
Goto Forum:
Current Time: Tue Sep 24 19:01:27 GMT 2024
Powered by FUDForum. Page generated in 0.04404 seconds
|