Thanks for your response. You're probably right, perhaps it's not the right tool. It was quite seductive to be able to code as easily as with C#/Java while having C performance/size. The project is about a kind of distributed UUID generator, available through different interfaces (socket, soap, rest...) , while being manageable through a web interface, users can define their own types/classes on-the-fly and link generated UUIDs to their objects so later they can pick up an UUID from, say, a database and find what kind of object it's related to, when it was created and so on. It can provide some tracability to a normally "dumb" identifier. As it has to be reliable/scalable/... it's probably a java-like job. I've investigated Java/C# previously for such a task and it's true it fits well, but i had a good feeling about Vala, so i thought "why not give it a try ?" :) Vala is perhaps, at least for now, more desktop-oriented. Anyway, it doesn't seems that the gmodule-2.0.vapi wraps any unload functionality, while GModule provides a GModuleUnload function. Is it not implemented or am i missing something (again) ?
Le 9 févr. 2010 à 21:57, Jan Hudec a écrit : > On Tue, Feb 09, 2010 at 15:36:56 +0100, jideel wrote: >> I'm wondering what would be the "right" way to generates code/classes at >> runtime, and reload it into the running program. > > Well, is Vala the right tool than? It's a completely static language which > needs to be compiled with C compiler and that linked and the C compiler and > linker are a pretty big beast. Something more dynamic would handle the job > easily. Either fully dynamic like python (or perl or ruby or lua or > javascript (using libseed)), that have no compilation at all, or partially > dynamic like CLR (Mono/.NET) or Java, which both carry their bytecode > compiler in the runtime. You can still use vala for the static part and > export necessary API to the dynamic part. > >> I thought to use the modules/plugin approach >> (http://live.gnome.org/Vala/TypeModules) the following way : >> - generate code than can be reloaded (plugin code, [ModuleInit]) using some >> kind of StringBuilder >> - flush it to a file > > I would not compose to StringBuilder (which is just string and will > reallocate all the time as you extend it), but write to a file directly. It > would be more efficient and you really get similar functionality. > >> - compile this file either by forking a valac compiler or perhaps using >> directly libvala (possible ?) > > Both are possible. Forking is probably easier, since while most of vala > compiler does live in libvala, the driver is not too trivial. Might depend on > the conditions. I found the code reasonably easy to follow, so just take > a look. > >> - reload the resulting plugin binary into the app > > It should work. You need to unload the old version, so you need to shut it > down and than reload. Mostly applies to CLR and Java too; fully dynamic > languages should be able to upgrade. > >> There's probably a better way to accomplish this kind of task. >> >> Any idea / suggestion ? > > It really depends on *why* you want to do it. > > -- > Jan 'Bulb' Hudec <[email protected]> _______________________________________________ Vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
