It is currently Tue Nov 21, 2017 4:24 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: What's wrong with Lua?
PostPosted: Wed Jun 07, 2017 6:29 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 987
Location: Pennsylvania, USA
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.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 6:46 am 
Offline
User avatar

Joined: Sat Jan 03, 2015 5:58 pm
Posts: 368
Location: ...
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.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 8:20 am 
Online

Joined: Sun Mar 27, 2011 10:49 am
Posts: 206
Location: NYC
Another +1 for Lua. Really nice, clean little language.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 8:24 am 
Offline
User avatar

Joined: Wed Sep 21, 2016 8:55 am
Posts: 55
Location: Calgary.Alberta,Canada
+1 also for Lua


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 8:48 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19238
Location: NE Indiana, USA (NTSC)
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:
    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?


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 9:52 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 987
Location: Pennsylvania, USA
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:
    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.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 10:17 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 582
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.


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 10:21 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5824
Location: Canada
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.)


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 10:26 am 
Offline
User avatar

Joined: Mon Oct 01, 2012 3:47 pm
Posts: 153
Location: freemland (NTSC-U)
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:
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).


Top
 Profile  
 
PostPosted: Wed Jun 07, 2017 12:26 pm 
Offline
User avatar

Joined: Fri Feb 27, 2009 2:35 pm
Posts: 214
Location: Fort Wayne, Indiana
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.


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 12:44 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 256
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 ;)


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 7:51 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2981
Location: Tampere, Finland
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: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 7:59 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19238
Location: NE Indiana, USA (NTSC)
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).


Top
 Profile  
 
PostPosted: Thu Jun 08, 2017 1:47 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 932
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.

_________________
.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group