473,405 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

On-the-fly compilation and execution of C++ program

Hi,
we are designing some stuff , that will generate c++ program(s)
What we want is we wanted to execute that generated code....

i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.

What we have got stucked at compilation, we want that our user should
not take care about compilation or c++ code generation etc...They just
write some xml "code" and it should execute !

[we are developing something like Event processor, reactor system etc]
-Raxit

Jun 27 '08 #1
16 4214
Ra***@MyKavita.com wrote:
Hi,
we are designing some stuff , that will generate c++ program(s)
What we want is we wanted to execute that generated code....

i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.

What we have got stucked at compilation, we want that our user should
not take care about compilation or c++ code generation etc...They just
write some xml "code" and it should execute !
[snip]

Well, what about using a compiler? If you don't want to write your own,
which would take a while, you could contact a compiler vendor for the
target platform and obtain a license to include a compiler into your
package and call it from a script or something. Other than that, you could
document the need for a C++ compiler and test for it during installation of
your program.
Best

Kai-Uwe Bux
Jun 27 '08 #2
On 31 mayo, 22:51, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Ra...@MyKavita.com wrote:
Hi,
we are designing some stuff , that will generate c++ program(s)
What we want is we wanted to execute that generated code....
i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.
What we have got stucked at compilation, we want that our user should
not take care about compilation or c++ code generation etc...They just
write some xml "code" and it should execute !

[snip]

Well, what about using a compiler? If you don't want to write your own,
which would take a while, you could contact a compiler vendor for the
target platform and obtain a license to include a compiler into your
package and call it from a script or something. Other than that, you could
document the need for a C++ compiler and test for it during installation of
your program.

Best

Kai-Uwe Bux
Well, I suppose that you have study .net alternative. If not, .net has
libraries to compile a code into common language code (something like
java bytecode, but in an exe or dll form), and to do a c++/c# parser
and compiler is pretty easy.
In a project I used c# as script language, which was compiled and
executed in runtime.

I hope that this help you.
Jun 27 '08 #3
On May 31, 10:51 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Ra...@MyKavita.com wrote:
we are designing some stuff , that will generate c++
program(s) What we want is we wanted to execute that
generated code....
i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.
What we have got stucked at compilation, we want that our
user should not take care about compilation or c++ code
generation etc...They just write some xml "code" and it
should execute !
[snip]
Well, what about using a compiler? If you don't want to write
your own, which would take a while, you could contact a
compiler vendor for the target platform and obtain a license
to include a compiler into your package and call it from a
script or something. Other than that, you could document the
need for a C++ compiler and test for it during installation of
your program.
The real question is why they would insist on C++ for step 2.
It seems highly unlikely that machine generated code from user
written XML would require all of the power of C++. Unless they
really needed the speed of an optimized compilation, I'd
probably just "invent" some sort of internal language that was
1) easy to generate from XML, 2) easy to parse, and 3) easy to
interpret effectively. (Said language might not even support
text as a source format.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #4
On Jun 1, 5:05 am, James Kanze <james.ka...@gmail.comwrote:
On May 31, 10:51 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Ra...@MyKavita.com wrote:
we are designing some stuff , that will generate c++
program(s) What we want is we wanted to execute that
generated code....
i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.
What we have got stucked at compilation, we want that our
user should not take care about compilation or c++ code
generation etc...They just write some xml "code" and it
should execute !
[snip]
Well, what about using a compiler? If you don't want to write
your own, which would take a while, you could contact a
compiler vendor for the target platform and obtain a license
to include a compiler into your package and call it from a
script or something. Other than that, you could document the
need for a C++ compiler and test for it during installation of
your program.

The real question is why they would insist on C++ for step 2.
James, This is interesting point, we are at very early stage, and for
step 1 & 2, there is Boost library available (we know still it is not
very much straight forward job and it may require some dirty hacks, we
think it will be more easy.)
It seems highly unlikely that machine generated code from user
written XML would require all of the power of C++. Unless they
no, we may not require all the power of c++, you can say like XML is
like domain specific language that our developer want to execute, but C
++ code will be generated in middle, and finally bytecode/machinecode/
ELF32 etc...
really needed the speed of an optimized compilation, I'd
probably just "invent" some sort of internal language that was
1) easy to generate from XML, 2) easy to parse, and 3) easy to
interpret effectively. (Said language might not even support
text as a source format.)
We do think instead of generating new languages for optimized
compilation, its good idea not to re-invent wheel.(we may be wrong and
we are very early stage of poc, we may do something very much
diffenetly.)
>
--
James Kanze (GABI Software) email:james.ka...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
-Raxit Sheth
Jun 27 '08 #5

