3

Javascript is nice, but for the better performance, why web browser(ie/chrome,firefox,safari) do not add lua vm? or make lua vm become a part of web browser standard?

Welcome any comment

greatwolf
  • 20,287
  • 13
  • 71
  • 105
arachide
  • 8,006
  • 18
  • 71
  • 134
  • 4
    Chrome and FF are open source, feel free to submit a patch :) – Mike Christensen Aug 11 '12 at 01:34
  • Question is closed, but (I suppose) the reason is: Lua is not suitable for browsers because it allows for things which should not be allowed in browsers, e.g. blocking code. Completely new Lua variant would have to be developed, then standarized and adopted. Creating languages which compile to JavaScript (like CoffeeScript) is easier and safer. – skalee Mar 06 '13 at 01:07
  • Note that `` is possible with [Fengari-web](https://github.com/fengari-lua/fengari-web) – sondra.kinsey May 15 '19 at 13:08

1 Answers1

2

Because today's JIT compilers for Javascript are just as fast, if not faster than, JIT engines for Lua.

The web experimented with different client-scripting languages in the mid-1990s (when we had LiveScript (an early JavaScript), VBScript (thank you, Microsoft), as well as Tcl. The web decided it didn't like that and we settled on a single language (JavaScript, now EcmaScript).

Lua offers no real advantages and introduces a massive workload (the DOM API would need to be implemented, for example, and Lua has different semantics to EcmaScript (with respect to typing and how functions work, amongst other things) so the majority of web developers would need to relearn their trade.

There just isn't a business case in it.

Dai
  • 141,631
  • 28
  • 261
  • 374
  • 4
    What you say is untrue. Lua JIT compiler is the fastest JIT compiler so far. It beats V8 hands down. – Konstantin Solomatov Feb 02 '13 at 21:28
  • 1
    Citation needed. This website shows that LuaJIT is considerably slower than V8: http://benchmarksgame.alioth.debian.org/u32/benchmark.php?test=all&lang=lua&lang2=v8 – Dai Feb 04 '13 at 07:48
  • 3
    It's not LuaJIT, it's lua interpreter. The author of shootout decided to drop LuaJIT. – Konstantin Solomatov Feb 04 '13 at 12:21
  • See citation, for example, here: http://attractivechaos.wordpress.com/2011/01/23/amazed-by-luajit/ – Konstantin Solomatov Feb 04 '13 at 12:22
  • That page is over 2 years old. The latest benchmark page linked to by the original article shows that V8 is now faster than LuaJIT: http://benchmarksgame.alioth.debian.org/u64/which-programs-are-fastest.php?gcc=on&csharp=on&v8=on&lua=on&calc=chart Please remove your downvote. – Dai Feb 05 '13 at 06:37
  • If you take a look at the link which you pointed me ot, you will see that they used original Lua interpreter instead of LuaJIT. – Konstantin Solomatov Feb 05 '13 at 12:28
  • 3
    Actually, neither of you is right. You can't say X is faster than Y, you can only say X is faster than Y in *executing particular algorithm*. Lua has several optimizations which are impossible in JavaScript, e.g. tail call elimination ([more](http://stackoverflow.com/questions/3660577/are-any-javascript-engines-tail-call-optimized)). Some benchmarks will say Lua is faster than another ones will say the opposite. – skalee Mar 06 '13 at 00:58
  • 1
    Your "facts" and "well-thought out reasoning" have no place in a StackOverflow comments area! – Dai Mar 06 '13 at 07:18
  • Lua-Jit is WAY faster than normal Lua ;) – Stolas Jun 18 '13 at 09:55
  • 3
    I disagree with the statement that Lua offers no real advantages to JavaScript. LuaJIT's superior speed and smaller memory usage compared to V8 were some of the reasons Tim Caswell cited for porting node.js to Lua in the Luvit project. It's just a simpler language, so it has the opportunity to be faster. –  Nov 25 '13 at 21:18