"The language of the future is javascript"

Raph Levien has posted an article The browser wars are once again upon us a few days ago to advogato, covering the current state of the landscape for client-side web programming, and ends by saying In any case, one thing seems clear, if surprising: the language of the future is JavaScript.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

See also Steve Yegge's article

See also Steve Yegge's article The Next Big Language, which argues that (upcoming versions of) Javascript is the superior language for technical reasons also. Provoking reading, to be sure! :)

Also, see the Crossing

Also, see the Crossing borders: JavaScript's language features article at IBM developerWorks by Bruce Tate, which among other things says:


"My friend and colleague Stuart Halloway, one of the foremost experts on Ajax, begins a JavaScript class with a provocative statement: "By 2011, we will recognize JavaScript as a language with a better set of features for developing modern applications." He then says that JavaScript programs are often 10 times as dense as similar Java programs and goes on to show the language features that make it so."

JavaScript may be the Language, but I am afraid of the Platform

I have been saying that JavaScript is the language of the future for awhile now (actually, the platform of the future for awhile now). But it's all been tongue in cheek.

Here's why: we seem to constantly be creating artificial hurtles for ourselves (through languages and platforms). Now JavaScript is a pretty powerful language, and I really don't mind programming in it. What I do mind is constantly reverting back to poorer and poorer virtual machines, libraries, and platforms. I am going to define the quality based upon two metrics (1) programmer's performance, and (2) execution performance.

I remember writing games as a kid in assembler. Why? Because I was told that was the only way to get good performance and therefore interesting features (the more you can do in less time, the more interesting the game will be). But eventually we all agreed that C was fast enough.

And then C++ came along and everyone regarded it as slower than C -- it should only be used for higher-level stuff. Whatever. But eventually, people regarded C++ as "good enough". OK, great we're getting more powerful languages.

Then Java and .NET came along. I won't argue whether these languages are more powerful than C++, but they certainly helped programmer productivity (metric 1 finally caught up with metric 2). Oh, but we had to wait for compilers and VMs to get fast enough to compare execution performance to C++. (It is my current observation, that for typical applications, C# on the MS VM is just as fast as C++).

But along came the web. In order to support that platform we all had to break our code to execute on a smart server with a dumb terminal (HTML and HTTP). Overall performance of applications fell through the floor (server time + client time). Even though we are using powerful and fast languages for server development, the user never gets to see the benefits. To them, they're still stuck in a land where most TEXAREAs don't even do spell check. How pathetic.

To help out, we need to add intelligence to the client. AJAX says to do it through JavaSCript and the DOM. Anyone who has done this knows just how wonderful the situation is. In case you have not done this, let me tell you that AJAX puts us back to (1) a horrible development experience, and (2) a very slow execution model.

The thing is, AJAX is so good for the end user, that we have to do it. We have to trudge through the browser differences, we have to use crazy line-protocols with weird asynch models. We as developers have stacked the cards against ourselves. It's not like anyone concisouly did this, but it is the net effect. It's sad that I can create a far richer user experience in MS Access from 10 years ago than I can over the web today (in less time with the same amount of effort).

SO I welcome JavaScript as a language. But I am shocked that we keep castrating ourselves with the platforms of JavaScript. You might guess that I am a believer that Flex2 and Silverlight are in fact, Good Things.

It's sad that I can create a

It's sad that I can create a far richer user experience in MS Access from 10 years ago than I can over the web today (in less time with the same amount of effort).

Debatable. Can't use an Access app from anywhere in the world, and I count that as a big plus in the user experience column. Your point is well taken though. With MS's new Silverlight, Flash and ActionScript, Mozilla's push with XUL+JS 2, and a few other endeavours, perhaps you'll get your wish.

Don't discount the effect

of cheap high-bandwidth, low-latency connections.

No amount of PLT or platform cleverness will make a pleasant user experience out of a 56k dialup line. :)

No amount of PLT or platform

No amount of PLT or platform cleverness will make a pleasant user experience out of a 56k dialup line. :)

I think you'd be surprised. If you design the GUI architecture properly, you can get the bandwidth low enough that people will barely notice it. There are a few tradeoffs involved of course, and noisy connections will definitely cause latency issues. Take a design lesson from MMORPGs: predict client-side (untrusted), then reconcile conflicts server-side (trusted). If it works for high-bandwidth, highly distributed and interactive 3D environments it can work for relatively lower-bandwidth desktop-like interaction. :-)

