News for hackers. Stuff that matters.
Re:My gripes with JavaScript by billybob on Wednesday June 22, 2011 @09:48AM (#2683056)
There seems to be agreement that Javascript is a messy language which is popular by default: it was included in Netscape, then other browsers picked it up. Now we're stuck with it.

I realize this would be very difficult and introduce horrible compatibility issues for a while, but sometimes I think, "what if we could start over?" What if Chrome and Firefox started supporting Python or Ruby or a custom, well-designed language for web scripting? Could it gain enough momentum to replace Javascript?

Actually, the easiest candidate would be for browsers to start natively supporting Coffeescript. But imagine a "dream team" designing a language just for the web, from scratch: Douglas Crockford, John Resig, Guido van Rossum, Yukihiro Matsumoto...

Is this a "it's crazy but it just might work" scenario, or is it just crazy?

Re:My gripes with JavaScript by protomyth on Wednesday June 22, 2011 @09:52AM (#2683076)
If we started over, we should pick a VM, not a language.
Re:My gripes with JavaScript by moomin on Wednesday June 22, 2011 @12:14PM (#2683794)
Producing a truly language-neutral VM would be an interesting goal, one that no-one's really got that close to achieving. (I think Microsoft's got closest.) Making it a compact wire format to boot would be... challenging.

Ultimately, a VM is just another language with lousy readability.

Re:My gripes with JavaScript by protomyth on Thursday June 23, 2011 @06:44PM (#2690234)
I see your point, but I think a VM spec comes with an implicit promise that it is OK to develop languages as opposed to the "why don't you just program in what we give you?" mantra.

I agree its a very hard problem. If I was starting from scratch I would probably look a lot more on vector operations than someone would have 10 years ago. Plus the manner of parallelism a person choses would seriously influence language implementors.

Re:My gripes with JavaScript by vmind on Wednesday June 22, 2011 @10:24AM (#2683226)
Some kind of flexible bytecode implemented across browsers would be fantastic, and you could always implement a fallback interpreter in javascript (or if feeling fancy, a decompiler).
Re:My gripes with JavaScript by windsurfer on Wednesday June 22, 2011 @10:36AM (#2683298)
Isn't Javascript a flexible bytecode?
Re:My gripes with JavaScript by vmind on Wednesday June 22, 2011 @10:45AM (#2683328)
Well, yes, but it comes with all the overhead of being a (partly) flawed language. Having a bytecode that allows, for instance, optional static and dynamic types would be much more direct than relying on type inference or separate native APIs (as are being introduced). Of course we have javascript now, so pragmatically languages should be compiled to it if we want them, but if there were to be an additional web bytecode, there would be many areas for improvement in terms of performance and safety.
Re:My gripes with JavaScript by chc on Wednesday June 22, 2011 @03:53PM (#2684859)
JavaScript is a programming language that compiles to bytecode. It can be treated as object code, but it is a very different and higher-level thing than the term "bytecode" generally denotes.

Calling JavaScript "flexible bytecode" is like saying that all Turing-complete programming languages are the same, or that all objects capable of driving a nail into a piece of wood are equivalent. It's true in a very facile way. JavaScript can be treated kind of like bytecode, and all Turing-complete languages can be treated as a simulation of a Turing machine, but the details that these rough descriptions miss are more numerous and more significant than the details that actually went into forming the generalization.

Re:My gripes with JavaScript by chc on Wednesday June 22, 2011 @03:53PM (#2684861)
JavaScript is a programming language that compiles to bytecode. It can be treated as object code, but it is very different and higher-level thing than the term "bytecode" generally denotes.
Re:My gripes with JavaScript by wladimir on Wednesday June 22, 2011 @11:00AM (#2683393)
Yes a VM would be nice. Or LLVM + native client, "portable native client", Google is (was?) working on this in Chromium.
Re:My gripes with JavaScript by protomyth on Wednesday June 22, 2011 @11:31AM (#2683541)
LLVM code with access to the DOM would be fine by me. Security would probably take a while to audit.

"The LLVM code representation is designed to be used in three different forms: as an in-memory compiler IR, as an on-disk bitcode representation (suitable for fast loading by a Just-In-Time compiler), and as a human readable assembly language representation. This allows LLVM to provide a powerful intermediate representation for efficient compiler transformations and analysis, while providing a natural means to debug and visualize the transformations. The three different forms of LLVM are all equivalent. This document describes the human readable representation and notation." http://llvm.org/docs/LangRef.html#abstract

Re:My gripes with JavaScript by fholm on Wednesday June 22, 2011 @10:23AM (#2683221)
I would not consider that a dream team considering the languages/libraries they have produced.
Re:My gripes with JavaScript by billybob on Wednesday June 22, 2011 @03:41PM (#2684785)
You think jQuery, Ruby and Python are subpar?

Why, and who would you pick?

Re:My gripes with JavaScript by romaniv on Wednesday June 22, 2011 @10:51AM (#2683354)
Not crazy at all, especially if is a VM that can host multiple languages. Hm... What would be even more interesting is a VM that can be configured form the server.

1. User opens a page with scripts in LanguageX. The page links to some kind of VM configuration file. 2. Browser loads that file, which enables it to parse LanguageX. Browser caches that file. 3. From now on, the browser can execute scripts in LanguageX.

Although, this particular idea might be the case when too much flexibility would lead to issues in the long run.

Re:My gripes with JavaScript by justincormack on Wednesday June 22, 2011 @11:02AM (#2683403)
Chrome's ative code plugin NaCl lets you do this - there is a Tcl implementation using it so far, but no reason why there should not be others.
Re:My gripes with JavaScript by wladimir on Wednesday June 22, 2011 @11:08AM (#2683434)
But NaCl in its current state is limited to a specific platforms, which is a big problem for a web app. Do you know if portable NaCl ever got anywhere?
Re:My gripes with JavaScript by justincormack on Wednesday June 22, 2011 @12:27PM (#2683846)
Actually haven't seen anything for a bit. You are right we do need this too...