Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No basic string manipulation, only RE-based stuff.

One-based indices instead of zero-based.



> No basic string manipulation, only RE-based stuff

It's trivial to write, there are lots of libraries that do this. I've worked on a lot of string processing code in Lua. It's not as easy as Perl or Ruby but it's not by any means hard.

> One-based indices instead of zero-based.

Other than violating the expectations of people used to other C-like languages, this is not in any way even remotely a problem. I don't know anybody who's spent any significant time with Lua who regards this as more than a minor detail.


These are pitfalls and usability concerns. Languages that make you actively work against the nature of the language are not good; programming languages should be making this stuff easy.

One-based indices stop being a "minor detail" as soon as you realize that out-of-bounds indexing doesn't fail, but returns nil. Time to re-examine all of your code. Combine this with the natural mathematical awkwardness of one-based indices and it can get really frustrating, really fast.

I had to do Lua for some game design stuff a few years ago, and these were the two things which stuck out at me almost immediately and bothered me during the entire ordeal. Maybe I've been spoiled by Python, Perl, Java, C++, C, and other languages, but it's deeply frustrating how wrong Lua is about this.


Lua is not perfect. But saying you shouldn't use it because of 1-based indexes is an overreaction.

> Maybe I've been spoiled by Python, Perl, Java, C++, C, and other languages

Probably. :)

One of Lua's main goals is to provide a language easy for beginners to use for small tasks. This affects its design in some other rather annoying ways (like for example, variables being global by default rather than local) but they were pretty carefully made decisions.

The context of this thread is, "what could be a good replacement for PHP?" I think because Lua aims to be easy for inexperienced programmers, it's a rather good choice, even if some of its characteristics can be surprising or annoying to established developers experienced with other languages.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: