lua-users home
lua-l archive

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


Hi John,

1)	We have compiled Lua ver 4 into our C++ source code and written a very broad range of software in Lua to extend its
functionality. It's doing this job excellently.
Should we consider upgrading Lua to ver 5?

I can share my personal experiences at least. I have developed large applications using Lua 4.0.1 (i.e. only small portions in C where absolutely necessary) and recently do most of my Lua development in 5.0.2. Just some random considerations:

- Lua 4.0.1 is (still) pure bliss! It runs fast and without any problems. Lua 5 in general runs a bit faster even than Lua 4. For us however, the speed of Lua 4 was already amazing and quite sufficient.

- Currently I use Lua 5.0.2 mainly to keep up with the developments. All considering, we will not upgrade our *existing* Lua 4.0.1 code, since there is no need for that really.

-  That being said, Lua 5.0.2 is, of course, also pure bliss!  :-)

-  What I really like in 5.0.2:

1. Lexical scoping of upvalues (the %-notation and its limited scope in 4.0.1 never became second nature...)

2. The new upvalue system makes it possible to "forward declare" local functions, e.g. local recursive functions are now possible.

3. The string.dump function. Now you can simply (pre-)compile scripts in Lua. This is a great improvement over Lua 4. Recently Ashwin Hirschi posted about his solution for Lua 4 to the list (subject: Lua 4 compilation).

4. Tail call optimisation. Though this is a fairly technical issue, I tend to rely rather heavily on it now it's there.

-  What I don't care either way about in 5.0.2:

1. Coroutines. Didn't need them then, don't need them now. All my apps (both Lua 4 and Lua 5) apply the "one thread per Lua state" strategy and it has never failed me.

2. Metatables. Yes, they may be conceptually nicer and offer just some extra juice over the tag system of Lua 4, but all considering, my Lua 5.0.2 apps so far would not suffer a bit if I had to redo them with tags... Plus, the tag system still seems a little bit easier to handle on the C side than metatables.

   3.  The new iterator concept of "for ... in ... do".

-  What I don't like in 5.0.2:

1. Function environments. They are (still) confusing. Looking at my Lua 5 code, the only place where I use them is to execute some script (typically a UI form definition file or some config file) in its own sandbox. I already did that in Lua 4 without function environments (by switching the global table). The Lua 5.1 package system relies on function environments so they will stay around...


In short, since you state that Lua 4 "is doing its job excellently" my guess is that your situation is similar to mine: upgrading existing code may not be worth your while. For new developments Lua 5 is of course definitely an option. Maybe you should wait in that case for the upcoming stable release of Lua 5.1 and skip 5.0.2.

HTH,
Wim