My gripes with JavaScript
ironjs.wordpress.com
ironjs.wordpress.com
Javascript's root problem is that there is nobody who plays that role. The language has now been around for ~15 years, but it has hardly changed in the meantime. Not zero, I know that, but compared to the advances that any other language made over the same period of its life, Javascript has hardly moved at all. Not since Netscape lost the ability to unilaterally move the language forward by virtue of having the de facto only implementation has the language been able to move much.
So not only does the language have problems, right now, there is no effective path for those problems to be fixed in any reasonable period of time. We know this, because js.next shouldn't be "something we hope to see in a few years" but rather something that should have been done ~2002/2003, if the whole improvement process wasn't so broken.
(BTW, remember to separate "the language" from "the bindings". XMLHTTPRequest was not a Javascript change, for instance, just a new binding that all browsers had.)
Even the standardization process is slow, somewhat disconnected from implementation, and is still essentially focused on fixing syntax problems that have been dangling for a decade now. If js.next somehow successfully manifests in the next few years, we still have a lot of problems in the library department, for instance.
Server-side JS will probably face a decision point at some point in the not-very-near future, where the decision will have to be made as to whether it sticks as close to client-side, browser JS controlled by a effectively-leaderless process running at vanishing fractions of the rate of improvement of any other language, or if it runs off to start creating its own improvements, probably by paving over the cowpaths. I actually favor the latter, because it would create some set of people who can say yea or nay, restore an actual feedback loop, and create progress which could then be propagated back to clients as appropriate.
Certainly this is mostly due to its unique position on the browser, but the language had to be flexible enough to fill that role and more. That's amazing.
Yes, that is tongue-in-cheek, but without JavaScript, web browsers would have found another language; without web browsers, JavaScript would long have been forgotten.
My memory is a bit foggy, but I recall Microsoft throwing a bunch of things at the browser in the beginning. You can specify the language in the script tag. VBScript anyone?
It wasn't like JavaScript didn't have competition ... it just won a very long time ago.
It had market penetration because it was included with Netscape Navigator.
Yes, it also was good enough at that time, but almost anything would have been, in a time where a ten-line script was huge. I do not think that it would have won against say VBScript if the latter would have been available on the same set of browsers.
I can think of one other, and for the same reason: make. Both languages are still around because it's near impossible to replace them, no matter how much they may suck. They aren't timeless, they're calcified by being a part of some infrastructure that exists on millions of machines.
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?
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.
"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
Ultimately, a VM is just another language with lousy readability.
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.
Why, and who would you pick?
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.
But then he goes on to list things like "Lack of language defined modules and namespaces" (which it has in common with COBOL, C, and PHP), "null vs. undefined" (JS has eight kinds of nothingness — '', false, null, undefined, NaN, 0, [], and {} — as opposed to a usually slightly smaller number, although Python has nine: '', None, [], {}, (), NaN, 0, 0.0, and False), etc.
I think he has failed to prove his point.
This touching lifestory isn't meant to convince you that JS is any good, but it should illustrate why/how certain individuals come to join the dark side.
Lisp can both be dynamic and compiled.
Many dynamic languages---Python, Ruby, et all--on JVM or CLR have a compilation step. They compile to byte code that the VM then runs.
As with most "next gen" web browser technology (for whatever your 'current gen' may be, back to Netscape 2.0), until I see it actually shipping in a majority of browsers I will remain skeptical.
What ideally should happen is browsers should expose the VM and an entry point for interpreters to use and configure JS on the VM. That way other languages could be used against the VM-in-browser.
I suspect Google is trying to move in this direction, but IDK.
Everything is an Expression (at least, as much as possible)
a lot of the hassles with JS just disappear with this "small" change (if applied extensivly)