"Ra***@MyKavita.com" <ra************@gmail.comwrote in message
news:20**********************************@p25g2000 pri.googlegroups.com...
On Jun 1, 5:05 am, James Kanze <james.ka...@gmail.comwrote:
On May 31, 10:51 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Ra...@MyKavita.com wrote:
we are designing some stuff , that will generate c++
program(s) What we want is we wanted to execute that
generated code....
i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.
What we have got stucked at compilation, we want that our
user should not take care about compilation or c++ code
generation etc...They just write some xml "code" and it
should execute !
IMO I wouldnt worry about generating C++ code and use an intermediate
language :

JVM cross platform

http://en.wikipedia.org/wiki/Java_Virtual_Machine

For .Net (windows targets) use CLR :

http://en.wikipedia.org/wiki/Common_Language_Runtime

(See also LINQ which has AFAIK some nice XML facilities)
http://msdn.microsoft.com/en-gb/library/bb308960.aspx

Or LLVM cross platform

http://llvm.org/

regards
Andy Little

Jun 27 '08 #6
On Jun 1, 5:21 pm, "Ra...@MyKavita.com" <raxitsheth2...@gmail.com>
wrote:
On Jun 1, 5:05 am, James Kanze <james.ka...@gmail.comwrote:
On May 31, 10:51 pm, Kai-Uwe Bux <jkherci...@gmx.netwrote:
Ra...@MyKavita.com wrote:
we are designing some stuff , that will generate c++
program(s) What we want is we wanted to execute that
generated code....
i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
3. compilation
4. execution.
What we have got stucked at compilation, we want that our
user should not take care about compilation or c++ code
generation etc...They just write some xml "code" and it
should execute !
[snip]
Well, what about using a compiler? If you don't want to write
your own, which would take a while, you could contact a
compiler vendor for the target platform and obtain a license
to include a compiler into your package and call it from a
script or something. Other than that, you could document the
need for a C++ compiler and test for it during installation of
your program.
The real question is why they would insist on C++ for step 2.
James, This is interesting point, we are at very early stage,
and for step 1 & 2, there is Boost library available (we know
still it is not very much straight forward job and it may
require some dirty hacks, we think it will be more easy.)It
seems highly unlikely that machine generated code from user
written XML would require all of the power of C++. Unless
they
no, we may not require all the power of c++, you can say like
XML is like domain specific language that our developer want
to execute, but C ++ code will be generated in middle, and
finally bytecode/machinecode/ ELF32 etc...
really needed the speed of an optimized compilation, I'd
probably just "invent" some sort of internal language that was
1) easy to generate from XML, 2) easy to parse, and 3) easy to
interpret effectively. (Said language might not even support
text as a source format.)
We do think instead of generating new languages for optimized
compilation, its good idea not to re-invent wheel.(we may be
wrong and we are very early stage of poc, we may do something
very much diffenetly.)
If you need the optimization, generating C or C++, then using an
optimizing compiler, is certainly a good solution. If you don't
need that much optimization, however: my point is that it is
probably just as easy to generate a simple byte code as it is
C++, and to execute that immediately.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #7
James Kanze wrote:
If you need the optimization, generating C or C++, then using an
optimizing compiler, is certainly a good solution. If you don't
need that much optimization, however: my point is that it is
probably just as easy to generate a simple byte code as it is
C++, and to execute that immediately.
Or you could just generate javascript source code, as you can get a
javascript engine that is inexpensive (free, even) and relatively small.

