Why is there just support for JavaScript and some VBScript in browsers today? I know JavaScript is good and all, but wouldn't having the option of using another programming language help promote different development styles?
|
|
There is no need to add suport for multiple languages, a solution would be to standardize on a generic bytecode that could be used by language implementors. But there is currently no plans for this (it's been suggested). Languages can be implemented on top of Javascript too. Javascript is good enough to allow other languages to be implemented on top of it. And there are many examples of this already. |
|||||||||||||||||||
|
|
JavaScript is the de-facto standard and has been since 1996. Being a standard simply because there is no competition isn't exactly fair, but I haven't heard a lot of complaining about why there isn't another language included. Adding another "standard" language promotes all sorts of fun little issues.
|
|||||
|
|
Think of the inconsistencies between browsers for their support of javascript alone. Now think about how it would be if there were more languages. |
|||||||||||||||
|
|
Browsers have to be standardised, so that what you develop works everywhere, on all browsers. If you have multiple languages kicking about, then you have to ensure that they all perform very similarly. If you are a web developer and you have a choice of languages, which may or may not be supported in some locations, then that is an additional headache. Javascript is a very flexible language, it is imperative, it is functional, it can be OOP (after a fashion with prototypes), and it is interpreted. Now with decent engines like in Chrome, it is reasonably capable of doing some good stuff. Extra languages would just set things back here, look at VBScript, IE only, and so anything that is written in it is bound to a particular browser and platform, nightmare. |
|||||||||||||
|
|
Instead of building these into browsers, vendors like to build clunky browser plug-ins - Java, Flash, Silverlight, etc. This guarantees cross-platform consistency. |
|||
|
|
One of the reasons is that it is practically impossible for different browser vendors to even agree on a standard Javascript implementation and Javascript has been around forever, at least from a web language perspective. So most people rightfully think that getting another client side language into the ecosystem and getting all the vendors to support it is practically impossible and most of the people that could potentially make it happen are already involved in Javascript standardization issues which I think is a much better use of their time. |
|||
|
|
I believe JavaScript is going to gain even more ground as the standard language for the Web. We're seeing a rise in server-side JavaScript. Here are some examples of implementations of this powerful language on the server:
What many of these implementations and frameworks demonstrate is that JavaScript is becoming such a powerful force in Web development that community leaders have already started moving JavaScript to the server. JavaScript is an extremely powerful functional programming language, and as time goes on I feel we will see it evolve. In summary, it seems like a contradiction to port the other languages to the browser when instead we can port this single browser language to the server and bridge that gap in a more unified manner. |
||||
|
|
|
There are several responses here which claim that supporting multiple languages would make it very odious for builders of web browsers to ensure they're compliant with all the languages. To me this seems incorrect. Java, for example is an extremely well defined standard. Essentially, all you need to do is to expose the browser DOM as a Java API, and run the Java Virtual Machine (JVM) inside your web browser. You could specify that scripting code would either have to be delivered in the form of compiled and signed JAR files, or as JavaScript sourcecode. If the browser encounters JavaScript, it could either run it through a dedicated interpreter (as it does today), or through Rhino on top of the JVM. If it encounters jar files, it creates a new class loader and security sandbox, loads the java bytecode into memory and executes it. This would be completely backward compatible with existing web pages, and would allow the browser, with a single stroke, to support the dozens of languages that run on the JVM. Other Advantages:
|
|||||
|
|
People have worked around the lack of built-in variety in two ways: using plugins like flash or java applets, and building layers that sort of use javascript as their "machine code", like jquery or google web toolkit. If there was a new development style popular enough, people would find a way to get it in. Just be aware if you make a .net runtime in javascript, and it ever becomes popular, certain circles will curse your name on the internet forevermore. |
|||
|
|
|
There are several examples of tools which will compile other languages to javascript, including Haskel, Lisp and Python (Probably others). So if you want to work in one of those languages you can do so. And I think one of my professors from university wrote a scheme implementation in Javascript. So if you like scheme you can do that too. |
|||
|
|