lua-users home
lua-l archive

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




> This is what I *really* want, purely for speed and ease-of-conversion,
its
> about time languages added a vector type to their integral types (in
C++
> you
> can do it with templates but compilation slows down terribly).  Most
> modern
> applications have to deal with 3d in some form or other now which
wasn't
> the
> case when most of the languages were invented.  ints and floats don't
cut
> the mustard no more.

It's all want, want, want with you Cuthbert! Lua doesn't have ints! The
default is double, which covers floats, ints, 32bit unsigned ints (so
you can do 32 bit colour). Light userdata was added to replace C
pointers cast to numbers and passed round inside Lua IIRC. 


> Sure you can just about do it in Lua but when almost every operation
in a
> video game involves a vector of some sort it becomes obvious that
> optimizing
> that one area would create enormous gains. (for the gaming industry)

Yep, for the gaming industry, but what about the mathematicians who want
complex numbers and arbitrary precision integer math. Lua is easily
extensible to cope with these types. Python has both afore mentioned
types as built in types. Your job then is to *remove* them when you want
to embed Python in your game. I sat on a round table at GDC and a
programmer there was explaining how after stripping down Python you're
still left with a 500kb+ library. Lua is probably a 1/5th of this
including compiler, and a hell of a lot faster.


> Modern cpus now have ints, floats *and* vectors as integral types.
> Remember, you don't need to have floats as integral types either, you
can
> implement a floating point system in lua using integers and
metatables. ;)

But when you add two floats together in an interpreted language it's not
compiled down into assembler - it's executed by the VM. So executing
vector math on the VM using metamethods is not a whole lot different.

Now, I had this idea about statically compiling Lua scripts and
converting them into C++ for the release version, but having the nice
fast data/script driven development speed. If you were to do this you
would get a nice speed advantage and the C++ could then give you
hardware vector access. Since Lua is a dynamic language there are a
whole heap of issues with this (e.g. functions are first class objects,
environments etc. - it would have been easier with Lua 4!) but you'd be
closer to the advantages you mention. It was just an idea  :-/

--nick