http://www.digitalmars.com/dscript/index.html

Yes, I wrote it.

-----------------
Walter Bright
Digital Mars
http://www.digitalmars.com C, C++, D programming language compilers
Jun 27 '08 #8
On Jun 2, 7:47 am, Walter Bright <wal...@digitalmars-nospamm.com>
wrote:
James Kanze wrote:
If you need the optimization, generating C or C++, then
using an optimizing compiler, is certainly a good solution.
If you don't need that much optimization, however: my point
is that it is probably just as easy to generate a simple
byte code as it is C++, and to execute that immediately.
Or you could just generate javascript source code, as you can
get a javascript engine that is inexpensive (free, even) and
relatively small.
http://www.digitalmars.com/dscript/index.html
That's actually a very good suggestion. Javascript, perl,
python, and probably a couple of other languages have
interpreters which you can directly link into a C++ program.
Generating one of those languages is probably no more difficult
than generating C++, and you don't have to worry about the
interpreter. (Even Perl could be used here: readability isn't a
real consideration for machine generated code.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #9
On May 31, 9:34*pm, "Ra...@MyKavita.com" <raxitsheth2...@gmail.com>
wrote:
we are designing some stuff , that will generate c++ program(s)
What we want is we wanted to execute that generated code....

i.e.
1. Xml based language
2. C++ code generated from 1.[Its mapping between 1 & 2]
For these first two steps something like Cog could be used:
http://nedbatchelder.com/code/cog/
(unfortunately the website is down at the moment). I have used this
with Cheetah:
http://www.cheetahtemplate.org/
to generate C++ code from XML descriptions. Cheetah could also be used
on its own to generate C++ from XML.

Saul
Jun 27 '08 #10
Ra***@MyKavita.com wrote:
What we have got stucked at compilation, we want that our user should
not take care about compilation or c++ code generation etc...They just
write some xml "code" and it should execute !
That thing has existed for over 50 years and is called "Lisp".
Jun 27 '08 #11
On Jun 2, 4:04 am, James Kanze <james.ka...@gmail.comwrote:
On Jun 2, 7:47 am, Walter Bright <wal...@digitalmars-nospamm.com>
wrote:
http://www.digitalmars.com/dscript/index.html

That's actually a very good suggestion. Javascript, perl,
python, and probably a couple of other languages have
interpreters which you can directly link into a C++ program.
Add Lua to that list. The Lua/C interface is modeled as a stack of
value-typed variables, and it's incredibly easy to integrate into C or
C++ projects.
Jun 27 '08 #12
On Jun 2, 4:28 pm, Matthias Buelow <m...@incubus.dewrote:
Ra...@MyKavita.com wrote:
What we have got stucked at compilation, we want that our
user should not take care about compilation or c++ code
generation etc...They just write some xml "code" and it
should execute !
That thing has existed for over 50 years and is called "Lisp".
Lisp can execute XML? (I'll bet it couldn't 50 years ago.)

Just about any interpreted language can, at least in principal,
take a string and execute it---I've even seen some Basic's which
can do it. Compiled languages, like C++, typically don't carry
the weight of a compiler around with them. About the only thing
special about Lisp (and its dialects, like Scheme) here is that
is remarkably easy to compile, so the extra weight is
considerably less (although the executable for scheme, on my
system, is still more than 3.5 MB). Historically, of course,
Lisp was the first interpreted language.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #13
James Kanze wrote:
Lisp can execute XML? (I'll bet it couldn't 50 years ago.)
No, but it's been pointed out that the only fundamental difference
between Lisp and XML is that Lisp can be executed.
Jun 27 '08 #14
James Kanze wrote:
Lisp can execute XML? (I'll bet it couldn't 50 years ago.)
:)

