tag:blogger.com,1999:blog-90612693515422416992023-11-15T07:31:31.073-08:00SoC Boost.Extension and Reflection ProposalMariano Consonihttp://www.blogger.com/profile/16075348814059969654noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-9061269351542241699.post-68469361573396593442007-03-22T10:55:00.000-07:002007-03-22T11:38:42.862-07:00My Boost SoC Proposal<pre style="font-family: arial;" face="arial">My name is Mariano Consoni. I'm an undergraduate student at<br />Buenos Aires University, planning to obtain a Computer Science<br />degree in the next few years. Here is my proposal for a plugin/extensions<br />library with reflection functionality.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Abstract</span><br /><br />The project that I propose is centered in adding to Boost a library<br />that allows the programmer to include extensions/plugins.<br />Additionally this will be the start point to implement reflection<br />concepts.<br /><br />My proposal has two parts:<br /><br /></pre><ul style="font-family: arial; text-align: left;"><li>Bring Boost.Extensions [1] to completion and enhance it.<br /></li></ul><pre style="font-family: arial;" face="arial">As I will say in the next sections, I wanted to add to Boost a library<br />that allows an application to have dynamic plugins/extensions<br />within an infrastructure.<br /><br />A member of the Boost mailing list told me about a library by Jeremy<br />Pack called Extension. Jeremy and I agreed that the best approach<br />would be to complete and enhance this library. In short, the<br />completion consists in preparing the library to be sent for review in<br />Boost. The enhancements are several, and will be described later.<br /><br /></pre><ul style="font-family: arial; text-align: left;"><li>Implement Reflection [2] using Extensions functionality</li></ul><pre style="font-family:arial;">The Extensions functionality is the perfect platform to<br />implement Reflection in C++. I've analyzed several<br />papers about this topic and having Extensions complete<br />will be great to start building this new features. Also,<br />the Boost Community showed a great interest saying that<br />it would be a great addition to Boost. Discussing Reflection<br />with Jeremy we agreed that it could be very useful to<br />use the dynamic (run-time) method loading features in<br />Extensions to give reflection functionality to normal<br />C++ classes. I'll detail this point later.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Proposal history</span><br /><br />Last year, I've been working in a GIS project. It needed<br />a very open architecture, and our decision was<br />to implement some kind of software plugin infrastructure.<br />This project was being written in C++ and with a<br />very intensive use of Boost. At that point, I checked out<br />if Boost had a Plugin Library.... without results.<br /><br />So I designed and implemented an original infrastructure.<br />It was useful and I've learnt a lot during the development.<br />Also I've noted its pros/cons.<br /><br />Since that time, I have been thinking about adding an<br />Extensions library to Boost, because I really like<br />Boost philosophy, and I use it very frequently (nowadays<br />I'm using it in at least three C++ projects,<br />and advocating its use to my colleagues).<br /><br />Luckily, Summer of Code 2007 was about to start. Then I<br />tried to get in touch with the boost community. Since<br />early March I've been discussing my ideas in the lists with<br />positive feedback. They showed a lot of interest<br />and, as I said before, quickly pointed me out that there<br />was some work done in that area. With more luck,<br />Jeremy contacted me very quickly.<br /><br />We started to work together that week. I started to review<br />his approach and he checked some of my old code. Obviously,<br />his approach is simpler, more concrete and really clean.<br />He told me that my code was very clear too, comparing it with<br />another libraries.<br /><br />Then, we started to set the concrete goals for the project.<br />The result of that work is this proposal.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Detailed objectives</span><br /><br />Objectives could be split in two parts. My first goal is to<br />bring to completion Boost.Extensions and then explore Reflection<br />functionalities.<br /><br />Some of the improvements that are needed to complete<br />Boost.Extensions (in order to submit it for revision) were<br />addressed in our work with Jeremy. I think that some more will<br />appear when we start the work.<br /><br />Then the actual tasks of this part are:<br /><br /></pre><ul style="font-family: arial; text-align: left;"><li>1.1. Preprocessor techniques to remove template redundancy. Nowadays some parts of the library are duplicated because the use of variable-arguments templates. The idea is to use the preprocessor library to avoid this. I've done it in another project, so I think that it'll be easy (but costly).</li></ul><ul style="font-family: arial; text-align: left;"><li>1.2. Provide (optionally) automatic closing of unneeded linked libraries. We think that this feature is important for many people to justify adding it in the standard library. Also, it can be added with "convenience" functions quite smoothly - just as smoothly as directly adding the functionality.<br /></li></ul><ul style="font-family: arial; text-align: left;"><li>1.3. Various integrations with other Boost libraries for convenience (like boost::function).</li></ul><ul style="font-family: arial; text-align: left;"><li>1.4. Finish up documentation.</li></ul><ul style="font-family: arial; text-align: left;"><li>1.5. Write lots of more unit tests, as well as larger tests.</li></ul><ul style="font-family: arial; text-align: left;"><li>1.6. Submit to Boost for review.</li></ul><pre style="font-family: arial;">Having that complete, I'll focus on the Reflection part. My main idea is<br />allow the C++ programmer to access a meta-level infrastructure where<br />he/she can load new classes/methods at run-time and get<br />information about them.<br /><br />For that purpose I need to define an API that allows exporting methods<br />and then the infrastructure to load them on demand. The difference with<br />the Extensions approach is that in this part this methods<br />won't be a virtual function declared in a base class. I mean, you should<br />export the methods that could be used to access this meta-level and<br />then Extensions will have the responsibility of loading the<br />necessary dynamic shared objects. Additionally, this will allow creating<br />objects that aren't derived of any class of the executable; instead they<br />are loaded on demand from a linked library.<br /><br />A possible use of this API could be, for example, the development of a<br />C++ "interpreter".<br /><br />Another interesting line of work could be having the ability to compile code<br />at runtime and use it ( i.e. compile it into a linked library and link to it at<br />runtime). If bjam was required to be in the path, and BOOST_BUILD_PATH<br />was all set up, this just might work well.<br /><br />I know that this objectives are big but really interesting. I'll detail in the<br />schedule and deliverables section what I want to achieve for sure, and<br />what could be developed if the time allows me.<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Deliverables</span><br /><br />In the first part of the project, I mean the Extensions completion, the deliverables<br />are really concrete. After each step of the development (1 - 6) a new version<br />of the library will be released with the corresponding changes.<br /><br />In the second part, the deliverables will be versions of this new Reflection<br />library. Mainly, the great deliverable will the library with the feature of allowing<br />the programmer to load classes/methods at run-time, on demand as it was<br />detailed in the previous section. It would be great if I can develop<br />some of the functionalities of on-demand compiling, but I can't guarantee<br />now (without having a deep knowledge in the subject).<br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Schedule</span><br /><br /><span style="font-weight: bold; font-style: italic;"> Weeks in the interim period between being accepted as student and<br />program start</span><br /><br />Try to get more and more feedback from the community and try to detail the<br />plan with Jeremy and my mentor. Maybe some prototype could be done<br />if I have spare time.<br /><br /><span style="font-weight: bold; font-style: italic;">Week 1</span><br /><br />Do a careful study of Boost.Extensions. I've checked it out, but I need a deep<br />understanding before starting. Get in touch with my mentor (as with Jeremy I'm<br />in touch nowadays). See carefully the requirements to review the library.<br /><br /><span style="font-weight: bold; font-style: italic;">Weeks 2 - 4</span><br /><br />First tasks, 1.1 to 1.3, and task 1.5.Initial unit tests will be written.<br /><br /><span style="font-weight: bold; font-style: italic;">Weeks 5 - 6</span><br /><br />Finish the first part (tasks 1.4 to 1.6), submitting the library to boost for revision.<br /><br /><span style="font-weight: bold; font-style: italic;">Weeks 7 - 8</span><br /><br />Explore reflection and do the first prototypes of the functionalities. Make<br />some units tests along the development.<br /><br /><span style="font-weight: bold; font-style: italic;">Weeks 9 - 10</span><br /><br />Go on with reflection, trying to fit it as a working and useful library.<br /><br /><span style="font-weight: bold; font-style: italic;">Weeks 11 - 12</span><br /><br />Fix bugs. Document. Make more unit tests. According to the remaining time add some<br />functionalities of the other optional tasks. Plan the future after-program work.<br /><br /><br /><br /><span style="font-weight: bold;font-size:130%;" >Why is this library needed?</span><br /><br />First, I think that this library is very useful for a very personal reason: if<br />it existed before I would used it in my GIS project :).<br /><br />Besides that, the community showed a lot of interest in the list [3].<br />Moreover there is at least one individual (Vladimir Volodko) that wants<br />to help to develop some peripheral parts of the library.<br /><br />The Reflection part also seems to be very interesting for the<br />community, and as far as we know there are a lot of functionalities<br />that could be built on top of the Reflection platform. Also, I think<br />that it could be the start point for Reflection functionality in Boost.<br /><br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">About me</span></span><br /><br />My favorite language is C++. I love Boost philosophy, and since I've known<br />it I used it in a lot of projects including a large GIS project (we used smart<br />pointers, Spirit parser, StateChart, Threads, Filesystem, and many others),<br />a transit engineering project and some more. I've been advocating its use<br />in the development teams where I've participated with great results.<br /><br />Besides that I like a lot functional languages (Haskell mainly) and Python.<br />When I knew Boost.Lambda it was a nice surprise.<br /><br />I have strong experience with open source software (I installed my first Linux in<br />1998) and open source development. I've worked in at least 3 projects using<br />open source technologies, besides the work that I've done as part of university<br />courses. I'm familiarized with the interaction in a development community as I've been<br />part of LUGAr (an Argentinian Linux User Group), and of course many other<br />(distributed) development projects.<br /><br />I've been studying Computer Science at Buenos Aires University<br />for some years. Here the career is long, six years at least, but when you finish you get<br />a degree comparable to a Msc.<br /><br />In academic terms, my interests are related to static analysis. I've made some<br />work about Barvinok methods, Bernstein basis and Ehrhart polynomials to evaluate<br />some properties of source code without executing it.<br /><br />I think that my strong interest in Boost mixed with my interest in static<br />analysis is a great mix for developing this project, and mainly the reflection<br />part. So, I think that maybe I am not the *best* individual to do this (that's<br />a very very strong assertion.. :) ), but I think that I'm very good because of<br />my experience with C++ (3+ years C++/Boost, and 6+ years with C) and my<br />past experience in different projects. Additionally, I could promise that I'll work<br />hard and do my best.<br /><br />Apart from that, I think that building free software is really nice. I've been for<br />a long time a Boost User, and now I want to collaborate and have my own<br />library/project. I think that the GSoC idea is perfect, and it'll be great if I can<br />develop this library and then be part of the community as co-author of the<br />library and continue participating in the Boost.Reflection development.<br /><br /><span style="font-weight: bold;font-size:130%;" ><br />References</span><br /><br />[1] Boost.Extension: http://sourceforge.net/projects/boost-extension/<br /><br />[2] Some reflection ideas: http://www.vollmann.com/pubs/meta/meta/meta.html<br /><br />[3] Boost mailing list<br />. http://article.gmane.org/gmane.comp.lib.boost.devel/155445<br />. http://archives.free.net.ph/thread/20070314.225134.19510931.en.html<br /><br /><br /><span style="font-size:130%;"><span style="font-weight: bold;">Other implementations and ideas about plugins or<br />reflection in C++</span></span><br /><br /></pre><ul style="font-family: arial; text-align: left;"><li>http://yallara.cs.rmit.edu.au/~aholkner/dynload/index.html</li></ul><pre style="font-family: arial;"> Plugin framework for C++, multiplatform.<br /></pre><ul style="font-family: arial; text-align: left;"><li>http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?Boost.Plugin</li></ul><pre style="font-family: arial;"> Boost.Plugin idea.<br /></pre><ul style="font-family: arial; text-align: left;"><li>http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2074.pdf</li></ul><pre style="font-family: arial;"> A paper about concepts of Plugins in C++.<br /></pre><ul style="font-family: arial; text-align: left;"><li>http://svn.berlios.de/viewcvs/yade/trunk/yade-libs/yade-lib-factory</li></ul><div style="text-align: left;"> /src/yade-lib-factory/?rev=HEAD</div><pre style="font-family: arial;"> A dynamic library loader.<br /></pre><ul style="font-family: arial; text-align: left;"><li>http://s11n.net/download/#class_loader</li></ul><pre style="font-family: arial;"> A framework for dynamic class loading.<br /></pre>Mariano Consonihttp://www.blogger.com/profile/16075348814059969654noreply@blogger.com0