News for hackers. Stuff that matters.
Re: Why are we limited to JS in browsers - would a bytecode ... by Groxx on Thursday November 11, 2010 @09:25AM (#1893880)
In all honesty... what's the difference?

Turing complete language ≈ Turing complete language. Just make something to compile your language of choice into JavaScript, or make a new one (CoffeeScript). Bytecode is just a little more dense, little faster executing, far harder to investigate language than JavaScript, which the browser can compile for added speed anyway.

I prefer my language-of-the-web to be readable, thanks. Then I can find out wtf it's doing. And where you really need speed, native client is just about your only option.

Re: Why are we limited to JS in browsers - would a bytecode ... by jules on Thursday November 11, 2010 @09:36AM (#1893908)
The difference is that Javascript is about the worst possible IL for a compiler to compile down to. Yeah you can recover some of the speed by spending man years on making Javascript execute somewhat fast.

As a bytecode you wouldn't use a bytecode that is targeted at handling Javascript constructs. You'd use a bytecode that, for example, supports machine integers (unlike Javascript). Something that allows you to allocate objects, rather than string indexed hash tables. Something that allows you to allocate an array of floats, rather than an array of boxed floats.

Re: Why are we limited to JS in browsers - would a bytecode ... by InclinedPlane on Thursday November 11, 2010 @11:46AM (#1894301)
"Worst possible"? Sub-optimal perhaps, but Javascript is becoming very fast in the browser, perhaps it's not such a bad choice after all.
Re: Why are we limited to JS in browsers - would a bytecode ... by jules on Thursday November 11, 2010 @12:08PM (#1894408)
With enough effort you can put lipstick on a pig. But really, an IL that doesn't support integers? An IL where a member field access may involve looking up a string in a hash table instead of being a single machine instruction? Propose that as an IL to a compiler guy and they'll laugh at you. Javascript is an historical accident. Let's look at some alternatives if history was different:

- Scheme: this would have been a much better choice, because it supports integers and has a compact object representation instead of representing everything with hash tables. Bad point: all objects are boxed (like in JS). Good point: tail calls are handy when compiling all kinds of control structures.

- Java: As an IL to compile down to this would have been better than Javascript. Good points on top of Scheme: unboxed primitive types, static typing means fewer runtime checks. Bad point: lack of tail calls.

- ML: excellent choice: has both unboxed primitives and tail calls.

I challenge you to find a language that would have been a worse choice than Javascript. It may turn out that by working really hard on smart runtimes and compilers you can get OKish performance out of Javascript in some cases, but that doesn't mean that it's a good choice for an intermediate language. A ML compiler that just translates to LLVM IL as simply as possible without doing any optimizations itself will easily beat the highly optimized Javascript engines we have today.

Re: Why are we limited to JS in browsers - would a bytecode ... by Robin_Message on Thursday November 11, 2010 @12:47PM (#1894560)
Just to note though: Javascript in fact doesn't require representing objects as hash tables. For example, the V8 javascript engine represents objects as instances of classes, more or less exactly how C++ would do it (the build the class definitions automatically in the background.)

You are right on integers though, and other types of memory block in general, they are trickier to fix in a javascript engine. Surely the best IL is LLVM IL though, since it was designed so everything can compile down to it.

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @01:22PM (#1894679)
> Just to note though: Javascript in fact doesn't require representing objects as hash tables. For example, the V8 javascript engine represents objects as instances of classes, more or less exactly how C++ would do it (the build the class definitions automatically in the background.)

That sounds like what Self does, too. See the excellent paper, "An Efficient Implementation of SELF" (http://selflanguage.org/documentation/published/implementati...).

The Self bibliography page (http://selflanguage.org/documentation/published/index.html) has a lot of other content applicable to dynamic languages in general, too.

Re: Why are we limited to JS in browsers - would a bytecode ... by wmf on Thursday November 11, 2010 @01:52PM (#1894767)
Self and V8 are connected through Lars Bak. http://en.wikipedia.org/wiki/Lars_Bak_(computer_programmer)
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @02:00PM (#1894795)
He worked on Beta / Mjølner, too. Neat!
Re: Why are we limited to JS in browsers - would a bytecode ... by jules on Thursday November 11, 2010 @02:02PM (#1894806)
Yep, sophisticated implementations try to infer the patterns in which objects occur and then dynamically generate classes for them. However this is not without problems, because if you assign to a new slot then you need to change the object's class, it needs to gracefully degrade to when the objects are used as hash tables, etc.

LLVM IL would be excellent for speed. The problem is that it's not memory safe (i.e. it allows reading and writing to arbitrary memory locations). NativeClient at Google is trying to solve that. http://code.google.com/p/nativeclient/

Re: Why are we limited to JS in browsers - would a bytecode ... by bd on Thursday November 11, 2010 @04:40PM (#1895389)
"But really, an IL that doesn't support integers? An IL where a member field access may involve looking up a string in a hash table instead of being a single machine instruction? Propose that as an IL to a compiler guy and they'll laugh at you."

Yup, JS arrays look crazy when you are used to C and pointers (I was shocked when I first found out).

That's why WebGL folks had to come up with typed arrays:

https://cvs.khronos.org/svn/repos/registry/trunk/public/webg...

http://weblog.bocoup.com/javascript-typed-arrays

Re: Why are we limited to JS in browsers - would a bytecode ... by sedachv on Thursday November 11, 2010 @04:50PM (#1895435)
"- Scheme: this would have been a much better choice, because it supports integers and has a compact object representation instead of representing everything with hash tables. Bad point: all objects are boxed (like in JS). Good point: tail calls are handy when compiling all kinds of control structures."

The boxing part is untrue. Even on 32-bit systems (that have word-aligned addressing, which all current 32-bit systems do), you can get 6 arbitrary type tags by using up the three least significant bits of a pointer (6 and not 8 because you use up two of the possible tag values for even/odd immediate integers (fixnums)).

Tail calls are overrated, maybe you're thinking about continuations? Those would have been truly terrible - you get all the downsides of concurrency with no benefits. One of the reasons arbitrary crap JS code runs as well as it does is because there's no possibility of concurrency. The browser event-loop model is a good one.

"- Java: As an IL to compile down to this would have been better than Javascript. Good points on top of Scheme: unboxed primitive types, static typing means fewer runtime checks."

Don't forget: getting sued by Oracle.

Java blows in every way compared to JavaScript. If Netscape had put Java instead of JS into Navigator the web would be a very different place today, because no one would have used it [Java].

"ML: excellent choice: has both unboxed primitives and tail calls."

In 1995? Give me a break, or a time machine.

Re: Why are we limited to JS in browsers - would a bytecode ... by jules on Thursday November 11, 2010 @05:12PM (#1895520)
> The boxing part is untrue.

You're right. Scheme implementations usually have unboxed fixnums and other types. However Scheme systems do not usually support user defined unboxed objects, like C#, C and ML do.

> Tail calls are overrated, maybe you're thinking about continuations? Those would have been truly terrible

I agree, I did mean tail calls. Tail calls may not be so good for programming with, but they are good for compiling to, because you can easily encode your control structures like while, for, until, state machines and more exotic forms of looping to them. You can also compile (parts of) code in continuation passing style without blowing the stack, which is hard to do efficiently if you don't have tail calls.

The reverse is not true, you cannot easily express tail calls on top of the usual control structures like while. This is why Scala and Clojure still don't have support for tail calls.

> Java blows in every way compared to JavaScript. If Netscape had put Java instead of JS into Navigator the web would be a very different place today, because no one would have used it [Java].

I'm not arguing that Java is better than Javascript for programming in. It's just a better target for compilers.

> In 1995? Give me a break, or a time machine.

Do you have any arguments to back up why ML would not be a better IL than JS?

It seems to me that you are arguing that these languages are not better than JS for programming in, but that is not what I claimed.

Re: Why are we limited to JS in browsers - would a bytecode ... by sedachv on Friday November 12, 2010 @03:55PM (#1899243)
"You're right. Scheme implementations usually have unboxed fixnums and other types. However Scheme systems do not usually support user defined unboxed objects, like C#, C and ML do."

That's because Scheme has to support type safety for arbitrary code loaded at run-time. Exactly like JavaScript has to do when the web browser GETs a script. Exactly what any of the other proposed ILs would have to do as well.

"I agree, I did mean tail calls. Tail calls may not be so good for programming with, but they are good for compiling to, because you can easily encode your control structures like while, for, until, state machines and more exotic forms of looping to them. You can also compile (parts of) code in continuation passing style without blowing the stack, which is hard to do efficiently if you don't have tail calls.

The reverse is not true, you cannot easily express tail calls on top of the usual control structures like while. This is why Scala and Clojure still don't have support for tail calls."

A better argument can be made for gotos than tail calls in this case. JavaScript already has gotos in the form of labels and break.

Tail call faking doesn't always have to have a trampoline overhead cost. Take a look at Scheme2JS for how they do it (http://www-sop.inria.fr/indes/scheme2js/)

"I'm not arguing that Java is better than Javascript for programming in. It's just a better target for compilers."

JavaScript provides run-time types and extensive reflection and introspection facilities. This makes it relatively straightforward to write something like Parenscript. OTOH trying to compile even a static subset of Common Lisp to C or Java is pretty complicated.

"Do you have any arguments to back up why ML would not be a better IL than JS?"

Your original statement was: "I challenge you to find a language that would have been a worse choice than Javascript." Given the state of ML implementations in 1995, I think it would have been a worse choice.

"It seems to me that you are arguing that these languages are not better than JS for programming in, but that is not what I claimed."

And you seriously think people would have first run out and built compilers from other languages to the "hypothetical better than JavaScript" language rather than use the latter directly? Because that's not what actually happened.

Re: Why are we limited to JS in browsers - would a bytecode ... by sedachv on Friday November 12, 2010 @09:20PM (#1900030)
"JavaScript already has gotos in the form of labels and break."

Actually, no, it doesn't. I don't know anything about JavaScript.

Re: Why are we limited to JS in browsers - would a bytecode ... by InclinedPlane on Thursday November 11, 2010 @02:16PM (#1894862)
x86 was a historical accident, and yet it has become the most popular architecture for personal computers and servers in history.

There are plenty of examples of languages that are worse than Javascript for the web. Java being a perfect example. Java and Javascript co-existed on the web for quite some time (in theory they still do). Java is based on a "proper" IL. And yet here we are, talking about some hypothetical new IL to replace Javascript, despite the fact that there is no guarantee it would actually be better, as the historical example of Java has shown us.

You need to get more than just the VM "right", there's a billion other factors, Java screwed up, Javascript hit the mark (despite its many other flaws). Perhaps LLVM is the future of web applications, it's too soon to tell. What I do know is that Javascript may not be perfect but it's still fundamentally good, and powerful enough (largely through closures and prototypes) to allow for robust workarounds to its flaws (jQuery, coffeescript, etc.)

Re: Why are we limited to JS in browsers - would a bytecode ... by cpr on Thursday November 11, 2010 @01:53PM (#1894772)
"Worse is better." (Google it.)

Javascript is a good enough (New Jersey-style) solution.

Why "fix" it?

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @07:11PM (#1895947)
Worse is Better doesn't quite fit here. WiB is about getting a "basically right" prototype out, and then improving it with real world feedback, rather than waiting forever to have a perfect 1.0.

With Javascript, unfortunately, it didn't work out so well - a bunch of early bugs (which could have been quickly fixed) were preserved when Microsoft made a bug-compatible clone for IE, and then became part of the ECMAScript standard in 1996. This derailed efforts to improve the language - there is a lot of work on sophisticated implementations now, but the spec itself is buggy.

People invoke "Worse is Better" as retroactive justification for all kinds of engineering blunders, but it's a bit more limited in scope. Here you go: http://www.jwz.org/doc/worse-is-better.html

Re: Why are we limited to JS in browsers - would a bytecode ... by cpr on Thursday November 11, 2010 @07:29PM (#1896000)
I respectfully disagree. "Worse is better" originally applied to the Bell Labs Unix efforts vs the Lisp Machine efforts at MIT and elsewhere.

Unix didn't get "fixed" later.

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @07:48PM (#1896052)
Actually, I think you're right - Javascript was frozen very early and Unix had a while to develop, but the same forces (competing commercial implementations) locked in minor errors in Unix as well.

I'd say Unix got more of its warts fixed than JS did, but that's only a difference of degree.

Mainly: The whole "Worse is Better" thing works better when you don't get stuck maintaining reverse compatibility with your early releases.

Re: Why are we limited to JS in browsers - would a bytecode ... by InclinedPlane on Thursday November 11, 2010 @08:25PM (#1896148)
I'd say Unix and C have more warts, and more serious warts, than Javascript does. But we have come to accept those warts in Unix and C as "the way things are" whereas we generally perceive javascripts warts as such. Arguably the decision to use null-terminated strings in C in order to save one or two bytes of memory per string is an error of much greater than Y2K proportions that we are still paying for.
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Friday November 12, 2010 @12:20AM (#1896626)
Agreed, though I think most of Unix's serious warts are actually C's. They're synergistic, though.
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Friday November 12, 2010 @03:17PM (#1899088)
(Oops: I meant 'symbiotic'.)
Re: Why are we limited to JS in browsers - would a bytecode ... by jrockway on Thursday November 11, 2010 @10:26PM (#1896414)
Unix didn't get "fixed" later.

When did Unix get fixed?

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @11:59PM (#1896579)
You need to be pun-ished.
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @01:28PM (#1894705)
Tcl would have been worse, probably.
Re: Why are we limited to JS in browsers - would a bytecode ... by TNO on Thursday November 11, 2010 @07:34PM (#1896011)
VBScript
Re: Why are we limited to JS in browsers - would a bytecode ... by blasdel on Friday November 12, 2010 @05:26PM (#1899550)
Except that VBScript is implemented as a DOM scripting language in IE!

I've had several mid-end managed switches where the web configuration UI used it and was unusable outside of IE with no sign as to why unless you read the source.

Re: Why are we limited to JS in browsers - would a bytecode ... by gloob on Thursday November 11, 2010 @05:42PM (#1895636)
Or sed.
Re: Why are we limited to JS in browsers - would a bytecode ... by wmf on Thursday November 11, 2010 @01:48PM (#1894754)
As a bytecode you wouldn't use a bytecode that is targeted at handling Javascript constructs.

So now you're asking the browsers to support two different VMs; one for JS and another one. Standardizing bytecode for JS (perhaps based on the existing Nitro or JagerMonkey bytecode) would be much less work.

Re: Why are we limited to JS in browsers - would a bytecode ... by ianb on Thursday November 11, 2010 @04:08PM (#1895255)
The browser provides very high level constructs (e.g., the DOM), handling numbers quickly is uninteresting and would be a poor direction for optimization. While I think an appropriate VM could be something interesting, I doubt an appropriate VM in this case would look like the JVM.
Re: Why are we limited to JS in browsers - would a bytecode ... by pcarmichael on Thursday November 11, 2010 @09:55AM (#1893968)
One difference is in compiler optimizations. For a given language, compilers can often make inferences based on the code and the semantics of the language, allowing for very targeted optimizations. If you go from LanguageFoo -> Javascript -> bytecode, then you may be limiting the range of optimizations possible (because Javascript may not be able to infer the same things about the code, be it because of program structure, language semantics, etc.)
Re: Why are we limited to JS in browsers - would a bytecode ... by m0th87 on Thursday November 11, 2010 @10:17AM (#1894033)
The same holds true with bytecodes. e.g. TCO on the JVM: http://stackoverflow.com/questions/105834/does-the-jvm-preve...
Re: Why are we limited to JS in browsers - would a bytecode ... by robhu on Thursday November 11, 2010 @11:38AM (#1894264)
Why not make the 'byte code' the LLVM IF ? That way you leverage all the stuff from the LLVM project for making it go fast.

The main thing to do then is just to have a front end for your favourite language the outputs LLVM IF.

Re: Why are we limited to JS in browsers - would a bytecode ... by wmf on Thursday November 11, 2010 @01:49PM (#1894757)
Google's working on that: http://nativeclient.googlecode.com/svn/data/site/pnacl.pdf

(Edit: I see that several other people already mentioned PNaCl further down in the thread. A hazard of HN's sorting, I guess.)

Re: Why are we limited to JS in browsers - would a bytecode ... by dkersten on Tuesday November 23, 2010 @12:45PM (#1934590)
LLVM bitcode is processor specific. Not sure where, but I saw that mentioned in the LLVM docs.
Re: Why are we limited to JS in browsers - would a bytecode ... by scott_s on Thursday November 11, 2010 @11:51AM (#1894326)
I don't think you understand the proposal: JavaScript would still be the language of the web. The things you don't see would just be handled differently.

In fact, it would be easier to to "find out wtf it's doing" because something that is now ad-hoc - what to do with the JS given to a browser - would be standardized. Keep in mind that the browsers already do something to your JS, either compile it to byte-code for the browsers own VM, or compile it directly to machine code. This proposal would standardize what the intermediate representation would be.

Re: Why are we limited to JS in browsers - would a bytecode ... by robhu on Thursday November 11, 2010 @01:04PM (#1894620)
No, the idea is that you could compile whatever language you like into byte code that would then run in the browser.

Javascript might still be the main language on the web (and would probably continue to be handled in the same way it is now) but you could also use other languages.

Re: Why are we limited to JS in browsers - would a bytecode ... by scott_s on Thursday November 11, 2010 @01:19PM (#1894669)
For reasons that silentbicycle presents elsewhere in this thread, that goal is quite difficult. The benefits I mentioned above would be true even if no other languages compiled down to the standardized byte-code - we'd have the above benefits first.
Re: Why are we limited to JS in browsers - would a bytecode ... by kristiandupont on Thursday November 11, 2010 @09:41AM (#1893927)
Well, you would be developing with plain javascript or symbols just like when writing native code. And besides, minified javascript might be more readable than bytecode but just barely.
Re: Why are we limited to JS in browsers - would a bytecode ... by tomjen3 on Thursday November 11, 2010 @09:32AM (#1893896)
The difference is that Javascript is a crappy language and I resent having to write in it. In addition, it lacks types and is therefore slower and does not execute the same way on all platforms.
Re: Why are we limited to JS in browsers - would a bytecode ... by lincolnq on Thursday November 11, 2010 @09:41AM (#1893928)
Then why don't you treat your JavaScript as object code, and compile a language you like better to it?

It does not lack types (it just lacks static type checking); it is not significantly slower (JavaScript JIT is very advanced, and you're not compute-bound in JavaScript). And "it does not execute the same way on all platforms" is true for pretty much all languages on all platforms, so I don't know what you're getting at.

If you'd like a better language I can suggest CoffeeScript and ghcjs.

Re: Why are we limited to JS in browsers - would a bytecode ... by skybrian on Thursday November 11, 2010 @10:45AM (#1894116)
JavaScript lacks 64-bit integers and binary data, just for starters. You can emulate these things (GWT does) but not efficiently.

Byte code isn't necessarily the solution though. It might be a good idea to add these types directly to JavaScript, so they're usable both directly and as an object language.

Re: Why are we limited to JS in browsers - would a bytecode ... by lincolnq on Thursday November 11, 2010 @11:06AM (#1894180)
Yes, it's true that it's utterly ridiculous that JS doesn't have integers. That's a definite lack of foresight on the part of the ECMAScript authors.
Re: Why are we limited to JS in browsers - would a bytecode ... by chrisaycock on Thursday November 11, 2010 @10:48AM (#1894130)
We can add Skulpt (Python) to that list too.
Re: Why are we limited to JS in browsers - would a bytecode ... by Groxx on Thursday November 11, 2010 @09:36AM (#1893907)
Not the same on all platforms is a wholly legitimate complaint. It's frickin' annoying that browsers don't all implement the same language.

But bytecode won't solve that. IE will still refuse to implement subset-X, WebKit will still prefix their CSS with -webkit, etc. Until everything settles down and decides on one implementation, in which case I'd still prefer to be able to read what the web is sending to me.

Re: Why are we limited to JS in browsers - would a bytecode ... by exit on Thursday November 11, 2010 @09:56AM (#1893977)
minified js isn't much more readable than bytecode
Re: Why are we limited to JS in browsers - would a bytecode ... by haribilalic on Thursday November 11, 2010 @09:38AM (#1893911)
Crappy is subjective. I actually like JavaScript.

JavaScript, although dynamic and loosely typed, does have types: string, number, object (including array, function and date), null and undefined are all JavaScript types.

Re: Why are we limited to JS in browsers - would a bytecode ... by kenjackson on Thursday November 11, 2010 @02:26PM (#1894904)
IMO, the issue isn't if you like Javascript or not. It is is Javascript a reasonable language for compilers to target.

I think the core proposal is that Javascript stays the defacto language of the web, but you build a standardized IL that all browsers target. Of course Javascript would be one of the core languages that would guide the design of the IL, because you don't want this new IL and Javascript to incompatible.

The nice thing though is after you do that, other people can write new languages that target that IL, and they're not second-class citizens. It allows there to be real language innovation on the IL, just as there is language innovation on x86.

The problem today is that JS is not a great language to target, and it relegates anything that targets it to second-class status (why are you using XYZ, why not just use Javascript?).

I think its a great idea. IMO, this would be a far more important development than HTML5 for the life of the web.

Re: Why are we limited to JS in browsers - would a bytecode ... by brainlock on Thursday November 11, 2010 @09:57AM (#1893982)
I'd add that it has functions as first-class citizens and closures. Javascript has for sure some crappy parts, but there is also a lot of good in it.
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @10:03AM (#1893999)
I find Javascript depressing. If it had a few more years to develop, it could have been a really great language. I understand why it wound up that way, but, sigh.

If you want to see a much better language with the same general design, look at Lua. It's made for scripting C programs rather than web pages, and it has had over a decade longer to mature.

Re: Why are we limited to JS in browsers - would a bytecode ... by haribilalic on Thursday November 11, 2010 @10:18AM (#1894038)
JavaScript was released in 1995 as part of Netscape Navigator 2.0. Lua was released in 1993. I don't know about a decade.
Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @10:40AM (#1894101)
Lua has been able to make major, reverses-compatibility breaking changes to improve its design in ways Javascript hasn't. Where Javascript has "The Good Parts" and incrementally improving implementations, Lua has been able to fix things and evolve.

"One thing Mike [Pall] didn't highlight: get a simpler language. Lua is much simpler than JS." - Brendan Eich (http://lambda-the-ultimate.org/node/3851#comment-57671)

Re: Why are we limited to JS in browsers - would a bytecode ... by dkersten on Tuesday November 23, 2010 @01:04PM (#1934658)
Lua (without JIT) is also one of the fastest non-JIT, non-native compiled languages there is. LuaJIT is also one of the faster JIT languages. Now, I'm not sure how it compares to the popular JS JIT engines, but from what I've read, its very hard to beat LuaJIT for performance.
Re: Why are we limited to JS in browsers - would a bytecode ... by didip on Thursday November 11, 2010 @11:38AM (#1894265)
If only Netscape just pick up Lua or Python instead of creating a language in a rush.
Re: Why are we limited to JS in browsers - would a bytecode ... by BrendanEich on Sunday November 14, 2010 @10:58PM (#1905155)
I've talked and written recently about why "just pick[ing] up Lua or Python" was not an option, but there are other strong reasons that was not in the cards.

Think about what mid-1990s Lua and Python were like, how much they needed to change in incompatible ways. The web browsers would never have tolerated that -- you'd get a fly-in-amber-from-1995-or-1996 version of Python or Lua, forced into a standards body such as Ecma (then ECMA), and then evolved slowly _a la_ ECMA-262 editions 2, 3, and (much later, after the big ES4 fight) edition 5.

Interoperation is hard, extant C Python and Lua runtimes were OS-dependent and as full of security holes, if not more full, than JS in early browsers, and yet these languages and others such as Perl were also destined to evolve rapidly in their virtuously-cycling open source communities, including server-side Linux and the BSDs (also games, especially in Lua's case -- Python too, but note the forking if not fly-in-amber effects: Stackless Python in Eve Online, e.g.).

JS, in contrast, after stagnation, has emerged with new, often rapidly interoperating, de-facto (getters, setters, array extras, JSON) and now de-jure (ES5) standards, the latter a detailed spec that far surpasses C and Scheme, say, in level of detail (for interop -- C and Scheme favor optimizing compiler writers and underspecify on purpose, e.g. order of evaluation).

The other languages you cite have been defined normatively over most or all of their evolving lives entirely by what their C implementations do. Code as spec, single source implementations do not cut it on the web, what with multiple competing open- and closed-source browsers.

Re: Why are we limited to JS in browsers - would a bytecode ... by mascarenhas on Thursday November 11, 2010 @01:02PM (#1894613)
You have to compare Lua at 1995 (version 2) to JavaScript at 1995, as its development, at least inside the browser, would be arrested the same way JavaScript's was. Lua 2 was certainly had a much better implementation than the first JavaScript, but I would not call it a better language (didn't have JavaScript's annoying quirks, but also didn't have closures, for example). 2000's Lua (5.0 and 5.1) is quite different from its earlier incarnations.
Re: Why are we limited to JS in browsers - would a bytecode ... by cpr on Thursday November 11, 2010 @01:56PM (#1894782)
I find Lua depressing and Javascript exciting. So where does that leave us?

If it's all a matter of taste as to what's desirable in a "mature" language, your argument doesn't go very far.

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @02:01PM (#1894802)
I'm mostly thinking about how many of the problems highlighted in "Javscript: The Good Parts" have been fixed in Lua, while Javascript can't be fixed. Not a matter of design and taste, but outright bugs.
Re: Why are we limited to JS in browsers - would a bytecode ... by cpr on Thursday November 11, 2010 @04:35PM (#1895367)
OK, don't use the "bad parts."

But it's a lot more than that. It's the "taste" of the language itself, and Javascript tastes much more like the kind of language I like using.

Lua always struck me as being so simple it crosses the line into Factor/Forth territory.

Re: Why are we limited to JS in browsers - would a bytecode ... by orangecat on Thursday November 11, 2010 @07:21PM (#1895982)
OK, don't use the "bad parts."

That's what I try to do, which turns it into a crippled Ruby. And there's no getting around it silently doing the wrong thing if I ever forget a "var" or "===".

Re: Why are we limited to JS in browsers - would a bytecode ... by jashkenas on Thursday November 11, 2010 @08:02PM (#1896090)
For what it's worth, there are tools that can help you avoid the bad parts. JSLint won't let you forget a "var" or "===" ... and if you use CoffeeScript, it's not possible to forget "var" or "===", because there aren't any.
Re: Why are we limited to JS in browsers - would a bytecode ... by brainlock on Thursday November 11, 2010 @10:18AM (#1894037)
Why do you find it depressing?

I'm not saying that there aren't better programming languages than Javascript. I'm just saying that there is a subset of Javascript which is really expressive and elegant.

Re: Why are we limited to JS in browsers - would a bytecode ... by silentbicycle on Thursday November 11, 2010 @10:36AM (#1894091)
That elegant, expressive subset is basically Lua. It's been able to jettison most cruft over the years.

I'm not a web developer, but every time I read/use Javascript, it feels like a broken fork of my favorite language. Javascript could have been that good, too. I like where Eich was going with it, but the browser wars etc. meant that shipping an early version made the most business sense, and design errors (which would have shaken out) got frozen in the spec.

Re: Why are we limited to JS in browsers - would a bytecode ... by BrendanEich on Sunday November 14, 2010 @11:10PM (#1905188)
See http://wiki.ecmascript.org/doku.php?id=harmony:harmony and the pages it links in the first paragraph. ES5 strict (on which Harmony is based) removes or fixes some of the cruftiness.

It's not the case that the Web dooms us forever to use JS as it was in 1995.

That is simply false on a number of JS-specific points, but more generally: the Web's deployed-browsers-with-enough-market-share-to-matter intersection semantics moves over the years. It does not stay still or grow only compatibly. Bad old forms (plugins, especially, but also things like spacer GIFs used in pre-modern table layouts, not to mention old JS versions) die off.

So, cheer up! JS can't be Lua, but it doesn't need to be. Its job is to be the best it can be according to its species and genus, its body plan. Which may be related to Lua's, but which was not and will never be the same as Lua's, because JS and Lua live in quite different ecosystems.

A concrete example: Lua has coroutines now, but JS is unlikely to get them in the same way, interoperably. Some VMs would have a hard time implementing, especially where the continuation spans a native method activation.

This is a case where Lua's single-source implementation shines, but that's just not going to happen on the web, in variously-implemented, open- and closed-source (the latter including clean-room, for fear of patents) browsers. So, we're aiming for Pythonic generators at most.

If we go further than generators, I'll be surprised. Pleased too, don't get me wrong. However I doubt it will happen, because some on the committee do not want deeper continuations than generators, since greater than one frame of depth breaks local security-hat-wearing reasoning about what is invariant in JS's run-to-completion, apparently single-threaded execution model.