lua-users home
lua-l archive

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


On Wed, Jan 20, 2010 at 12:50 PM, Francesco Abbate <gslshell@gmail.com> wrote:
> For the other side I've discovered some shortcomings of Lua:
> 1) the lack of a debugger to step through the code is really painful.
> I'm used to to so in C/C++ with gdb and not having that with lua was
> painful.

I've never found a debugger as good as gdb for ruby, python, or lua.  :-(

> 2) in lua all the arguments are passed by values except when they are
> objects because in this latter case you can have only reference
> (pointer) to the objects. When writing complex algorithm is confusing
> because you have always to keep trace in your mind if a routine modify
> an object or if it does creates a new one. For examples if I write:
> p = q
> or
> p = q + z
> where these are objects the first statement will just point p to the
> same object of q while the seconde statement will create a new object
> for 'p'. If you later change 'p' you may or not changing the original
> object 'q' depending on the assignment that you've done. I'm always
> unconfortable with this kind of behaviour and I need to stay alert
> about object assignment and side effects.

I'm baffled as to what languages you have used before that make this surprising!

Its like this in lua, python, perl, ruby, bash, c++, java, even
fortran and lisp...

Is there a language in which after

 p = q + z

p is actually q, but q was modified? wow. doesn't that mean that
addition is not commutative?

p =q + z -- modifies q, and p is now q?
p =z + q -- modifies z, and p is now z?

> 3) the lack of any typing system and mandatory variable declarations
> in Lua prevent the detection of many errors that could be otherwise
> detected by the compiler. For example  took me a while to find this
> bug: I wrote
> if i1 == i2 then bla bla...
> instead of
> if g.i1 == g.i2 then bla bla...
> The interpreter did not raise any error not even at run time because
> i1 and i2 was supposed to be global variables and as both of them were
> nil they were actually equal!

Check out strict.lua in the lua source distribution.

Cheers,
Sam