

Lua: Good, bad, and ugly parts - nkurz
http://notebook.kulchenko.com/programming/lua-good-different-bad-and-ugly-parts

======
forkandwait
I have a new meta-pet-peeve: people who are peeved by one-indexing.

EDIT: I guess it went into his "differetn" category. Never mind....

Why is one-indexing at the top of his list of bad things, or even on a list of
things that matter? It is like getting stuck on adjectives after the noun...

My opinion, not widely shared here, is that 1-indexing is best for scripting
and math languages where 1-indexing corresponds directly to the subscripts in
the formulas. In Numpy etc, you have spend a lot of time converting those
formulas by subtracting one all over the place, introducing bugs and making
stuff less readable.

The only reason to use zero index is when, like in C, you are calculating your
distance from a memory boundary.

Sorry for the rant.

~~~
Pxtl
Dijsktra on zero-based indexing:

[http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...](http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html)

Obviously the differences are small and it's not worth obsessing over, but I
do think that zero-based approach works better with array code that involves
offsets... and that's not the exclusive province of manually managed memory -
array-index math can happen for many reasons.

Of course, one-based math is more intuitive to the layperson, which is
obviously why it's the natural choice for Lua.

~~~
endianswap
And for those who didn't see this on HN a couple of days ago, here's Guido van
Rossum on zero-based indexing in Python:
[https://plus.google.com/115212051037621986145/posts/YTUxbXYZ...](https://plus.google.com/115212051037621986145/posts/YTUxbXYZyfi)

------
copx
>Good: Portable: builds on any platform with an ANSI C compiler.

>Bad: No POSIX functions built-in.

This is an either/or thing. You cannot implement those functions in portable
ANSI C, it is platform-specific functionality. Also Lua is widely used on non-
POSIX platforms (e.g. Windows) and given that the Lua developers have removed
even most simple and basic functions like table.foreach in the past to keep
the language minimal I don't see them ever adding those. Personally I like it
this way.

~~~
lvh
There's a lot of great middle ground though; consider what Python does for
many of those APIs :)

~~~
Avshalom
well then you lose the smallness. That's also why the pattern matching isn't
quite regexp and about half of 'the bad' adding features adds size.

------
ANTSANTS
Previous submission:

[https://news.ycombinator.com/item?id=5348513](https://news.ycombinator.com/item?id=5348513)

~~~
sillysaurus2
Although this has absolutely nothing to do with the submission, I followed a
link from that thread, wound up at
[https://www.destroyallsoftware.com/talks/wat](https://www.destroyallsoftware.com/talks/wat)
and laughed for about five minutes straight. Thanks!

~~~
speeder
I am the one that should thank you for posting that link.

I had a good laugh.

And now I am curious about javascript crazy + behavior.

~~~
agumonkey
Gary Bernhardt is regularly guilty of these things, checkout this other talk
[http://www.confreaks.com/videos/615-cascadiaruby2011-the-
uni...](http://www.confreaks.com/videos/615-cascadiaruby2011-the-unix-
chainsaw)

both very interesting and very distracting, again.

