You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "alessandro rossi (JIRA)" <ji...@apache.org> on 2011/05/18 13:43:47 UTC

[jira] [Created] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Using template system (for example: ctemplate) for code generation
------------------------------------------------------------------

                 Key: THRIFT-1173
                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (General)
    Affects Versions: 0.6.1
            Reporter: alessandro rossi
            Priority: Minor


IMHO, the code generation embedded into generator's code is not a good solution.
With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
If you want I can implement an example for cpp generator.
Best Regards,
Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "Roger Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13052737#comment-13052737 ] 

Roger Meier commented on THRIFT-1173:
-------------------------------------

Hi Alessandro! Sorry for the delay....

I'm not familiar with LUA, however being a committer at Thrift extends my knowledge on multiple languages from day to day;-)

I think a replacement of the Thrift Compiler with a template based approach is a huge effort and a such generator that supportes languages has the be heavily tested....

As mentioned, I really see a potential for that approach for the following use cases:
* testing purposes
* prototype new languages
* generate custom documentation
* generate proprietary code.

Thanks
-Roger

> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "Roger Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13036733#comment-13036733 ] 

Roger Meier commented on THRIFT-1173:
-------------------------------------

I use ctemplate on several applications, it's a great piece of software.

However migrating the Thrift compiler to a template based concept sounds like lot of work and adds additional dependencies to the Thrift compiler. And this will make it more difficult to cross compile the compiler for Windows.

On the other side a template based mechanism would be a great option to test or prototype new adoptions of languages or to create other things like custom documentation or proprietary code ready to use.

Do you already have a prototype?

> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "alessandro rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13036745#comment-13036745 ] 

alessandro rossi commented on THRIFT-1173:
------------------------------------------

No, I've not a prototype, but I can try to develop it for a language (cpp or python), so you could compare it with existing version.


> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "alessandro rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13043291#comment-13043291 ] 

alessandro rossi commented on THRIFT-1173:
------------------------------------------

I forgot to mention that cpptempl seems to be a LL(1) grammar. So extend it with others costructs is very difficult!!

> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "alessandro rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13043246#comment-13043246 ] 

alessandro rossi commented on THRIFT-1173:
------------------------------------------

an update:
-I used ctemplate, but this template engine is very poor (no "for"/"if")
-I switched to (modificated) cpptempl (https://bitbucket.org/ginstrom/cpptemplate/overview).
 PRO:
 -for / if
 -easy parameter passing
 -only two file (cpptempl.cpp,cpptempl.h)
 -MIT license (is really good?)
 CONS:
 -no else/elif
 -no include
-I'm investigating in order to use flex/bison (I used them about 15 years ago :P ) for a new simple-but-powerful template engine without lib dependancies (thrift already use flex/bison for its grammar).
the new template engine MUST have:
-for/if/else/elif/switch-case
-function
-include

PS: I'm working to python generator using cpptempl and the code lines now are 2240 (original 2390). It's heavy to pass for embedded-code to template-code.


> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1173) Using template system (for example: ctemplate) for code generation

Posted by "alessandro rossi (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044768#comment-13044768 ] 

alessandro rossi commented on THRIFT-1173:
------------------------------------------

another update:
I dusted off the Dragon Book (Compilers: Principles, Techniques, and Tools [Aho,Sethi,Ullman]) but this approch is more complicated, because i WANT a powerful scripting languages. So, follow the KISS principle, I'm developing a template engine using LUA embedded in C/C++. Lua (that I used in other projects) have small footprint, is ANSI C  and is more powerfull than my (future?) template language/engine.
What do you think about my choise? 


 

> Using template system (for example: ctemplate) for code generation
> ------------------------------------------------------------------
>
>                 Key: THRIFT-1173
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1173
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (General)
>    Affects Versions: 0.6.1
>            Reporter: alessandro rossi
>            Priority: Minor
>              Labels: generation, template
>
> IMHO, the code generation embedded into generator's code is not a good solution.
> With ctemplate (http://code.google.com/p/google-ctemplate/), for example, we can separate logic with generation code.
> If you want I can implement an example for cpp generator.
> Best Regards,
> Alessandro

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira