开发者

Why has Javascript been (mostly) only a browser-side technology for more than 10 years?

Recently there is a lot of projects that pushes Javascript into other directions: as a general purpose scripting language (GLUEScript, Rhino), as an extension language (QTScript, Adobe Reader, OO Macros), Widgets (Yahoo Widgets, MS Gadgets, Dashboard), and even server-side JS & web frameworks (CommonJS, Helma, Phobos, V8cgi), which seems obvious since it is already a language widely used for web development.

But wait, everything is so new and nothing is really mature. However JS is around for almost 15 years开发者_如何学运维, being as powerfull as any other scripting languages, being standardised by the ECMA, and being a mandatory technology for web development.

Why did it take so much time to gain acceptance into other domains than web browsers?


Douglas Crockford, who has done much to help people use JavaScript productively, also has a very clear picture of the things that hold JavaScript back. You can pick up a few of the points at JavaScript: The World's Most Misunderstood Programming Language. See also his lecture series Crockford on JavaScript.


The proliferation of Javascript as a viable language for heavy applications development isn't as old as the langauge itself... atleast it's definitely more recent than 15 years.

Mainly, it's popular and heavily-utilized right now due to the proliferation of AJAX and frameworks like jQuery/mootools/protoypes/scriptaculous and largely because browsers support is improving in compatibility, performances and whatnot.

Take, for example, Node.js which is built on V8 (which didn't exists until Google made Chrome) which strikes up the javascript performance bar so high that you can make high-performance networked applications on top of it dead easy.

So, IMO, it's because people jumped on the AJAX bandwagon that made JavaScript now suddenly becomes so much more awesome and spanning out to other areas.


There are some big flaws in the language surrounding code reuse - in particular, all code is executed in a single namespace, and there's no language-level support for importing other code. Plenty of enterprising library authors have worked around this on the client-side, due to necessity, but these problems are big ones to avoid when implementation choice is a language.

There is also not a single standard implementation of the language - Rhino is the most prominent, but it's not the most advanced in the days of SpiderMonkey, JavaScriptCore and V8. This shouldn't be as much of an issue with a standardized issue, but there's still a problem that non-browser JS code is unlikely to work with all JS engines, and very likely to be targeted to a single engine (Node.js depending on V8 is the most prominent example of this).

These problems have kept JS libraries from being written outside the browser, and since nobody writes non-browser JS libraries, writing non-browser JS becomes that much more difficult.

Things are changing - in particular, the CommonJS group has created a module spec that allows for better code reuse, which is already being used in Node, and are working on better specs for packaging JS code.


Language adoption is as much about the auxiliary libraries as it is the language itself. In the case of Javascript, there's a dearth of libraries for doing things like I/O and other standard requirements for fully-fledged use.


8 years ago I tried to have a brief look at JavaScript to see if I should learn more or not about it. I didn't. Why? I thought it would die within 2-3 years.

But thanks to JQuery and other JS frameworks it has gained very much reputation the last couple of years.

It's also associative. Do cars drive on water, do airplanes land on highways? JavaScript have always "belonged" to browsers, even though you could use it for non-browser related stuff.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