What I wanted to say is that the rôle that "executable XML" is supposed
to occupy is traditionally (and imho, much better) filled in by a Lisp
dialect of some sorts. They have a head-start of almost 50 years on XML
and Lisp S-expressions are (imho) more readable than XML.

The idea, of course, being that instead of somehow trying some awkward
construct to turn XML into C++ and feed that to an external compiler and
then load the generated object file (or somesuch), it might be more
productive to use S-expressions instead of XML, and embed a Lisp system
in the (C++) application.
Jun 27 '08 #15
Walter Bright wrote:
No, but it's been pointed out that the only fundamental difference
between Lisp and XML is that Lisp can be executed.
Or as John McCarthy says: "XML is isomorphic to the subset of Lisp data
where the first item in a list is required to be atomic."

(http://www-formal.stanford.edu/jmc/cbcl2/node4.html)
Jun 27 '08 #16
On Jun 3, 1:38 pm, Matthias Buelow <m...@incubus.dewrote:
James Kanze wrote:
Lisp can execute XML? (I'll bet it couldn't 50 years ago.)
:)
What I wanted to say is that the rôle that "executable XML" is
supposed to occupy is traditionally (and imho, much better)
filled in by a Lisp dialect of some sorts. They have a
head-start of almost 50 years on XML and Lisp S-expressions
are (imho) more readable than XML.
Yes, but Lisp isn't "in", and XML is. So obviously, a new
project can't use Lisp, and must use XML.
The idea, of course, being that instead of somehow trying some
awkward construct to turn XML into C++ and feed that to an
external compiler and then load the generated object file (or
somesuch), it might be more productive to use S-expressions
instead of XML, and embed a Lisp system in the (C++)
application.
And XML probably maps easier into Lisp than into C++. (There is
a basic simimlarity of structure.) So you can still keep the
XML to show to the customer, and be in, and use a Lisp
interpreter to do the real work:-). (Most of the time I've had
to generate code automatically, it's been mainly tables, and
nested structures do map fairly easily into C++, although if the
structures are dynamic, you end up needing a lot of pointers.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Chris Krasnichuk | last post by:
Hello every one, Does anyone know how to make php work on your computer? please reply I need help Chris
20
by: Chris Krasnichuk | last post by:
hello, Does anyone know how I make php work on "my" computer? I made a mistake in my last post so I fixed it here. Chris
2
by: Patricia | last post by:
I am a new Oracle user. I am trying to install Oracle 9i Personal Edition on Windows ME; however, I am getting the following error during the installation: Oracle Database Configuration Assistant...
57
by: Bing Wu | last post by:
Hi all, I am running a database containing large datasets: frames: 20 thousand rows, coordinates: 170 million row. The database has been implemented with: IBM DB2 v8.1
1
by: gndzkdr | last post by:
hi all, i m new on Sql and i have a project related to C# and Sql. i have to do a project which must work on LAN, and there must be only one database file on main computer(Server Computer) and...
7
by: SHC | last post by:
I'm in need of some javascript to load two pages into two seperate iframes which are on two seperate and different pages. Rather complicated I know (and easier done in one frameset), but caused...
8
by: PhongPham | last post by:
Hello, Info relate: OS : uclinux Platform : unix version 2.4.22 (or 2.4.26) Chip on board : ARM7 I want to get a python package on network to "make" in linux (Fedora core 1 or anything...
8
by: Lemune | last post by:
Hi, I'm developing window service application on C# 2005. The service is to read a new excel file on certain directory, and process it to database. The service work find on XP. But when I...
19
by: pmw | last post by:
Hi I've got a problem with my current application. I currently use Windows Vista with Visual Studio Express 2008. If I compile the application on Vista, it works fine on Vista, but it doesn't...
16
by: tvnaidu | last post by:
I have these two ON and OFF buttons html code below, based on condition I am displaying status on screen(I have mutliple lines for each LED), my row shifting when some displaying ON and some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.