Just in time compiling

J

Justin Naidl

A group of friends and I are doing a RPG (role-playing game) maker for a
school project. It occured to us, however, that if you want the user to be
able to have almost complete control over the contents of his/her game, that
you would end up with a tiny executable and a huge datafile. We wanted to
keep clear of this as disk accesses take a lot of time to do and there would
be a huge load of them to do this part. We could very easily write a
program to spit out the code but we don't know how to get it to compile into
an executable as part of the software. The user shouldn't have to be a
programmer to get a working game. We basically want them to design a game
and then click a build game button. On that click, the code is generated
and compiled. Now, the way we figure it, is using just in time compiling we
can use .Nets clr, intermediate language, and just in time compiling to
achieve this, however, we don't know how. :) So any thoughts or good
pointers would be most helpful.


Thanks
~Justin
 
D

Daniel O'Connell [C# MVP]

Justin Naidl said:
A group of friends and I are doing a RPG (role-playing game) maker for a
school project. It occured to us, however, that if you want the user to
be
able to have almost complete control over the contents of his/her game,
that
you would end up with a tiny executable and a huge datafile. We wanted to
keep clear of this as disk accesses take a lot of time to do and there
would
be a huge load of them to do this part. We could very easily write a
program to spit out the code but we don't know how to get it to compile
into
an executable as part of the software. The user shouldn't have to be a
programmer to get a working game. We basically want them to design a game
and then click a build game button. On that click, the code is generated
and compiled. Now, the way we figure it, is using just in time compiling
we
can use .Nets clr, intermediate language, and just in time compiling to
achieve this, however, we don't know how. :) So any thoughts or good
pointers would be most helpful.

Well, first thing, don't throw out the tiny engine, large datafile approach
offhand. Most commercial games use this approach(as do most game
construction kits I've seen.) A large executable can cause alot of trouble
in its own right. Test it and see. With careful caching and logical file
design I suspect you'll find pretty good performance.

Now, on to the larger question, compiling scripts. Its to large a topic for
this post, but the System.Reflection.Emit namespace offers almost all of the
classes you could ever need to construct a compiler, and the greater web
contains a wealth of information on it.

Amazon has two books directly on topic, although I've never read them and
can't speak to the quality:
http://www.amazon.com/exec/obidos/t...bs_b_2_1/103-3462433-9574251?v=glance&s=books

http://www.amazon.com/exec/obidos/t...f=sr_1_1/103-3462433-9574251?v=glance&s=books

There is a mailing list as well, although it is a very quiet mailing list,
as well as other resources at
http://www.gotdotnet.com/team/lang/

If you want to just use C#, VB.NET, or another language that provides a
CodeDOM compiler as your scripting you could use the appropriate classes.
Do you know what language you are planning on using, there might be a
compiler for it if it exists? I can probably give you more information if I
knwo what approach you are looking to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top