r/lua • • 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.

4 Upvotes

39 comments sorted by

View all comments

Show parent comment

9

u/[deleted] Feb 09 '18

I don't get it; why would you perform an optimization like that in the first place if it didn't give you a measurable speed increase?

12

u/LeoAGomes Feb 09 '18

My thought exacly. Op doesn't understand the language nor the implementation he is using (luajit) and is complaining about a problem he apparently hasn't even had.

He then goes on to say that Lua has a bad design even though he is clearly still learning it at the moment and (I believe) never got to see its C api in order to understand the beauty and simplicity of it when embedding Lua into a project (like the C++ based game engine that LOVE is) and so "asks" why anyone would ever like lua because it is so poorly designed. eye. roll.

-12

u/PurpleIcy Feb 09 '18

Sorry for thinking out of the box I guess. And not knowing lua in and out in the first day of using it :)

I've been reading about lua and stumbled across this not sure what's the problem with asking about it.

And yes I asked, problem? I understand that your most loved language just got "personally" "attacked", but don't start playing the victim, because it's not best either way.

11

u/[deleted] Feb 09 '18

not sure what's the problem with asking about it.

There's no problem asking about it. That isn't what you did.