Lua: Good, bad, and ugly parts
notebook.kulchenko.com
notebook.kulchenko.com
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.
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
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.
I think Lua's 1-basedness is a valid complaint for embedders. It's not a huge problem, it can be worked around. However, if the Lua devs (or Mike Pall) decided tomorrow that from then on out, Lua(JIT) would use 0-based indexing by default, it would only make my work easier.
Zero works. One works. Zero works too.
>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.
I had a good laugh.
And now I am curious about javascript crazy + behavior.
both very interesting and very distracting, again.