2 ms·
I agree with your argument about 1-based indexing being more intuitive for people with more math than programming experience. I'd even concede that, given Lua's
by ANTSANTS 13y ago
I agree with your argument about 1-based indexing being more intuitive for people with more math than programming experience. I'd even concede that, given Lua's history (as I understand it) as a tool for engineers at PUC-Rio, it would be strange if they hadn't adopted that convention. Lua is not just any "scripting" language trying to isolate itself from the rest of the world, though. Today it is arguably the most popular language for embedding purposes. It's typically used in reasonably large C or C++-based applications as a layer of easily and dynamically reconfigurable glue between components. As such, a large portion of its users are directly involved in maintaining the interface between the C and Lua worlds in their programs, to a much greater extent than with most other dynamic languages. Differing from C's convention for any reason is a small but constant source of annoyance and occasional bugs when working at this level. You accept the difference and learn to work around it, but it's yet another dumb-mistake-causing source of unnecessary cognitive load that seems out of place in a language mostly free of that characteristic.
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.