
Lua: the world's most infuriating language? - jgrahamc
http://www.slideshare.net/jgrahamc/lua-the-worlds-most-infuriating-language
======
Pxtl
... that is the _strangest_ collection of complaints I've ever seen about Lua.
He obsesses over minor syntactic quibbles like the lack of a += operator and
the ~= and "not" instead of C's inexplicable exclamation marks (how does this
man stand SQL?) but he doesn't dwell on Lua's bigger flaws.

I mean, 1-based arrays, weird scoping and the pairs/ipairs thing seems far
more serious than the lack of a proper conditional operator (how long did
Python go before it got a conditional operator?)

Lua is everything it was meant to be - a lightweight, user-friendly, safe
language that runs nice and fast in spite of being very hashtable-oriented.
There's a good reason it's heavily used as a scripting language for game
engines and other platforms that need to let users run code provided by other
users - a more "batteries-included" language would have users wiping each
other's filesystems.

~~~
aDevilInMe
1 based indices are fine most of the time, they are mostly like 0 based yet
start at 1 :) When it does become a problem is when you are reading and using
binary formats and offsets, where I seem to always get off by one errors. A
ternary function, iff, is soo simple to implement Lua. Scoping is just
something you have to understand as with tables there is no problem with them
besides a beginners understanding of them.

What you consider a minor gripe, compound assignment operator, I personally
think is a flaw in the language same goes for bitwise functions instead of
operators. Here is an example I posted earlier on twitter.

object = object + other

"object" and "other" here are full userdata and the code is going to malloc a
new userdata and also create a new object in C/C++; which is straight away
going to over write the original instance. Huh? why? += makes so much sense.

Each to there own, I can fix my issues using patches but it would be nice if I
did not have to.

~~~
bonzaro
Might I ask, how would you implement a ternary function that should retain the
lazy evaluation quality of the syntactic ternary operator?

------
Demiurge
So why is Lua so much faster than Python? I tried searching about this but
primarily people discuss historical context. I'm curious about real language
features and whys.

~~~
oscargrouch
Mike Pall is behind Luajit.. Get him or Lars Bak to work in a jit compiler and
you language will be fast as it can be..

Of course, bad designed language in terms of performance will suffer more to
get into the state-of-the-art

~~~
masklinn
Mike Pall has noted design decisions of Python which make it much harder to
optimize than Lua in the past: [http://lua-
users.org/lists/lua-l/2004-11/msg00083.html](http://lua-
users.org/lists/lua-l/2004-11/msg00083.html)

~~~
Demiurge
Thank you, that's the kind of stuff I was looking for.

------
compay
I've heard almost all of the complaints before and had a few of them myself.
But before tearing this guy a new one for rattling off a list of trivial-
sounding complaints, be aware that the second half of the presentation extols
the virtues of Lua and advises you to "get past the initial irritation."

------
truebosko
I felt the same way, but I used MoonScript for a simple hack project and it
removed a lot of the Lua annoyances.
([http://moonscript.org/](http://moonscript.org/))

------
justincormack
The video is here, although the sound quality is not great, sorry
[http://www.youtube.com/watch?v=_pOkOAq5jfM](http://www.youtube.com/watch?v=_pOkOAq5jfM)

------
kazagistar
Well played. Title intentionally plays off the "question mark in title means
answer is no" meme.

------
16s
I think of it as the C of scripting languages. You have to roll a lot of your
own stuff.

~~~
jacques_chester
I think that a better analogy is the Scheme of script languages.

~~~
mseepgood
I always felt that Scheme was the Scheme of scripting languages. Or is Scheme
rather the Lisp of scripting languages?

~~~
mheathr
One of my favorite Scheme reads was an e-mail discussion on whether it was
possible to add OOP to a functional programming language, and then the author
goes on to do so in a trivial amount of code. A cursory search doesn't turn up
the exchange I had in mind though, or I would link it.

------
benbeltran
It's weird that I see many people complaining about tables because of
pairs/ipairs or trivial stuff like that, which are more nuisances than
anything. The flexibility of tables/metatables make them a very powerful data
structure (not unlike javascript's prototype). I've been playing a bit with it
for game development and you can build some very powerful stuff just using
tables.

Maybe instead of trying to use lua as another language, you should totally
embrace "the lua way" and then you'll understand why their tables/metatables
is the way it is.

------
snarfy
If you can't get past the initial complaints, try squirrel.

[http://www.squirrel-lang.org/](http://www.squirrel-lang.org/)

It's basically Lua, with his complaints fixed.

------
stevekemp
I have to save I've loved using lua recently, in my console mail-client. Being
able to apply operations to messages, and do interesting things is great:

[http://lumail.org/examples/](http://lumail.org/examples/)

Sure there are warts, such as the lack of "+=" or "++", but once you get into
the right state of mind it is a pleasure to work with.

------
joaomsa
You get past most of these syntax nitpicks after a while. I wrote plenty of
Lua at my previous job, but every once in while would still forget about
globals by default. I really would love to know why they went ahead with that
design decision, when most languages take a far more conservative approach to
variable scoping.

~~~
kazagistar
Store the environment in "global" table. Make a new environment. Point the
__index of the new environment at the global table. Make __newindex of the new
environment a function that throws an error.

Congradulations, you have metaprogrammed lua to only set globals explicitly.
Good job!

------
mcv
Learning Lua reminded me a lot of Javascript. They're both weird languages
with a very similar object model, and they're both very practical once you get
past the initial hurdles. They both have some issues, but they also have
plenty of redeeming features.

------
anonymoushn
I wonder if he knows that he can write a loader to fix all this stuff.

