Has anyone used LuaLanguage
for standalone application development? Has anyone used LuaJava
Please note the following CeeLanguage
code from the "Lua-an extensible extension language" paper (1994) at http://www.lua.org/spe.html
A simple Lua interpreter can be written as follows:
int main (int argc, char *argv)
iolib_open(); /* opens I/O library (optional) */
strlib_open(); /* opens string lib (optional) */
mathlib_open(); /* opens math lib (optional) */
while (gets(line) != 0)
Earlier versions of this page criticized that CeeLanguage code for using the unsafe function gets, which is a correct criticism of CeeLanguage practice, but OffTopic regarding LuaLanguageDiscussion, particularly considering how many comments touched on that digression. And considering (just to be done with the subject once and for all):
- No, there are no calls to gets() in Lua. --JohnPassaniti
- (To make the code do the Right Thing in the presence of over-long input lines, you'd need to double or triple its length, thus obscuring it and making it unfit for its purpose as an example. You could make it safer by using fgets instead of gets, but it would still do the wrong thing when given over-long lines.)
- A single call to glibc's getline (http://www.gnu.org/software/libc/manual/html_node/Line-Input.html#Line-Input) would have been safe and just as clear. -- ThomasColthurst
- Ok, that should wrap that up.
Cool little interpreted language. We're using it on our game development project. Fun stuff!
A fast and very spare little language with a clever VM, but the mismatch of Lua's data model to your own when using something as simple as a vector of ints in Lua is simply mind-boggling. You either have to pass it around as an opaque chunk of untyped "userdata" or write all your own access primitives, because Lua actually lacks an int datatype (or if you want it, you then lose floats), and it has nothing like a vector type, just an "array part" that might or might not actually map 1-to-1 index-wise with your own array.
Basically it seems useful for flow control, with all your real datatypes done in C or C++. Nothing you could write a real application in without a lot of pain.
You only really need the bare C datatypes when you're doing something that needs bare-metal performance, and you should only be manipulating those in C anyway. When you need to make large stuff in Lua that doesn't cross over, table-string-number only design comes easily.
What's clever about the VM?
it's bundled up into a single C context, with no external dependencies. you can create one, or many, this seems fairly unusual for scripting languages, which mostly seem to work as stand-alone executables, and even if they can be embedded are full of global data.
I have used many
kinds of languages now, and like me you know that all good languages, such as Lua, have their facilities and advantages! You cannot judge a language with silly comments or toy examples! Lua may have its negative points (which I can't point to), but it's absolutely great for data manipulation... It uses hash tables in the background and you could easily handle your data with few lines of code! I'm sure that Lua has so much to offer. You should try using it and studying it instead of just making suppositions about it. Another advantage of Lua is that its interpreter is very
small, and it fits in a very small amount of memory. It is also very fast
and very portable!
I'm waiting for comments and am sorry about any English mistakes; I'm a student from Brazil... -- Pablo
What English mistakes? You sound like a native speaker to me! -- A WikiGnome :-)
Question: Could Lua be described as a PrototypeBasedLanguage
I did a presentation for a programming languages class that classified Lua as exactly that.
It's very easy to create a prototype object and clone it.
I think FLISL is better for embedding a interpreted program language to extend something.
- Lua is pretty easy for non-experts to pick up and use. The same cannot be said about forth at all
See also ToLuaDescription