What's wrong with Lua?

You can talk about almost anything that you want to on this board.

Moderator: Moderators

Post Reply
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

What's wrong with Lua?

Post by GradualGames »

NovaSquirrel wrote:For me the thing that stopped me from having any interest in PICO-8 was the code size limit. Lua just made it even less appealing and I just continued to do NES stuff instead.
This is the second fellow brewer I've heard say they don't like Lua. Out of curiosity, what do you (or anyone else) dislike about it?

I like it because of how little ceremony it has to the syntax. I also like how easy it is to pass functions around as data. The consistent KEYWORD....END syntax is nice, too, instead of being forced to use tabs as in python for instance. I like that everything is a table.

Perhaps the only thing I find odd is tables starting at 1 instead of 0. Takes some getting used to. That's the only wrinkle I've found so far really. The rest of it is really fun to work with.

*edit* Oh! And coroutines! Lua's the first language where I successfully applied coroutines. No, wait, I did that in 6502 first...haha (thanks for the idea tokumaru!). Coroutines make state machines in games really really nice to work with.
User avatar
nicklausw
Posts: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: What's wrong with Lua?

Post by nicklausw »

I was gonna ask the same thing about why people don't like Lua. Just picked it up a few days ago to experiment with scripting in FCEUX, and honestly I love the language already. I've been converting some of my python tools for fun, and the source has generally ended up smaller and neater so far.
adam_smasher
Posts: 271
Joined: Sun Mar 27, 2011 10:49 am
Location: Victoria, BC

Re: What's wrong with Lua?

Post by adam_smasher »

Another +1 for Lua. Really nice, clean little language.
User avatar
OmegaMax
Posts: 80
Joined: Wed Sep 21, 2016 8:55 am
Location: Calgary.Alberta,Canada

Re: What's wrong with Lua?

Post by OmegaMax »

+1 also for Lua
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: What's wrong with Lua?

Post by tepples »

A typical data conversion tool in my NES toolchain is pilbmp2nes.py. Had I made it in Lua instead, I would have run into at least these problems:
  1. Tables start at 1, making line-by-line hand translation of programs in other languages that much more error-prone.
  2. No integer type, instead relying on the FPU. (JavaScript has the same problem.)
  3. No bitwise operators prior to 5.3. Data converters tend to need them, particular when CHR data and compression are involved.
  4. Python 3 is installed by default in modern GNU/Linux systems. Lua isn't.

    Code: Select all

    The program 'lua' is currently not installed.  To run 'lua' please ask your administrator to install the package 'lua5.2'
  5. What's the widely used counterpart to Pillow, the Python imaging library?
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: What's wrong with Lua?

Post by GradualGames »

tepples wrote:A typical data conversion tool in my NES toolchain is pilbmp2nes.py. Had I made it in Lua instead, I would have run into at least these problems:
  1. Tables start at 1, making line-by-line hand translation of programs in other languages that much more error-prone.
  2. No integer type, instead relying on the FPU. (JavaScript has the same problem.)
  3. No bitwise operators prior to 5.3. Data converters tend to need them, particular when CHR data and compression are involved.
  4. Python 3 is installed by default in modern GNU/Linux systems. Lua isn't.

    Code: Select all

    The program 'lua' is currently not installed.  To run 'lua' please ask your administrator to install the package 'lua5.2'
  5. What's the widely used counterpart to Pillow, the Python imaging library?
It always seems like the ecosystem of a given language has so much to do with which domains it becomes successful in. I have a bunch of python tools as well, I'm very happy with those and will not be rewriting them a third time. Definitely enjoying lua for fceux debugging and also in pico 8 though.
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: What's wrong with Lua?

Post by calima »

Back when I needed an embedded scripting language, besides the 1-based counting, I chose not to use LuaJIT because it was so huge. Even it it's fast, that's not something I'd be able to debug at all, when something breaks, and something always breaks.

I chose JimTCL instead, which was comparably tiny and very debuggable, even if slower.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: What's wrong with Lua?

Post by rainwarrior »

tepples wrote:A typical data conversion tool in my NES toolchain is pilbmp2nes.py. Had I made it in Lua instead...
The typical usage of Lua is embedded into another application to add scripting capabilities. That's what it was designed for. It doesn't normally appear as its own stand-alone OS level application.
tepples wrote:What's the widely used counterpart to Pillow, the Python imaging library?
If Lua is embedded in an application that works with images, it might have access to that application's imaging capabilities. Lua libraries do exist, but because the usual application is as an embedded lightweight scripting augmentation, generally the implementation wouldn't want or need to include many libraries. (The same is true of embedded Python usage, too.)
User avatar
freem
Posts: 176
Joined: Mon Oct 01, 2012 3:47 pm
Location: freemland (NTSC-U)
Contact:

Re: What's wrong with Lua?

Post by freem »

tepples wrote:Tables start at 1, making line-by-line hand translation of programs in other languages that much more error-prone.
I've always found this annoying, but nothing actually stops you from declaring or using index 0:

