Lua: Good, Bad, and Ugly Parts

I have come across several detailed lists that mention good and not-so-good parts of Lua (for example, Lua benefits, why Lua, why Lua is not more widely used, advantages of Lua, Lua good/bad, Lua vs. JavaScript, and Lua Gotchas), but I found that some of the features that tripped me or that I cared about were not listed, so I put together my own list. It is far from being comprehensive and some aspects of the language are not covered (for example, math and string libraries), but it captures the gist of my experience with the language.

Read in full here:

http://notebook.kulchenko.com/programming/lua-good-different-bad-and-ugly-parts

This thread was posted by one of our members via one of our news source trackers.

2 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes

Incremental garbage collector that has low latency, no additional memory cost, little implementation complexity, and support for weak tables.

This is not a pro, this is a con, I OFTEN see the LUA GC consuming more time than the scripts that it itself runs when I profile them in some games and programs, and this just seems utterly crazy. I know it’s mostly the people who write the scripts fault, but the language design encourages that kind of sloppy programming. Now note the mostly, the GC still eats substantial time even when little to no garbage is generated but a a lot of tiny objects are held, even if they are heavily used, it still feels the need to walk everything.

Multiline strings (using [[...]]; can be enclosed with [[...[=[...]=]...]]) and comments (--[[...]]).

This also is not a pro, especially for newbies (of whom lua is supposedly for). Like would have ever thought to use that syntax for multiline strings?! And don’t even get me started on the weird concatenation operator of .., again who would have thought that, especially for a newbie focused language?!

Fast and powerful JIT compiler/interpreter (LuaJIT) which includes FFI library and is ABI-compatible with Lua 5.1 (this means that it can load binary modules compiled for Lua 5.1).

Luajit is indeed amazing, but it’s not standard lua, not made by the lua devs, it’s entirely third part, doesn’t do everything lua can do, has other things that lua doesn’t have, it’s another language, it’s not lua. It’s “mostly” compatible, but even then if you are using the lua C api to bind it instead of its new form you gain almost no speed across API calls because of the marshalling costs, and indeed it can be slower as it often has to marshal something it didn’t have to before. This should be considered another language, not a pro of lua itself.

Tables and strings are indexed from 1 rather than 0.

This, this is just horrifying, don’t know why anyone, anyone would have ever thought this was smart. Instead of a big paragraph just go read this:
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

No integers as a separate numeric type; the number type represent real numbers. The next version of Lua (5.3) may change that.

Yeah and this article is showing its age, lua has long since moved past this limitation.

No classes; object-orientation is implemented using tables and functions; inheritance is implemented using the metatable mechanism.

No classes is a “good thing”, how is this marked as different anyway, most languages don’t have classes… o.O

nil and false are the only false values; 0, 0.0, “0” and all other values evaluate as true.

Yeah weak typing is just horrible, like it’s not near as bad as javascript, but it’s still pretty bad…

Non-equality operator is ~= (for example, if a ~= 1 then ... end).

Such a hugely different thing, especially for newbies, how often do people use the Shift+key after all, especially with how much harder it is to hit than!as it requires rotating my hand to hit instead of just translating upwards like for shift+1 for!`.


And basically the rest of it as well, but some of it is not an issue anymore, this article is just really really old.

2 Likes

I was taking a course on Adobe ColdFusion when I was new to web development. When I heard array indexes in ColdFusion start from 1, I laughed out loud, even if I was a complete noob.

2 Likes