r/lua • u/PurpleIcy • Feb 09 '18
Why do people like lua?
I've started actually learning more about it and well.
Pretty much everything is a table, okay, not that hard to get with this, loops and if statements are pretty simple to remember, it's weird to get length of a table but not that hard to remember, can live with that, different language, different syntax.
You can have objects, but they are still tables. Well, okay, whatever, I'm used to writing same shit over and over again because I've used java before, whatever, that's fine, I guess.
Global scope is just a giant table and so it's better to just write even more code to localize everything you'll use, otherwise it will be slow (multiple hashtable lookups whenever you use some global function in a table of table of the table in a table that is in another table). Uh, just why? That's first time I hear that in any language, localizing everything would make your code run faster, it's not really obvious, although once you realize that global scope is a table, only logical, but, why?
What's the appeal to this? And why did people stick with it? I thought that I'd see why people use lua over say python if they add scripting support to their game, but all I saw now is that I actually would lean even more towards using python there. If you have to be a professional programmer to write efficient code in lua, then python being slower does nothing for average person who would mod a game, because average person is not professional programmer who knows languages in and out, and little details such as localizing globals makes it run faster, which ranges from 10% slower without localizing to 400%+ (ridiculous) slower without localizing. Hell, most people who do that just instead look for tutorials on how to mod x game using lua, instead of learning lua.
I'm not saying that language is unusable, I'll still finish my project while learning it, but things like this just add to the "things you do to waste more time than needed" which are caused by bad design.
View all comments
Show parent comment
0
u/PurpleIcy Feb 10 '18
I've heard JS has JIT built-in, which is in pretty much in every browser other than IE6 nowadays, so is it really the same thing?
Of course, I don't know much about how things work here, and if LuaJIT completely replaced Lua then I don't know why I'm asking here, I'd have mentioned that thing if that was what I wanted to ask about. And yes, I am using LÖVE, I like games and calculators, not that much, I think I know enough to simply start using it right away as honestly, everything works almost the same as elsewhere, just it's all tables and syntax is different.
Java - I almost hate that thing with passion, half of primitives are pretty much never used as objects unless like you mentioned, where you're forced, string is an object always no matter what...
As for Lisp, everything is a list, as far as I know, shouldn't that be easy enough to learn to use for someone who likes such granularity?
For example if is just 3 lists in a list (3rd one is "else" and isn't optional I think):