News for hackers. Stuff that matters.
Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by __david__ on Sunday October 17, 2010 @05:11AM (#1799974)
I've sat down to learn Lua a number of times because on the I really like the idea of it (small, fast, safe, etc). It really has quite a beautiful minimalism to it.

But each time I try I get to the part where I learn that array indices start at 1 and I get annoyed. Have we not learned anything since BASIC? Sigh.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by tryp on Sunday October 17, 2010 @06:42AM (#1800072)
I found that adopting the native idioms meant never having to notice the 1- based indexing. Everything is a hash table, and if you find yourself using literal numeric keys, there's probably a nicer way to do it.

The lua users wiki is full of interesting ideas for tackling the basics in ways that leverage lua's simple flexibility.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by pederb72 on Sunday October 17, 2010 @11:50AM (#1800585)
Actually, Lua's table object is split into two parts. The array part, which is accessed using numerical indices, and the dictionary. It's done like that to enable fast array access, and I do find it an incredible useful feature in Lua.

In my experience 1-based indexing is not a problem when you're just writing Lua code. I've sometimes been frustrated when creating Lua bindings to C-modules which involved some kind of array access though.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by __david__ on Sunday October 17, 2010 @06:52AM (#1800084)
That is entirely possible. I can tell if someone doesn't know perl or python because they write for loops like a C coder instead of looping over containers. So I can believe that you don't come in contact with that detail very often.

It just bugs me that such an obvious wart exists in an otherwise very clean language.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by silentbicycle on Sunday October 17, 2010 @10:15AM (#1800360)
The reason the arrays index from 1 is that Lua is designed to pare down to a data description & configuration language for non-programmers, and they felt that starting arrays from zero would be confusing. I don't like it it either, but in practice it's a minor issue.

People who write off Lua because of indexing from 1, Python because of the significant whitespace, Lisp for its pares, etc. probably haven't gotten to the really interesting stuff yet.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by stcredzero on Sunday October 17, 2010 @09:19AM (#1800236)
Where "obvious" = something only someone with a foreign viewpoint thinks about.

("foreign" with regards to programming language.)

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by JulianMorrison on Sunday October 17, 2010 @05:35AM (#1800000)
What do you object to in counting from 1? (Other than it's not traditional.)

In C, it's an offset into a typed block of memory, so 0 indexing makes sense. But lua does not deal directly with memory.

Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by __david__ on Sunday October 17, 2010 @06:48AM (#1800079)
It has nothing to do with indexing memory--it has to do with 1 based arrays causing "+1" and "-1" to be sprinkled all oever the place. I find Dykstra's argument to be compelling: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
Re:Lua Doesn't Suck – Strange Loop 2010 20-minute talk video by kemayo on Sunday October 17, 2010 @12:18PM (#1800682)
My experience with Lua hasn't seen this problem materialize.