But is-it pratical?

MMORPGs are a special case: a lot of the bandwidth saving comes from distributing the client application on a DVD..

I remember Berlin a project to do client server GUIs, which tried to put more intelligence in the display part to reduce the bandwidth used and the latency, the problem is that this creates a high coupling between the display part and the application ..

MMORPGs are a special case:

MMORPGs are a special case: a lot of the bandwidth saving comes from distributing the client application on a DVD.. [...] [Berlin] which tried to put more intelligence in the display part to reduce the bandwidth used and the latency, the problem is that this creates a high coupling between the display part and the application

Yes, that's it exactly. Except nowadays in the world of pervasive VMs, updated code and/or app/display server dependencies can be downloaded and executed on the fly; after the initial download, network communication is fast.

Unfortunately, .NET is the only widely deployed VM that comes somewhat close to this safety goal with it's notion of the AppDomain. Even the AppDomain is insufficiently isolated however, as malicious code can still mount DoS attacks against the memory subsystem, and the "scheduler". I've written about .NET's limitations in this regard elsewhere, and I hope to follow this up soon with a post on the minimal features required of a true secure common language VM that can do the above (hints are in that post though).

Great post

I agree with everything you said, especially the dumb terminal observation. But as naasking pointed out, it's all about deployment.

Silverlight seems to change the landscape a bit though with support for C#, JavaScript, Ruby, Python, Java, or any .NET language that can be hosted in the Silverlight CLR sandbox.

While I'm not the biggest

While I'm not the biggest fan of prototype based object models like the one Javascript uses, I couldn't agree more with the comments about the platform.

But there are more things that need to be solved as well. One is tool support, its been a while since I've done web work but I've yet to find a Javascript/HTML editor that provides as many productivity gains as Eclipse JDT and Visual Studio's IDE's for VB, C++, and C#.

Lets also not forget usability issues as well. 4 of the 5 easiest places to reach with a mouse are already taken by the browser's control bar and the operating system's task bar.

JavaScript VMs are getting better

In happier news, recent VMs and compilers for JavaScript are getting their acts together, adding type inference and JIT compilation and nice garbage collection. The future will always be profoundly sub-optimal, but a lot of work will go into polishing it.

Joel on Software on Javascript

Just to add another well written essay that praises Javascript:

Can your Programming Language do this?

The thing is...

The only sad/happy (depends on your perspective) thing is that most functional languages (OCaml, SML, Haskell, and all the forgive-me-not-to-mention-them ones) can do most of the things praised in this essay.

I cannot help myself but view that all the static/dynamic flame war (I hope I won't start another battle) has actually been static(C++, Java) vs. dynamic. Somehow, I feel that the praise that dynamic and scripting languages recieve mostly originates in their succinctness (no need to declare types - also a feature of some static languages) and their runtime reflexivity (and the ability to alter the code/behaviour at runtime - I personally haven't yet seen many programming challenges that can be significantly better and faster solved using reflectivity), which are a huge gain compared to Java and C++, but not necessarily better than ML.

Joel (Unsurprisingly) Gets It Right

While the code examples are in JavaScript, Joel is quite clear in his essay that any language with first-class anonymous functions wins in the same way, and that thinking functionally is how you come up with Google's (in?)famous MapReduce. He (again, correctly) complains of the poor support in Java and C++ for the paradigm. Not once does he say anything about static this or dynamic that—I'm pretty sure that he knows better. Like 99% of everything Joel writes, I think his post presents the crystalline beauty of the functional style in a very accessible way.

One of the design mistakes of Java

