February 20, 2005

Puma C++ transformation library

Today I looked at Puma. Puma is a library for applying transformations to C++ programs. It can do C++ lexical analysis, parsing and semantic analysis. The library provides an API for examining and modifying C++ abstract syntax trees. To support program transformation, it also allows a modified syntax tree to be "unparsed" back into C++ source code, which can then be compiled using a C++ compiler.

It seems to be quite robust. For example, looking through some of the tests, I saw that it can parse templates and even template metaprograms. I was also pleased to see that it is used as the back-end of AspectC++, which is relatively mature aspect oriented programming system for C++.

I considered using AspectC++ instead of CDL. Aspect oriented programming has a lot of cross-over with metaprogramming. One thing it wouldn't let me do though is generate a schema from C++ class definitions. It provides no way of outputting anything other than C++ as far as I can tell. I'll take a closer look at it soon.

I am considering using Puma to parse CDL. If it works out, it will eliminate one of the big risks and most of the development effort for my C++ metaprogramming system. As with my C# and Java to C++ translators, I think the key to getting a prototype up and running quickly is to find a library that will do most of the parsing and analysis for me.

Puma is GPL. I am not sure if that would be a problem for a commercial project. The game would not be compiled with or link to any of the GPLed code. But some of it would be automatically generated by GPLed code. Is code that is generated by a GPL tool also GPL? I'll do some research.

I haven't had a chance to actually try it out yet. It took me all day to get it to compile in Visual C++. I had to upgrade from Visual C++ 7.0 to 8.0 beta. 7.0 was not sufficiently standards compliant. Then I had to wade through GCC makefiles and figure out how to set up a VC++ project with all the necessary preprocessor definitions. Grr, C++ makes things too difficult for a lazy programmer like me!

Comments:
I have been following your progress of trying to wrassle C++ into some sort of modern language. I tried for a very long time to find a reasonable solution that gave me what I wanted (introspection so I could bind my scripting language) without making my code scary, but in the end.. I just gave up. It just was not worth it for me to jump through all those hoops.

I hope you can find a good solution, but make sure you think long and hard about whether finding that solution is actually worth it.

btw. PUMA does look pretty cool.
 
Thanks for your feedback Billy. I'm not concerned about the effort involved in solving this problem. I love solving hard problems. My only goal is to learn new things. And I'm learning a whole bunch of new stuff with this project!

The way C++ is so entrenched in games development does frustrate me sometimes. I think there are two big obstacles slowing the adoption of other languages. The first is the lack of tools. If I want to program a console game in C#, I have to write my own compiler. The second is the performance-centric mindset of your typical game programmer. But that is beginning to change with the adoption of scripting languages and "higher level" languages for tools programming.

C++ isn't so bad though, especially if you are doing real OO, unit testing, refactoring, etc. Just look at all the awesome games that are written in C++. It can't be that bad!
 
"Lazy programmer"?! "Lazy" is the last word I'd associate with you! Keep up the thinking.

C
 
I'm pretty sure you're okay using GPL code to generate and manipulate code, provided the generated code doesn't link with a GPL library or runtime. gcc is GPL after all.
 
Yeah I think you're right Chad. It seems code compiled with GCC can be distributed for commercial purposes provided none of the code itself is GPL. For example, Sony's C++ compiler for PS2 is GCC. A lot of commercial games must be compiled with GCC. Good news!
 
good site
http://www.dating-online.co.in/
 
good site
manoj kumar
mahilange

ganiyari
bilaspur
http://www.accomodationsmotels.org/
 
good site
ghonghadih bilaspur
http://www.bestjewellerybox.org/
 
good site
ghonghadih bilaspur
http://www.bestjewellerybox.org/
 
good site
manoj kumar
mahilange
ganiyari
http://www.funboatshow.org/
 
good site

manoj kumar
mahilange
http://www.bitautoparts.org/
 
Hello.
You wrote that you compile Puma using Visual C++ and spend full day for it. Cold you share your VC solution with people who more lazzy and not ready repeat this heroic deed?
 
Pengertian Correct Score Sbobet atau Tebak Skor adalah salah satu jenis taruhan yang sangat menguntungkan selain mix parlay. Dikarenakan perkalian Odds / Hadiah Taruhannya yang sangat besar sehingga banyak menarik perhatian para pecandu Judi Bola. Tak hanya itu, dari sistem bermain pun sangatlah gampang karena pemain hanya perlu (Baca Selengkapnya Disini...)
 
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?