[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Game Logic
Chris Purnell wrote:
> What I'm looking for are alternative ways of solving the
> problem of what the language should be like. I like the
> simplicity of the Quake C language but I don't want to fall
> into the trap of just copying Quake. The only problem with
> it I can see at this stage it that is compiled into a single
> byte-code file. I'd need something more flexible but I could
> do this using the same or a very similar language.
I suggest you take a serious look at Perl.
It is very dynamic, has a compiler that optimizes well, it can be called
by/call to C/C++ (check out Swig), is well supported in the community
and there is a very good book telling about its internals and the
process of embeddeding it into a program.
I don't know much about Quake1 QuakeC, but about Quake3 virtual
machine... I don't know where most people get the idea that a virtual
machine is efficient. With interpreted languages, you have much
advantage of making each operation as "big" as possible (a single
operation should do a lot of stuff). Why? The overhead in interpreters
is the run loop (take instruction, decode it, run it), having very small
instructions makes it so that you spend a lot of time getting the next
instruction and its parameters. With "big" instructions (consider the
grep operator of Perl or its sort operator), you spend your time in
carefully optimized C code, spinning away as fast as possible.
Also, note that Perl doesn't use a simple array of instructions like the
QVM or Java, it uses an in-memory network of structures with pointers to
each others, with a lot of out-of-band communication going on. For
example, when an expression is found to always return the same constant
value, that information flows along the network of operators and
optimizes away the expression evaluation. Anyhoo, take a look at the
Advanced Perl Programming book by O'Reilly, it is very interesting.
Making the bytecode "virtual machine style" (like QVM and Java, again),
has an advantage in the case of Quake. It simply leveraged LCC as its
compiler, using straight ANSI C as the scripting language, enabling
easily recompiling the code with a "real" compiler.
But beside that...
"Unix is the worst operating system; except for all others."
-- Berry Kercheval
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org