4 ms·
I completely disagree. Lua is SUCH a cleaner, faster, more consistent language than JavaScript, ESPECIALLY when considering how easy it is to embed in another a
by SomeCallMeTim 14y ago
I completely disagree. Lua is SUCH a cleaner, faster, more consistent language than JavaScript, ESPECIALLY when considering how easy it is to embed in another app (like binding it to PHP), that it's a no-brainer to use Lua. They were looking for speed, and LuaJIT is FAST; approaching C speed under the right circumstances.
What I'm sad about is that JavaScript is so locked-in on the browser that I can't use Lua there as well.
- azakai 14y agoI would agree that Lua is cleaner. But it is not perfect either, for example indexing starting at 1 is definitely an oddity. As for fast, I would love to see more comparisons on real-world code, there are too few on the web. It is easier to embed Lua than JavaScript, however, that's say a week of work, then you're done, so it isn't a reason for something like Wikipedia to prefer Lua. With all that said, Lua and JavaScript are both good languages, adding either one to Wikipedia is going to be a huge improvement. edit: looks like my phrasing has offended mikemike, who I have the utmost respect for, so I removed some stuff he disliked.
- bsg75 14y agoThe Lua index from 1 complaint is becoming the new Python whitespace gripe.
- deleted 14y ago[deleted]
- pjscott 14y agoAnd just like the Python whitespace thing, in practice it doesn't seem to be a problem after the first day or so. You get used to it quickly.
- gngeal 14y agoNot if your brain is used to doing modular arithmetics since childhood. :/ Python whitespace and Lisp parens seem trite in comparison to that. I just get 1-based indices more often wrong that I get 0-based indices wrong. (When doing things like "given an interval of indices a-to-b, partition it into n subintervals so that every element of the original interval is in precisely one of the sub-intervals, and the lengths of the intervals are either the same or as close to each other as possible", I find the "count from one, bounds are inclusive" model horrible. How do you express an interval from a with the length of zero? It's just <a,a) with half-open intervals. What, <a, a-1>? So many special cases with the <a, b> model...)
- dottrap 14y agoLuaJIT is being used in various commercial games. You may not see that real world code, but it is out there. Watch the YouTube video of the Wikipedia presentation linked elsewhere in this discussion. From the video, they picked Lua also because they could have multiple concurrent Lua states (no globals), easy to override the default memory allocators for security, Lua VM instances are very cheap and fast to create and launch, and the code base was small enough that their security guy could actually audit all the code (and they even submitted a patch). All these properties are hard to find with Javascript, but with Javascript, you have to go further and first decide which Javascript implementation to use. The ECMA spec says nothing about C interfaces or embedding so every Javascript engine (e.g. V8, JSCore, SpiderMonkey) is completely different. They also said they are using the standard Lua interpreter and not LuaJIT because stock Lua happened to already be really fast and fast enough for their purposes right now.
- azakai 14y ago> LuaJIT is being used in various commercial games. You may not see that real world code, but it is out there. I didn't say otherwise, I know LuaJIT is used. What I did say was I have not seen speed comparisons on such real-world code - but I would love to see a link if you have one. > and the code base was small enough that their security guy could actually audit all the code A small codebase is indeed good, but JavaScript VMs have very large teams of people working on hardening them, both reading and reviewing the code and applying methods like fuzzing to look for security problems. The fact is that JS VMs are likely the more hardened of anything out there, simply because they are used in web browsers. > with Javascript, you have to go further and first decide which Javascript implementation to use. Lua has at least two implementations as well, mainstream Lua and LuaJIT. > They also said they are using the standard Lua interpreter and not LuaJIT because stock Lua happened to already be really fast and fast enough for their purposes right now. That's cool.
- ufo 14y ago> Lua has at least two implementations as well The difference is that the Lua C API is standardized meaning that C code can work with either just fine. The only big incompatibility problem is that LuaJIT provides an extra, non-portable, FFI library in addition to the standard one.
- deleted 14y ago[deleted]
- azakai 14y agoBy all means please correct me when I am wrong. Is that limitation no longer correct? I can find that link to the v8 blogpost, if you want? edit: While I didn't mean them the way you interpreted them, I edited out the parts of my previous comment that you took offense to.
- copx 14y ago>for example indexing starting at 1 is definitely an oddity. Only to programmers raised in a C-based world. Normal people, mathematicians, and Lua start counting at 1. I remember when I was new to programming I was horribly annoyed by the fact that C started counting at 0 - that was so unnatural! (the BASIC I had used up until that point used 1-based indexing too) 0-based indexing is good for low-level code, for memory and screen addresses. For high level concepts starting at 1 is the natural choice. However, I admit after many years of C/C++ I was quite irritated by everything starting at 1 by default. My brain adapted after a few days, though. I think the Lua devs made the right choice with the 1-based indexing. Just like 0-based indexing was the right choice for C. As I said both ways are natural but in different scenarios: 0-based for low-level machine code, 1-based for high level human concepts.
- azakai 14y ago> Only to programmers raised in a C-based world. Normal people, mathematicians, and Lua start counting at 1. I mostly agree, except for mathematicians ;) , where it depends on the context. For example aleph numbers start at 0, http://en.wikipedia.org/wiki/Aleph_number http://en.wikipedia.org/wiki/Aleph_number and even the natural numbers can start at 0 or 1, http://en.wikipedia.org/wiki/Natural_number http://en.wikipedia.org/wiki/Natural_number
- SomeCallMeTim 14y agoI think the key here is that people ALWAYS complain about Lua indexing from one. Aside from that, not having a huge standard library is the second complaint. There are debates that come up all the time on the Lua list about what would be best, but I think those are really the main complaints people have. Large standard libraries would mean huge potential for security holes in this case; they've locked features down to only support things that they could make secure. And starting from 1 you can get used to. LuaJIT doesn't even REQUIRE you start from 1; it'll optimize arrays you start from zero. And even vanilla Lua will accept 0 as a table index; it just won't treat it as an array (for ipairs() or length). But if you start asking people for complaints about JavaScript, you will find people complaining about operators acting wonky, auto-type-conversion problems from hell, and even odder things like [1]. Lua is just a cleaner design. I am stuck using JavaScript when I want to work on the web, but knowing what an elegant language CAN be makes me enjoy it a lot less. And don't get me started on how ugly NodeJS is because JavaScript doesn't have coroutines... [1] https://news.ycombinator.com/item?id=3401074 https://news.ycombinator.com/item?id=3401074