[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting



Eero Pajarre wrote:

> I have always thought that the way data structures are done in Java
> very much resembles typical pointer usage. Garbage collection
> of course relieves me from manually freeing  data, and indexing errors
> are also checked (but I can get the latter also in C++, and I could
> even use gc there).

Garbage collection is a reasonable idea for non-realtime programs - but
for those of us who *live* by getting around a render loop in under 16.7
milliseconds, the idea that some mysterious background activity could
snarf the CPU and disappear for several milliseconds (or in some cases,
tens of milliseconds) is a completely unworkable proposition.

Determinism is the name of the game here - and manually freeing data
allows me to choose when I have the time to do that and to have a
reasonable idea in advance of how long that process will take.

For scripting simple game activities like AI and object behaviours,
you probably don't need to allocate or free memory on-the-fly - and
even if you do, the programs are generally *tiny* - so garbage collection
never takes too long.

But take a 100,000 line game or a 1,000,000 line flight simulator and
garbage collection will quite simply kill performance once in a while.

If you are playing quake and the game suddenly freezes for even a
tenth of a second, it can really throw your game.

Java is fine for network stuff because people expect the occasional
mysterious pause - that's what the Internet is like. Like most languages,
it's fine for the job it was designed for - but poor at jobs outside
of it's domain.  Don't use Lisp for signal processing, don't use C++
for expanding HTML, don't use Java for flight simulation and don't
use COBOL for...well, *anything* actually!

> Still it is quite possible to make mistakes
> with java which correspond to stale and rogue pointers in C++.
> (For example you return a object, which is piece of your main data structure,
> without cloning the object, latter a prosessing function modifies
> this object, without you understanding that your main data structure is
> modified)

Sure - no 'sufficiently powerful' language can prevent you from making any
errors at all.  That's mathematically provable (check out "The Halting Problem").

> After saying that I still use scripting (lua) in my game. My number
> one reason for this was avoiding the need of development environment
> at the end user platform. Latter I have started to value the ability
> to making the protected and  "easy" environment for end user modifications.

Yes - I think that's a reasonable choice for the user-modifyable parts of
the game.
 
----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net