lua-users home
lua-l archive

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


Yeah, I was complaining about this as well. Then someone said that __get and __set have been removed as a speed improvement. Curiously enough, IMHO, one could actually do more with tags in Lua4 and it would run faster as well. Meta-tables are slower and you'd want to get rid of anything you can get away with while using them. In fact, in current implementation of Lua5 Beta, it is partially optimized for when one does NOT use meta-methods (Duh!  What an important case for a language whose main virtue is meta-table based extensibility). Basically, as long as one runs plain vanilla Lua5 scripts they will go pretty fast. But as soon as one starts using inheritance, call and other meta-methods on their objects that is when the meta-method overhead jumps in. Syntax-wise meta-tables are pretty but with respect to functionality they are impaired feature-wise as well as speed-wise, in may view, compared to tags in Lua4 (boy, am I repeating myself or what?). My only hopes are that meta-methods access will get optimized at some point for a case when one actually uses them and that computers are getting faster and faster allowing applications to become a little more wasteful in terms of CPU and memory use and letting programmers become less thoughtful at the same time. In my port of a ton of scripts from Lua 4 to 5 I implemented a tag system on top meta-tables. My C code has almost not changed at all (renamed a few functions and such). Then a little massage to scripts fixed the rest of the differences. Another thing that may compensate for MT overhead is that the VM in Lua5 is reportedly faster then in Lua4.

Anyway, Lua5 is still more then well suited for what we use it (even better due to co-routines).

AB

-----Original Message-----
From: jimmyp_gr <jimmyp@hal.csd.auth.gr> [mailto:jimmyp@hal.csd.auth.gr]
Sent: Tuesday, January 28, 2003 11:12 AM
To: Multiple recipients of list
Subject: On lua5 and embedding

Lua was designed to be an embeddable extension language and it seems
to me that it does the second part pretty good.It's very
simple(allmost everything is implemented with tables) and efficient
and it fits nicely into C.Regarding the first point though,
embedding.I rencently took a look at python(I had to write a plugin
for an application) and after reading the Python to C interface I was
almost ready to switch to python(after reading about the language
itself though I reconsidered).You could define your own data types and
do almost anything.Now I agree that userdata and metatables can
achieve the same functionality and may be more elegant and unified in
the sense of the everything-is-a-table philosofy but why the heck are
there so few metamethods?I mean a few like:
__get,__set,__getindex,__setindex would hepl interfacing lua to C
immensely(just take a look at many of the previous threads).I assume
that the problems is the metamethod look-up overhead in frequent
operations like getting and setting global values but couldn't this be
handled with caching of some sort?Besides __get and __set metamethods
on userdata could help implementing a lot of things without assigning
a metatable to the globals table.
btw why the distinction between full and light userdata in Lua5.Light
ones can be implemented with full ones anyway(using a full userdata of
size sizeof(void *)).I know it's not so important but it seems to me
that it unnecessarily adds complexity when lua's goal seems to be
simplicity.
That's all my bitching for now,
Dimitris