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.

Popular General Dev topics Top

First poster: dimitarvp
skiftOS is a simple, handmade operating system for the x86 platform, aiming for clean and pretty APIs while keeping the spirit of UNIX. s...
New
First poster: dwaynebradley
Maybe it’s just my experience, but Object-Oriented Programming seems like a default, most common paradigm of software engineering. The on...
New
First poster: iPaul
TOKYO (Kyodo) – Japan’s government plans to encourage firms to let their employees choose to work four days a week instead of five, aimin...
New
First poster: bot
Kinesis Advantage360 Ergonomic Keyboard. Split-adjustable, contoured design that maximizes comfort and boosts productivity. Mechanical s...
New
First poster: bot
GitHub - nanobowers/py2cr: Python3 to Crystal Translation using Python AST Walker. Python3 to Crystal Translation using Python AST Walke...
New
First poster: bot
For the first 8 or so years of my programming experience, while I was an undergraduate and later graduate student, working in the experim...
New
First poster: gflashner
Why Flutter is the most popular cross-platform mobile SDK. Running a development team for each mobile platform sucks up resources from o...
New
First poster: bot
To build a web application you need to make architecture decisions across a range of topics. The beauty of Ruby on Rails or Django is tha...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
First poster: bot
openai-python/chatml.md at main · openai/openai-python. The OpenAI Python library provides convenient access to the OpenAI API from appl...
New

Other popular topics Top

AstonJ
We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1127 25299 748
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
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
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New

Latest in In The News