TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

LUA is better than JavaScript

14 pointsby Ivoahover 8 years ago

10 comments

askariwaover 8 years ago
Please tell me this article is a hoax: This guy studies Computing Science and writes :<p>&quot;Javascript is written in Java and meant to script Java programs&quot;<p>&quot;Javascript only runs on the JVM, which is only available on web browsers. That is only one platform. LUA runs on any CPU that can run assembly code, since LUA was written in C which is portable assembly. It is more portable.&quot;<p>Just one comment : please study more.
评论 #13190211 未加载
评论 #13189364 未加载
评论 #13189584 未加载
rogualover 8 years ago
There&#x27;s a lot to like about Lua but the one thing that stops me taking it seriously is that it doesn&#x27;t have arrays or lists. Its only data structure is an infinite associative map (called a table), in which all keys map to the value &quot;nil&quot; unless otherwise set.<p>When you need a list, convention is to use a table with integer keys. But, the standard library functions dealing with these &quot;lists&quot; interpret the list as ending at the first element whose value is nil! There is no separate length field or anything (there was, but they took it out).<p>So, you can&#x27;t just trust that a list is a generic structure that can hold anything -- you need to be on the lookout for &quot;nil&quot;, because inserting it into a list truncates the list to that position.<p>There are many crazy workarounds for this: <a href="http:&#x2F;&#x2F;lua-users.org&#x2F;wiki&#x2F;StoringNilsInTables" rel="nofollow">http:&#x2F;&#x2F;lua-users.org&#x2F;wiki&#x2F;StoringNilsInTables</a><p>But my workaround is to just not use Lua, because as many warts as JS has, it has nothing as bad as that IMO. It&#x27;s a shame, because Lua is otherwise an excellent language.
davelnewtonover 8 years ago
I assume this is an attempt at parody.
tavish1over 8 years ago
What is this even. I think Lua is better too, but this article is really bad. Also it&#x27;s Lua, not LUA. I couldn&#x27;t even read it in full after spotting things like &quot;Javascript only runs on the JVM&quot; and &quot;Games are harder than web and programmers choose the best tool for the job, so LUA is a better tool and Javascript wouldn&#x27;t be able to handle it&quot;<p>EDIT: oh, I missed the first paragraph &quot;I want to note that the language is technically called &quot;Lua&quot; and the authors explicitly request people to refrain from calling it LUA, but I always shout whenever I say it in real life&quot;, good troll :|
enkiv2over 8 years ago
Lua is better than JavaScript, sure, but this article doesn&#x27;t make a convincing argument for that proposition. In fact, I might argue that it has a negative effect on any such arguments that may be posted, by virtue of association.
andrewmcwattersover 8 years ago
Lua is definitely better than JavaScript. Anyone well versed in both languages knows this, I&#x27;m undoubtably sure.<p>But I like that no one uses it. If people knew how much better Lua was over JavaScript, it might ruin the ecosystem with amateurs.
combatentropyover 8 years ago
This article is hilarious.
wahernover 8 years ago
<p><pre><code> LUA doesn&#x27;t have any of that functional baloney built into it like Javascript. It doesn&#x27;t have Objects either. Leave that cruft to Java, Javascript, and all the other clunky enterprise languages like them. Programming in LUA is the way it&#x27;s supposed to be, imperative. Conclusion: LUA is hardcore and lightweight, like C. </code></pre> Actually, Lua was intentionally designed to support functional programming and strong function composition. Lua supports proper tail calls and lexical closures. The former is necessary for functional programming, and the latter makes function composition easier as a practical matter, especially when you consider that...<p>... one of the beauties of Lua is that you can write &quot;Lua&quot; in either Lua or C. That is, the Lua language was designed so that the Lua C API was a first-class citizen. A Lua function written in C has full access to the power of lexical closures as well as stackful coroutines. (See the paper &quot;Passing a Language through the Eye of a Needle&quot; at <a href="http:&#x2F;&#x2F;queue.acm.org&#x2F;detail.cfm?id=1983083" rel="nofollow">http:&#x2F;&#x2F;queue.acm.org&#x2F;detail.cfm?id=1983083</a>) No other language benefits from such attention to detail in that regard. If you don&#x27;t understand the beauty of the Lua C API, then you don&#x27;t understand Lua.<p>Also, object oriented programming in Lua is prototype based, just like in JavaScript. But Lua is definitely hardcore and lightweight and fast, even though it&#x27;s a much more sophisticated language than both JavaScript and Python in terms of language abstractions.<p>I think people get the idea that Lua isn&#x27;t sophisticated because it&#x27;s so simple--that is, it has a small repertoire of language features, and the implementation is small and comprehensible. But that&#x27;s largely a product of the fact that while Lua is over 20 years old, it never committed to strong backwards compatibility.<p>Lua 5.3 is the product of decades of ruthlessly discarding failed experiments, and carefully introducing new experiments. And this shows if you pay close attention to the details of the language features, semantics, and API.<p>For example, look at Lua&#x27;s stackful coroutines. Some consider call&#x2F;cc (call with current continuations) the ideal abstraction, but Lua&#x27;s choice of asymmetric stackful coroutines was carefully considered. The paper 2004 paper &quot;Revisiting Coroutines&quot; (<a href="http:&#x2F;&#x2F;www.inf.puc-rio.br&#x2F;~roberto&#x2F;docs&#x2F;MCC15-04.pdf" rel="nofollow">http:&#x2F;&#x2F;www.inf.puc-rio.br&#x2F;~roberto&#x2F;docs&#x2F;MCC15-04.pdf</a>) by one of the Lua authors is widely cited in this area of language research and design.<p>Lua&#x27;s lack of backwards compatibility is a stumbling block for uptake. But it&#x27;s asymptotically approaching the perfect language of it&#x27;s kind (dynamically typed, etc). The period between major releases seems to be growing (5+ years now), and the changes fewer. The future is bright.
wwwhatcrackover 8 years ago
Is anything worse than javascript?
andrewmcwattersover 8 years ago
It&#x27;s Lua, not LUA. <a href="https:&#x2F;&#x2F;www.lua.org&#x2F;about.html#name" rel="nofollow">https:&#x2F;&#x2F;www.lua.org&#x2F;about.html#name</a>
评论 #13186873 未加载