4 ms·
Forth is also quite amazing. I really enjoy both.
by herrosheep 8y ago
Forth is also quite amazing. I really enjoy both.
- blattimwind 8y agoLua always seemed somehow "right" to me (despite its numerous flaws, including one-based indexing), just like s-expressions somehow are just the right format for many kinds of data. You look at it and "just know". You understand it, the computer understands it effortlessly, and if you remove any element it stops making sense. One thing both of these have in common is that they are slightly different from mainstream ideas (e.g. C, Python, JSON, XML). Not so different it becomes alien, but different enough to make you approach it with a different state of mind.
- airstrike 8y agoI'm not a Lua user, so I thought I'd ask why one-based indexing is a flaw. As long as it's consistent, does it really matter? As someone who is forced to use VBA, it sounds like Lua could be worse
- jonsen 8y ago“Why numbering should start at zero”: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
- umanwizard 8y agoIf x is some object then x[k] is intuitively some object at distance "k" from the beginning of x. So the object right at the beginning is x[0].
- bunderbunder 8y agoI have spent limited time with Lua - mostly just fiddling with pico-8. My experience has been that it's fairly easy to get used to, but occasionally annoying. For example, it doesn't interact nicely with modular arithmetic the way 0-based indexing does.
- renox 8y agoBecause Lua is often used as an extension language of C++ which has 0-based indexing: it's really painful for programmers to switch from one indexing to another.
- ghusbands 8y agoIf you store a 2d array in a 1d one, it's natural to try/use x+200*y or such. With 0-based indexing it just works. With 1-based indexing, it's more complicated. If you do any modulus-based array access, 1-based indexing makes it more complicated. Basically, a world with 0-based indexing results in simpler math than a world with 1-based indexing, making it the better choice.
- samatman 8y agoI tend to consider one-based indexing Lua's only flaw, in fact. In particular for the LuaJIT dialect, since I'm less satisfied with the new paradigm for environments.
- sifoobar 8y agoThey have a lot in common, and there's no reason you can't have a bit of both at the same time: https://gitlab.com/sifoo/snigl https://gitlab.com/sifoo/snigl