building and calling "dynamic c++" from a host program
Hello I have the following question: If you want to make a program that will let the user write "scripts" directly in c++, how will you do it? I am strugling my mind these days looking for a solution to this problem and I want to know if boost already address this situation. My intuition tells me that the process will probably consist on invoking bjam to build a dynamic lib with the "script" and then call the built code in the host binary. But how can this be done keeping it portable and clean? Obviously it won't work if you don't have a build environment configured but anyway it may be a very interesting feature. Regards, Isaac Lascasas.
On Sun, Aug 17, 2008 at 06:27:35PM +0200, Isaac Lascasas wrote:
If you want to make a program that will let the user write "scripts" directly in c++, how will you do it? I am strugling my mind these days looking for a solution to this problem and I want to know if boost already address this situation. My intuition tells me that the process will probably consist on invoking bjam to build a dynamic lib with the "script" and then call the built code in the host binary. But how can this be done keeping it portable and clean? Obviously it won't work if you don't have a build environment configured but anyway it may be a very interesting feature.
There are some C++ interpreters, for example: Ch: http://www.softintegration.com/ CINT: http://root.cern.ch/twiki/bin/view/ROOT/CINT That is, if you really want _scripts_, i.e., instantaneous interpretation like. If you're looking for precompiled plugins, you don't have to look further than DLLs.
Thanks for your proposal, I have not yet tested any c++ interpreter and I
don't know how fast these tools can execute the client code. It can be a
good alternative but I think it should exist a better alternative for
certain situations.
I'm more interested in fast execution of the embedded code than in instant
interpretation so the build time is not a problem. My objective is to write
a fast real time graphic effects prototyping tool and let the user
eventually write chunks of code in c++, for example to process a list of
thousands of items for a particle system as fast as if I rebuild the whole
thing with the new user code. In other words, the main problem I have is
that time-critical code can be placed inside this dynamic c++.
Regards,
Isaac Lascasas.
--------------------------------------------------
From: "Zeljko Vrba"
On Sun, Aug 17, 2008 at 06:27:35PM +0200, Isaac Lascasas wrote:
If you want to make a program that will let the user write "scripts" directly in c++, how will you do it? I am strugling my mind these days looking for a solution to this problem and I want to know if boost already address this situation. My intuition tells me that the process will probably consist on invoking bjam to build a dynamic lib with the "script" and then call the built code in the host binary. But how can this be done keeping it portable and clean? Obviously it won't work if you don't have a build environment configured but anyway it may be a very interesting feature.
There are some C++ interpreters, for example:
Ch: http://www.softintegration.com/ CINT: http://root.cern.ch/twiki/bin/view/ROOT/CINT
That is, if you really want _scripts_, i.e., instantaneous interpretation like. If you're looking for precompiled plugins, you don't have to look further than DLLs.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Then I think the only solution is that you allow compiled plugins .dll/.so in your project. And the "user" is a just developer that build the plugin and copy it in your application folder. -----Messaggio originale----- Da: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Per conto di Isaac Lascasas Inviato: domenica 17 agosto 2008 19.03 A: boost-users@lists.boost.org Oggetto: Re: [Boost-users] building and calling "dynamic c++" from ahostprogram Thanks for your proposal, I have not yet tested any c++ interpreter and I don't know how fast these tools can execute the client code. It can be a good alternative but I think it should exist a better alternative for certain situations. I'm more interested in fast execution of the embedded code than in instant interpretation so the build time is not a problem. My objective is to write a fast real time graphic effects prototyping tool and let the user eventually write chunks of code in c++, for example to process a list of thousands of items for a particle system as fast as if I rebuild the whole thing with the new user code. In other words, the main problem I have is that time-critical code can be placed inside this dynamic c++. Regards, Isaac Lascasas.
Isaac,
On Sun, Aug 17, 2008 at 9:27 AM, Isaac Lascasas
Hello I have the following question:
If you want to make a program that will let the user write "scripts" directly in c++, how will you do it? I am strugling my mind these days looking for a solution to this problem and I want to know if boost already address this situation. My intuition tells me that the process will probably consist on invoking bjam to build a dynamic lib with the "script" and then call the built code in the host binary. But how can this be done keeping it portable and clean? Obviously it won't work if you don't have a build environment configured but anyway it may be a very interesting feature.
Regards,
Isaac Lascasas.
That kind of depends on what exactly you want. I put an example in Boost.Extension that automatically compiles arbitrary code (using Boost.Build - but you could modify it for other compilers) into a shared library and then loads and runs it: http://svn.boost.org/trac/boost/browser/sandbox/libs/extension/examples/runt... I haven't gotten around to writing documentation for the example, but plan to do it in the next few weeks. The code is relatively straightforward though. As far as a full scripting environment for C++, there are full libraries that do this - but you'd have a tough time persuading me that Python or another actual scripting language (perhaps with Boost.Python) wasn't a better solution. I guess if all you have is a hammer... Jeremy Pack http://boost-extension.blogspot.com
As far as a full scripting environment for C++, there are full libraries that do this - but you'd have a tough time persuading me that Python or another actual scripting language (perhaps with Boost.Python) wasn't a better solution. I guess if all you have is a hammer...
I don't have any idea what these things do but the problem I often run into is reasonable time performance, usually due to memory access patterns when I exceed physical memory limits. PERL is great if bash doesn't work but sometimes both can get very slow. ( I have found various tricks, such as an "irrelevant" call to bash sort prior to doing anything as this can prevent thrashing later but IIRC ) I usually just end up taking a single include file for my homebrew command line interface and write a one page c++ program that is usually just an STL container or a special relative ( something that knows my memory access patterns and only supports a subset of, say, vector ) and some specialized processing ( sometimes odd floating point or string processing) that is probably hard to generalize for a compiled, non-general purpose language.
Jeremy Pack http://boost-extension.blogspot.com
_________________________________________________________________ Get ideas on sharing photos from people like you. Find new ways to share. http://www.windowslive.com/explore/photogallery/posts?ocid=TXT_TAGLM_WL_Phot...
That was exactly what I was looking for. I am again surprised that my needs are <again> already covered by boost in some way.
Thank you,
Isaac Lascasas.
From: Jeremy Pack
Sent: Sunday, August 17, 2008 7:03 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] building and calling "dynamic c++" from a hostprogram
Isaac,
On Sun, Aug 17, 2008 at 9:27 AM, Isaac Lascasas
participants (5)
-
Andrea Denzler
-
Isaac Lascasas
-
Jeremy Pack
-
Mike Marchywka
-
Zeljko Vrba