News for hackers. Stuff that matters.
Re:A History of Lua (2001) by jhoechtl on Wednesday August 10, 2022 @05:21AM (#32409503)
Index by 1
Re:A History of Lua (2001) by remram on Wednesday August 10, 2022 @08:56AM (#32411124)
This was such a weird decision. Lua is meant to be embedded, meaning it will have to call application code where indexes start at 0. Why make the Lua indexes not match?
Re:A History of Lua (2001) by shadowofneptune on Wednesday August 10, 2022 @10:28AM (#32412569)
Some big influences on the syntax are Modula and Fortran. The first allows you to start an array with any index you like, the second starts it with one. As the article says, it started as a data language for engineers who may have been familiar with Fortran. The C-like languages were not as overwhelmingly common back when Lua started, as well.
Re:A History of Lua (2001) by pull_my_finger on Thursday August 11, 2022 @12:11AM (#32421502)
> When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around.

> And the arrays were exactly the same. It’s very funny that most people don’t realize that. There are good things about zero-based arrays as well as one-based arrays.

> The fact is that most popular languages today are zero-based because of C. They were kind of inspired by C. And the funny thing is that C doesn’t have indexing. So you can’t say that C indexes arrays from zero, because there is no indexing operation. C has pointer arithmetic, so zero in C is not an index, it’s an offset. And as an offset, it must be a zero — not because it has better mathematical properties or because it’s more natural, whatever.

> And all those languages that copied C, they do have indexes and don’t have pointer arithmetic. Java, JavaScript, etc., etc. — none of them have pointer arithmetic. So they just copied the zero, but it’s a completely different operation. They put zero for no reason at all — it’s like a cargo cult.

https://habr.com/en/company/vk/blog/459466/

Re:A History of Lua (2001) by renox on Wednesday August 10, 2022 @02:49PM (#32416724)
This. I was doing Ethernet packet assembly/disassembly with one part in C, the other in Lua.. Let's just say that I'm not a Lua fan to say the least.