Hacker News new | ask | show | jobs
by lisbbb 256 days ago
I worked with Lua for awhile but never got over the 1-based indexing.
2 comments

You'd get used to it eventually. Many of us had to go the other way. I grew up with BASIC and Wirth languages (Pascal, Modula-2, etc) that were 1-indexed and to this day even after 25, 30 years of working professionally in 0-based indexed languages I still catch myself here and there having to adjust (and whiteboard coding can sometimes throw me off under pressure), but clearly operate just fine.

I worked briefly professionally in Julia a couple years ago, which is 1-indexed, and I found it an easy transition, really. Many scientific computing things are 1-indexed, as Fortran was, too, among other reasons.

My own project is a rewrite / defibrilation of the 1990s LambdaMOO server (https://codeberg.org/timbran/moor/), which had its own OO programming language that was 1-indexed.

It's just not as "weird" as people think, I think it's just a generation of people grew up with C-derived languages and have grown to expect 0 as "normal" when it's really just "accident of history/popularity". I don't think it's objectionable that Lua chose 1-indexing, it is actually more "friendly" to newcomers to programming.

As Fortran is, not was.
Yeah fair enough. I was speaking more about historic influence. Fortran is still extensively used, but it was more influential 40 years ago than it is now.
You very seldon need to deal with it, most of your iterators are `pairs()` or `ipairs()` anyway. I like 1-based indexing and can deal with 0-based ones without any wart. I don't really get it why people make so much fuss, but then again if you feel it is a big problem, then there are plenty of other options that will suit you better.