<< Closures Comes To C++0x | Home | J...J...JJava >>

If JavaScript Were Such A Great Language ...

... why aren't its extra-web-browser versions being used widely.

Here's my observation: If people wanted to, they can use JavaScript for:

  • Windows shell scripting (JScript Windows scripting host)
  • General purpose Windows/.NET programming (JScript.NET)
  • General purpose dynamic language programming for the JVM (Rhino)
  • General purpose Unix shell scripting (xpcshell)
  • Scripting applications (for C++, Java, .NET applications through one of the above technologies)

All of the above technologies have existed for at least five years, some even ten. But if people are using JavaScript for non-web programmings, they are not talking about it.

Something to think about on a Monday morning.

Tags :


Re: If JavaScript Were Such A Great Language ...

True, but JavaScript has been in 3D and desktop publishing tools for nearly 8 years. Softimage XSI 1.0 included Js, along VB, python as a scripting solution (when Softimage was under Microsoft's umbrella), Adobe AfterEffects 5.5 also included Js. There were signs during SIGGRAPH 2001 that other tools would follow this trend. Lastly, let's not forget that ActionScript ~=~ JavaScript, scripting Flash was terrible until AS came along.

Re: If JavaScript Were Such A Great Language ...

Not true!
JS is a great language - unfortunately, it was thought of as a toy language until recently (3-4 years) till a slew of 'AJAX' applications flooded the market.
Even today many ppl are counfused between the browsers DOM API and the JS language and tend to blame JS for all of DOM APIs pain.
However, recently JS is popping in all kinds of places. as the previous post points out - Action Script is a great example.
- Java6 comes bundled with Rhino (see http://www.onjava.com/pub/a/onjava/2006/04/26/mustang-meets-rhino-java-se-6-scripting.html)
- Jaxer is a server side platform based on JS
All these are signs that JS is here to stay! Js has its wrinkles but now that it is in the limelight, the deficiencies in the language will get attention - only time will tell if the wrinkles will be ironed out or in the name of making it better it gets more wrinkled :)

Re: If JavaScript Were Such A Great Language ...

The same argument about poor quality evidenced by lack of offline adoption could be made for PHP.... JS is a bad language, but not even the best languages see use in all contexts.

Re: If JavaScript Were Such A Great Language ...

I think there are several underlying reasons. First of all, EcmaScript 3 has some notable drawbacks - a very minimal library system, lack of built-in support for many higher-level abstractions, etc. This makes languages like Python often more attractive for tasks like extensions and scripting. Many of these drawbacks are dealt with in ES4, but that's not finalized yet.

Second, on a more social note, Javascript has a heavy stigma attached to it. Despite folks like Steve Yegge and Douglas Crockford evangelizing it, Javascript has a reputation as a "web language" which one wouldn't want to use for real programming. It's going to take a lot to overcome that.

Finally, each of the implementations listed have their own issues. JScript is tied to Windows, JScript.NET to .NET (and maybe Windows, too; I'm not sure about the status of it with respect to Mono), and Rhino to the JVM (although it is used in various Java projects). SpiderMonkey, the engine behind Firefox and xpcshell, is neither developed nor marketed as a language for general-purpose scripting. I haven't tried, but I imagine it would be much harder to use it to do some trivial file manipulation than it would to use, say, Perl or Bash.

Re: If JavaScript Were Such A Great Language ...

It comes down to the standard library. I mean this in two ways. Firstly, I mean that the base methods on the core objects (Array, Date, Math) suck, they suck bad. They suck in a lot of ways because some of them come straight from pretty awful Java APIs. They're not designed for this language, and it shows. Why on earth do you need to use getBlah, and setBlah methods on Date? Or random support in Math: why do I have to first get a double between 0 and 1 and then use that to derive the random number I actually want? Now, tons of the libraries that are used in all your web projects fix a lot of these issues, but many of these also include DOM stuff, and XHR stuff, which a developer has to rip out before they can really use the library on a normal js runtime. Once you've done that, you have to deal with the fact that you're working with a library that's optimized for web development anyway, which is probably not what you're doing. The second thing I mean by the standard library sucking is that, well, actual implementations of libraries to do things like make socket connections, or fetch data over HTTP, or parse XML, or anything like that. At best, you'll be on some kind of shared class space like the JVM or .NET, but that means you have to work with the fact that the APIs you're developing in don't really work in a javascript like way, and you've also got to contend with the fact that the object-bridge may make you work with these objects in special ways. What javascript needs to actually be used in development, is a runtime with developers that focus on developing it for outside the browser, make changes to the language to suit that (since compatability is less of an issue outside the browser) and build up a strong standard library for the development process.

Re: If JavaScript Were Such A Great Language ...

Over at that little shop called Google they're apparently using Rhino.

Re: If JavaScript Were Such A Great Language ...

We use JavaScript in the form of Windows Scripting Host for many tools, including our build system (over 2000 lines of code now) - since 2001.

Re: If JavaScript Were Such A Great Language ...

I fully agree. However we must be fair. If Javascript were so be good, it would have use scenarios like other "scripting" languages too (perl python lua php and the best of these ruby >:) ) To be honest I hope that there will be ways to use another language than Javascript for local use. I dont like languages with such a narrow usage focus (take php for example, outside of the web everyone quickly realizes that it is a horrible solution)

Re: If JavaScript Were Such A Great Language ...

From what I've read, Google is using JavaScript (Rhino) on their servers (search for "google rhino").

Re: If JavaScript Were Such A Great Language ...

JavaScript is my favourite language, and I would love to use it outside of the browser, but have never found a decent env. to do that in. I've tried both Rhino and WSH, and both suck -- they don't have the extra APIs that JavaScript doesn't come with by itself, and they don't have a debugger. I recently came accross Phobos though, and that is amazing, and I am using it for a project. It has great APIs and an a working debugger. Nice!

Re: If JavaScript Were Such A Great Language ...

I would take JavaScript seriously if it weren't for the fact that users can just turn it off, and increasingly are doing so. If 5% of my users could disable sites with PHP, do you think I'd use it for anything but trivial presentation (which is what I use JS for)? As a web designer, I make sure all my sites work in IE6, IE7, Firefox, Opera, and Safari (which covers Konqueror too). Semantic markup makes them work on mobile devices and in Lynx too. Why do I do this? Because the businesses who are my clients aren't paying me to exclude potential customers.

Re: If JavaScript Were Such A Great Language ...

What idiot said Javascript was a great language?

Re: If JavaScript Were Such A Great Language ...

What idiot said Javascript was a great language? One that'd actually used it and knew it.

Re: If JavaScript Were Such A Great Language ...

As far as I know, Adobe's ActionScript is very much based on Javascript.

Re: If JavaScript Were Such A Great Language ...

JS for shell scripting suffers from a lack of good libraries for file manipulation or other standard unix shell utilities. Otherwise it would be great to not have to require another language for developers to use.

Re: If JavaScript Were Such A Great Language ...

Well, for two reasons I can see. 1) It's ~50x slower than C 2) It uses ~60x as much RAM as Pascal http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all&calc=Calculate&xfullcpu=0&xmem=1&xloc=0&binarytrees=1&chameneosredux=1&fannkuch=1&fasta=1&knucleotide=1&mandelbrot=1&meteor=0&nbody=1&nsieve=1&nsievebits=1&partialsums=1&pidigits=1&recursive=1&regexdna=1&revcomp=1&spectralnorm=1&hello=0&sumcol=1&threadring=1

