[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: class implementation
- From: "Kerry Thompson" <kerryt@...>
- Date: Mon, 3 Apr 2006 17:03:35 -0400
> I really like using lua, it's simple, it's small, i've heard it's also
> fast.
It can be fast if you use it right. Just be aware of its strengths and
weaknesses.
Lua is not a true compiled language like C++. It compiles to bytecode, or
tokens, not to machine language. It relies on a virtual machine to interpret
the tokens. Old-timers will remember UCSD Pascal, one of the first
virtual-machine languages.
Lua will never be as fast as a compiled language, especially in loops,
because the tokens have to be read and the appropriate machine-language
routines called. It will be especially slow with dofile(), because it has to
take the time to convert the text to bytecode. You can kill yourself putting
a dofile() in a loop.
Lua can, however, be quite fast enough when used right, and for the right
sort of application. I wouldn't want to write a 3D shooter engine in lua,
but we use it extensively with our game engines to define rooms, for
example, and it works quite well for that.
Its strengths are that you can optimize things, writing bottleneck routines
in C++ if you need. That, and the cross-platform capabilities, are really
powerful stuff.
Cordially,
Kerry Thompson