Code: Select all

local junkPile = {
	[0] = "hello",
	[1] = "world",
}

for k,v in pairs(junkPile) do
	print(string.format("[%d] %s",k,v))
end
tepples wrote:No integer type, instead relying on the FPU. (JavaScript has the same problem.)
The first item on the "main changes" list for Lua 5.3 is "integers (64-bit by default)". Since your next point mentions requiring Lua 5.3 for bit ops...
tepples wrote:No bitwise operators prior to 5.3. Data converters tend to need them, particular when CHR data and compression are involved.
Various solutions exist for this, even for versions before 5.3.
tepples wrote:What's the widely used counterpart to Pillow, the Python imaging library?
Based on number of downloads from LuaRocks (think something like Perl's CPAN, but for Lua), the most used library is a wrapper for imlib2 named lua-imlib2.

Other solutions are available from the lua-users wiki ("Image Manipulation" section).
User avatar
NovaSquirrel
Posts: 483
Joined: Fri Feb 27, 2009 2:35 pm
Location: Fort Wayne, Indiana
Contact:

Re: What's wrong with Lua?

Post by NovaSquirrel »

In addition to weird syntax, Lua has weird behavior that differs a lot from other languages and can create traps for people who aren't aware of them or who forget:
  1. Lua doesn't differentiate between nil and an undefined variable. If you typo a variable name, it will just have the value of nil and you won't get an error. If you put nil into an array, it becomes a table instead and loses an array's speed benefits, also making the # operator incorrect. I've seen other people tweet about problems that they traced back to some variable name being typoed.
  2. Starting at 1.
  3. No switch statement so you have to do weird workarounds. Same for if you want OOP features or try/catch.
  4. Boolean expressions act weird. 0 and 1 are both true, but not 0 and not 1 are false?
For my own projects I've always used Squirrel, which looks and behaves a lot more like C. It's very easy to move algorithms back and forth between Squirrel and other languages, and I've adapted code I've found written in JavaScript before.

That said there are some features in Lua that I wish I had in Squirrel, like goto and a JIT version of the language. Try/catch provides a lot of the use case I normally have for goto though.
Oziphantom
Posts: 1565
Joined: Tue Feb 07, 2017 2:03 am

Re: What's wrong with Lua?

Post by Oziphantom »

What has already been said. Although to be fair I was seeing LUA 2~3 and by 5 it seems to have grown a lot( I'm also surprised it still is growing, mentally I have it filed with Perl), but its point was to be a small simple scripting language, but it started to suffer from "shiny hammer" syndrome. I feel that GameMonkey was a better product for the purpose. And going from GameMonkey to LUA felt like going backwards ;) ( yes I know LUA came before )
Other crimes in my book
- Garbage collection
- JIT
- Dynamic
- Duck
This tends to give it a large resource impact, random CPU usage and make the code hard to follow after coming back to it. It tends to be string heavy which only compounds the problems.

Again fine if you are doing a 256 line script for something like a PC, but not something you want to make a game in, not something you want to make a game in for a resource bound machine. Not something you want to use on a machine where you limit the size and number of commands, where said size is based upon the "byte encoded" size that changes depending on what and how you do something, with no clear 1:1 ratio.
To me LUA is a better VBA, and I would rather use in a situation where I would consider VBA, only VBA is built into Windows and hence comes "for free" so I just use VBA ;) But if I wasn't on Windows then the door is open.

Having ints now is nice ;) Although tepples doing an | 0 in JS is a nice hack to force an int, as you can't do binary maths on a float ;) Doing |0 before sending values to a canvas to render gives a nice speed boost ;) Although having the "its not bad, if you do <insert hack here>" is basically pointing out their is a problem ;) And the problem probably is your trying to use it to do something it wasn't meant to do ;)
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: What's wrong with Lua?

Post by thefox »

To add to the list of complaints, if you forget local when defining a variable, it will define a global variable (or modify an existing one) instead.

I do like it despite all the complaints, although I would take Python if I had the choice. On the upside, Lua is easy to integrate and quite compact.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: What's wrong with Lua?

Post by tepples »

thefox wrote:To add to the list of complaints, if you forget local when defining a variable, it will define a global variable (or modify an existing one) instead.
JavaScript without "use strict" has the same problem. So do C and C++ if a global variable happens to have the same name and type as the local variable you forgot to declare. For comparison, in Python, global variables are read-only without the global keyword, and in PHP, global variables aren't even in scope without the global keyword unless they're variables defined by the interpreter (mostly $_REQUEST and $_SERVER).
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: What's wrong with Lua?

Post by zzo38 »

I think that each program can do one thing, so you don't (usually) need the picture format conversion between two formats in one program, and can just convert one format. You can use one program for sort, one program for shuffle, one program for make audible on speaker, one program to rasterize for printing, one program to convert into format for printer, one program to send it to the printer, etc.

I don't like the 1-base tables in Lua either, although, that is what it is.
(Free Hero Mesh - FOSS puzzle game engine)
Post Reply