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
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
A self-contained AVR programmer using an Arduino Uno. For a project I need to be able to program an ATtiny84 microcontroller but I don’t...
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
CommunityNews
April 22nd is Earth Day – a powerful reminder of our shared responsibility to preserve the planet for future generations. While the call ...
New

Other popular topics Top

malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1143 25816 759
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 Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New