CommunityNews

CommunityNews

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.

Most Liked

OvermindDL1

OvermindDL1

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.

DevotionGeo

DevotionGeo

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.

Where Next?

Popular Embedded topics Top

First poster: bot
Lua is one of my favourite programming languages. I’ve used it to build a CMS for my old educational website, for creating cool IoT hardw...
New
First poster: bot
From init.vim to init.lua - a crash course. 5 minutes crash course on moving from init.vim to init.lua and unleashing the power of Neov...
New
First poster: OvermindDL1
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 ...
New
First poster: OvermindDL1
Using Zig to Build Native Lua Scripts. Using Zig to Cross compile a Lua script for multiple arches
New
First poster: bot
Fengari (Moon in greek) is the Lua VM written in JavaScript. It uses JavaScript’s garbage collector so that interoperability with the DOM...
New
First poster: bot
GitHub - IBM/MicroscoPy: An open-source, motorized, and modular microscope built using LEGO bricks, Arduino, Raspberry Pi and 3D printing...
New
First poster: bot
Print an Arduino-Powered Color Mechanical Television. Anyone with a 3D printer can make a new twist on the oldest type of TV
New
First poster: bot
Introducing multitasking to Arduino | Arduino Blog. With the increased capabilities of Arduino and other microcontroller boards, includi...
New
First poster: bot
GitHub - rxi/lite: A lightweight text editor written in Lua. A lightweight text editor written in Lua. Contribute to rxi/lite developmen...
New
First poster: bot
MicroPython officially becomes part of the Arduino ecosystem | Arduino Blog. At Arduino we like to experiment with new technologies to f...
New

Other popular topics Top

siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New