is the complete lack of support for HOFs, other than via the artifice of writing a classes which implement a "doit" method. (Many of Java's issues would be more tolerable if a decent preprocesser were part of the language definition).

C++, at least, has function pointers and operator (), and such can fake combinatorial HOFs reasonably well without too much extra syntax. (OTOH, environment capture is still a big issue; as has been pointed out, a lack of GC makes managing closures properly difficult).

This is going to change

Writing JavaScript in Python

I think it's fair to say that JavaScript is the new "machine-code", we have GWT that treats JavaScript that way and I think we'll see more projects like that. I've recently implemented something similar for Python and this article prompted be to blog about it: Programming the browser with Python

We can't fight JavaScript but that does not mean we have to surrender to it.

GWT and Python

Hi Sergey,

If you're interested in GWT, but prefer Python over Java, there's a project called pyjamas, which is essentially a pythonized clone of GWT. Disclaimer: The GWT team (of which I'm a member) has no relationship to pyjamas.

It sounds like it might be down your alley. That said, I'm not sure how pyjamas compares with our optimizations. We're aggressive with whole program transformations that would seem difficult to do in python. In fact, GWT doesn't support dynamic class loading for that very reason.

Thanks. I did find pyjamas

Thanks. I did find pyjamas soon after I wrote that blog post, and it looks nice. What I was trying to do is quite different, my aim is not to override javascript semantics but only reuse python syntax and make it possible to implement server-side and client-side code in the same module. Not sure about Pyjamas, but at least GWT could not be mixed with JS libraries like YUI or MochiKit etc. My module seems to interoperate with it just fine.

GWT is awesome with it's optimizations. Nothing of that kind in my implementation =) (Not sure about Pyjamas either)

Using other libraries

You should be able to use JSNI to embed any javascript library component you need. For example, this IBM developerWorks article demonstrates embedding an ActiveWidgets control inside a GWT application. Additionally, we are working on a javascript "import/export" mechanism that would provide better automation for that process.

If there's a specific problem you're having, or any insights you'd like to share, please let us know. :)

Insights

I am not sure just how relevant it still is, but check out our original discussion of GWT...

Me? I am still waiting for the Google DSL I suggsted long ago (which will probably be called the GPL... as in "Google Programming Language"...)

Thanks for suggestions, all

Thanks for suggestions, all of this looks quite interesting.

And the reason why JS is the language of the future?

I think the reason that JS seems to be the language of the future is not its dynamic nature or functional capabilities, but the simple fact that it runs within a GUI (i.e. the browser).

Suppose that we had the C language within the browser (with a few additions like garbage collection and first-class functions). Would that be considered 'the language of the future'?

Or suppose that we had LISP within the browser. Would that be considered 'the language of the future'?

I think the situation with the web development is more about the lack of a distributed programming environment with a graphical output than programming languages themselves. HTTP/HTML was a good idea for showing static information, but the web programming environment needs a new design (new protocols, new standards) rather than a set of hacks to turn the web into a distributed application platform.

And I am not so sure that all applications need to be inside a browser. Perhaps what is needed is a distributed O/S protocol where programs are distributed in bytecode format, and a distributed O/S engine makes sure everything works as expected.

Security

The internet is a hostile environment, and having a distributed OS heads straight into issues surrounding security and trust. Though there are possible solutions, they do require cooperation (or conspiracy) between a large number of parties to get things up and rolling.

The main thing I like about http/html based appls is the loose coupling. And I don't have to worry about installation issues (e.g. some user blaming a hard disk crash on my software simply because it was the last thing installed on the machine). And I don't have to worry about what OS or version they run.

The browser is the OS, no?

And I don't have to worry about what OS or version they run.

That seems odd to me. Don't you have to worry about what e.g. strange internationalized version of Opera they are running? (Or do you just aim for IE6+ and say everybody else can jump off a bridge?)

Therein lies the issue

If you adapt some of these platforms, you DO have to worry about the browser or OS your customer runs.

Some of the platforms proposed--Silverlight, the new Adobe stuff--might not work on your browser or OS. MS appears to be supporting Silverlight on Windows platforms, regardless of browser (including Firefox--MS has done much to support Firefox on Windows of late). MS also will likely support Macs running Safari. MS certainly will not support Firefox on Linux, Konquerer on Linux, or anything else for that matter on any OS other than Windows (XP service pack 2 or Vista) or certain flavors of MacOS. There's always Mono; but how quickly they can track MS' changes, and/or stay clear of legal issues, remains to be seen.

Adobe has less reasons to be platform-hostile than does MS--they are not an OS vendor after all. OTOH, their support for Linux has been spotty in the past.

AJAX, for all its warts, works on pretty much every modern browser+OS combination.

JavaFX is a bit of an unknown quantity.

There is one player that can have an influence on this, but whom we haven't heard from yet: Google. Most if not all rich client apps they've done have been using the open-source kit. They've got the in-house software expertese, as well as the market presence, to influence this sort of thing should they choose.

There is one player that can

There is one player that can have an influence on this, but whom we haven't heard from yet: Google. Most if not all rich client apps they've done have been using the open-source kit.

I'm employed by Google, but I am only speaking for myself.

If you adapt some of these platforms, you DO have to worry about the browser or OS your customer runs.

Google Web Toolkit supports all the major platforms out of the box. We isolate platform specific code (typically embedded javascript) into different classes using a rebind strategy. For example, the DOM class is backed by browser-specific impl classes, only one of which is selected per webapp permutation at compile time.

The technique is a pretty important differentiator for GWT in that it allows us to automatically build specialized, lean permutations of your webapps for each browser (e.g. webapp-ie6.js, webapp-ie7.js, webapp-ff2.js, webapp-safari.js, webapp-opera.js, etc...). Typical webapps send all the differing browser-specific code to each and every client, regardless of their actual browser.

</shameless advertisement>

haXe

That's similar to what haXe is doing.

Not that I have anything against javascript...

...but I would really like it if there was a broader range of languages available for client-side coding than javascript, javascript, or javascript.

I've looked at javascript from time to time and have found nothing that hasn't been done better in many other languages, except for the fact that it's bundled into every browser.

So the question I have is this: why aren't there client-side browser plugins for every new language? Is this just for lack of effort, or are there real technical reasons why javascript is superior in this domain? I would love it if I could do client-side programming in e.g. Scheme, or Ocaml, or Haskell.

Inertia, mainly

First, Javascript isn't supported via plugin, typically--it is, as you say, built into the browser. All the major browsers support it (some version thereof) out of the box. Unlike Java (until recently), Flash, and anything .NET, there are long been good open-source implementations of Javascript.

An interesting question, now that Sun is finally releasing the whole Java shebang under the GPL, is how long before certain browsers (mainly Firefox) ship with Java built in? That seems a no-brainer.

And then, there is the inertia problem. Few shops do web apps in Scheme or ML or Haskell for the same reason that few shops write embedded systems, shrinkwrap software, or client-side stuff in these languages. With web apps, there is a chicken-and-egg problem; browser vendors (including Mozilla) are unlikely to embed languages in a browser without demonstrated use; and app developers certainly aren't going to write client-side code in a language that most browsers don't support. Getting people to install plugins for things like Flash or Java is enough of a hassle.

In other words, the reasons are primarily social and not technical.

Java built in?

An interesting question, now that Sun is finally releasing the whole Java shebang under the GPL, is how long before certain browsers (mainly Firefox) ship with Java built in? That seems a no-brainer.

Why would Mozilla introduce a huge dependency for something that is largely irrelevant in the browser? Did applets make a comeback when I wasn't paying attention?

Maybe

Did applets make a comeback when I wasn't paying attention?

Combine Java Kernel with JavaFX and the answer may be, "yes".

A future maybe

Lots of things are possible in the future, but last time I checked applets didn't make a comeback.

If the comments over at Javalobby.org and TheServerside.com are any indication, then JavaFX has an uphill battle.

But it's definitely not a no-brainer for Mozilla to make a decision to start shipping Java.

Perhaps this is a thread too far afield..

but why do you think that Java has apparently failed this particular niche (client-side web app)? Java thrives elsewhere, but this niche was seen originally as Java's "sweet spot".

1) Issues with the language itself (syntax and semantics)?
2) Performance issues--VM startup time, applet running time, poor behavior of early GC technology?
3) Other broswer integration/user experience issues--need to download and install a plugin, ugly widgets (that look different from native widgets), etc.
4) Security issues?
5) Licensing issues, other supplier issues from Sun Microsystems?
6) Interference from Microsoft?

Several issues

  • Immaturity of the Java system itself
  • Immaturity of client systems (bandwidth and performance considerations)
  • no Flash-like installer
  • versioning and updating issues

And I would say that (1) on your list might have been an issue too. Content authors don't want to monkey around with Java's heavyweight syntax.

depends on the future

If the program of the future is less than 5000 lines, then indeed the language of the future might be javascript. Otherwise I wouldn't bet real money on it. It is a giant (if not insurmountable) step backwards for medium to large sized applications.