Re: If JavaScript Were Such A Great Language ...

JavaScript is a great language. It's simple and powerful at the same time. It does need more libraries but that would be true of any language that's just coming into it's own after being pigeonholed in a browser environment for so long. I think Jaxer was mentioned above and there's also the new Axiom Stack. When platforms like this take off, there will be more library support.

Re: If JavaScript Were Such A Great Language ...

Javascript was and is a language that comes with no inherent functionality. Everything javascript can do outside of normal syntax(loops, variables, math, regex) has to be provided by an outside system or application. Javascript only has the ability to do things with the DOM etc. because the browser provide it to the language. Therefore using javascript on a different platform for different purposes is exactly what the language is made for and is great at doing. For example, the server-side libraries that are provided by Jaxer(a server that runs javascript on the server-side) have great file manipulation and database connection functionality to name a little bit. To think that Javascript is only useful as a web language in the browser is understandable but a small amount ignorant. Just like every other language functionality is only there because of the libraries that provide that functionality. I think Javascript is a great language and look forward to seeing how it gets used on different platforms for different purpose.

Re: If JavaScript Were Such A Great Language ...

How about server-side Javascript ala Apatana Jaxer? Comes with some file IO libs (even rudimentary DB access option I believe).

Re: If JavaScript Were Such A Great Language ...

Server side Javascript was created ages ago, before the browsers war began Netscape create LiveScript (the original JS), the only way to extend Netscape Server's functionality was through LiveScript.

Add a comment Send a TrackBack