Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is javascript the only client side scripting language implemented in browsers? [closed]

Why don't browsers add support for, say, Python scripting as an alternative to Javascript? Or more general purpose scripting languages? Is there a reason that Javascript is the only one implemented across browsers? After all, the script tag does have support to specify the scripting language used.

(I know there is VBScript support in IE, but it seems obsolete for all intents and purposes.)

like image 838
Anand Avatar asked Jan 20 '12 19:01

Anand


People also ask

Is JavaScript only client-side?

The future of JavaScript While JavaScript is not the only client-side scripting language on the Internet, it was one of the first and it is still the most widely used. Many developers believe that JavaScript is inefficient and finicky, so they have made many improvements to the language over the years.

Why is JavaScript good for client-side?

All kinds of scripts can run on the client side if they are written in JavaScript, because JavaScript is universally supported. Other scripting languages can only be used if the user's browser supports them.

Can JavaScript only be executed on the browser in the client?

Today, JavaScript can execute not only in the browser, but also on the server, or actually on any device that has a special program called the JavaScript engine. The browser has an embedded engine sometimes called a “JavaScript virtual machine”.

Why do browsers not support other languages?

They lack the browser environment (e.g. javascript's 'document' object and php's superglobals), but a similar environment could be constructed as a module in those languages. Many programming languages have cgi modules, so there is a precedent for this.


1 Answers

Well, Google is trying to buck that trend with Dart. The community hasn't been entirely receptive to the idea; either.

Google proposed adding multiple VM support for Webkit which didn't go down very well.

One particular comment summed it up nicely as to why there has been some resistance to that:

In this case the feature is exposing additional programming languages to the web, something without any real benefit to anyone other than fans of the current "most awesome" language (not too long ago that might have been Go, a year or so ago this would have been ruby, before than python, i recall i brief surge in haskell popularity not that long ago as well, Lua has been on the verges for a long time, in this case it's Dart -- who's to say there won't be a completely different language in vogue in 6 months?), but as a cost it fragments the web and adds a substantial additional maintenance burden -- just maintaining the v8 and jsc bindings isn't trivial and they're for the same language.

The issue here isn't "can we make multiple vms live in webkit" it's "can we expose multiple languages to the web", to the former i say obviously as we already do, to the latter I say that we don't want to.

Unless we want to turn webkit into the engine that everyone hates because of all its unique "features" that break the open web, a la certain browsers in the late 90s.

CoffeeScript is another example of an emerging client-side scripting language. However, rather than support another virtual machine in a browser (as Google is trying to do with Dart), it compiles to JavaScript. There are several other "compile X to JavaScript" that do that as well. emscripten is a good example of compiling LLVM to JavaScript.

So there are plenty of other client languages; they just all use JavaScript as an intermediate. I'd argue that should be what Dart does as well, though they have some room to improve.

like image 159
vcsjones Avatar answered Sep 23 '22 10:09

vcsjones