Slashdot Mirror


Brendan Eich Discusses the Future of JavaScript

snydeq writes "JavaScript creator Brendan Eich talks at length about the future of JavaScript, ARAX, disputes with Microsoft, and the Screaming Monkey scripting engine for IE in an interview with InfoWorld's Paul Krill. JavaScript 2, which Mozilla's Eich expects to be available in some form by the end of the year, will 'address programming in the large.' To do that, Eich hopes to improve the integrity of the language without sacrificing flexibility and making JavaScript 'painfully static in a fixed way like Java does.' Eich does not expect Firefox support for JavaScript 2 until at least Version 3.1 of the browser. As for Internet Explorer, Eich explains how Screaming Monkey will help bring JavaScript 2 to IE should Microsoft drag its heels on providing meaningful support."

14 of 164 comments (clear)

  1. 1-page version by taupin · · Score: 5, Informative

    is here.

  2. Ow. by taupin · · Score: 4, Funny
    This statement made my mind hurt:

    "[...] use JavaScript as kind of an underlying assembly language [...]"

  3. Insightful by Mensa+Babe · · Score: 4, Interesting

    I wholeheartedly agree with Brendan that we should at any cost stop JavaScript in particulat and Ecmascript in general from being as painful as Java in any way possible. However what we should do is not only improving all of the ECMA-262 derivatives but to make a systematical progress towards better flexibility and interoperability of various scripting approaches in the future. Take for example the wonderful project by Mehmet Yavuz Selim Soyturk called PJS which is an important step in the direction to allow the Parrot virtual machine, designed to run Perl, Tcl, Javascript, Ruby, Lua, Scheme, Befunge, Lisp, PHP, Python, Perl 6, APL, Java, .NET, et al., to run on JavaScript, so all of those languages could be used together to enhance your browsing experience on the Web. For this to be even remotely plausible the JavaScript must be as flexible and as fast as possible because it would basically mean running high-level language code compiled to the Parrot intermediate representation (PIR, or IMC), that converted to the Parrot assembly language, assembled, linked, converted to Parrot bytecode and then execuded on the Parrot virtual machine or PVM which would itself be a large JavaScript interpreted script running in a Web browser, running in the operating system... You get the picture. A logical step forward would be to include PVM in all of the major browsers to run the Parrot bytecode natively and efficiently in the browser. There are already plans to include PVM interpreter in Firefox which means it will be available as a viable target for scriping dynamic html pages for all of its derivatives like Camino, Galeon and Konqueror. Hopefully the commercial browsers would follow (the Artistic license is not anti-commercial like GPL so there should be no legal problems with the integration). I really look forward to the future of perfect interoperability when every single Web page could potentially run scripts written in literally dozens of programming languages simultaneously. One day we will experience that synergy thanks to people like Brendan Eich,Mehmet Yavuz Selim Soyturk, Larry Wall, et al. if they only agree to work together on one common solution to the big mess of Web scripts that we have today. Let's all hope they will.

    --
    Karma: Positive (probably because of superiour intellect)
  4. Re:Javascripts popularity is no real suprise by vivin · · Score: 4, Insightful

    Javascript has the potential to be really useful. Well, it already is. I was at JavaONE earlier this year and I went to a few Javascript sessions. One of the most eye-opening sessions was the one where the presenter described Javascript as a LISP-1 language that just happens to look like C.

    As far as improvement, I think it needs a proper object oriented model (the current one is far too confusing), and also should be friendlier to implementations that require recursion. You can write recursive code in Javascript now, but it's very slow. Iterative solutions are faster.

    --
    Vivin Suresh Paliath
    http://vivin.net

    I like
  5. synergy with html 5 by bcrowell · · Score: 5, Interesting

    IMO the changes proposed for js 2 aren't very exciting. The biggest problems with js aren't really problems with the language design, they're problems with the lack of standardization in the interface to the browser. I don't see the burning need to make js more oo, more statically typed, or more like java.

    What I think really will be cool is the synergy between js and html 5. Html 5 has lots of good features for doing web apps, including audio, persistent storage, and graphics (canvas, inline svg without xhtml). Most of this is stuff you could have done before using java applets or flash, but now you'll be able to do them using a w3c standard that the vast majority of users will probably end up actually having supported in their browsers.

  6. Here's what Javascript 2 looks like by vivin · · Score: 4, Informative

    This site has an example of Javascript 2, and a translator from Javascript 2 to the current version. I really like the type-safety features and the MUCH better way to do OO.

    In response to the parent, in the article they talk about how Microsoft is fixated on 3.1 and not 4. Hence, there is "Project Screaming Monkey" which aims to create a scripting engine for IE that can run Javascript 2 and not depend on Microsoft to support Javascript 2. Then, IE can support Javascript 2 (through the Flash Player - full details in the article). I wonder if it is possible to do something similar for Firefox. Perhaps via a plugin? But I suspect performance would suffer greatly. Or maybe 4->3.1 translator like at ecmascript4.com that would do an "on-the-fly" translation.

    --
    Vivin Suresh Paliath
    http://vivin.net

    I like
    1. Re:Here's what Javascript 2 looks like by weston · · Score: 4, Interesting

      I really like the type-safety features

      Fortunately, the type safety features will be optional.

      and the MUCH better way to do OO.

      This is a matter of opinion, and is definitely contested.

      Q: "If you could do Java over again, what would you change?"
      A: "I'd leave out classes" - James Gosling

    2. Re:Here's what Javascript 2 looks like by Pastis · · Score: 5, Informative

      > "If you could do Java over again, what would you
      > change?" "I'd leave out classes," he replied.

      "After the laughter died down, he explained that the real problem wasn't classes per se, but rather implementation inheritance (the extends relationship). Interface inheritance (the implements relationship) is preferable. You should avoid implementation inheritance whenever possible. "

      Not the same as saying that he didn't want java to be OO.

      http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html

  7. HotRuby by DragonWriter · · Score: 4, Informative

    Eich says: "Some of these techniques, like HotRuby, actually translate Ruby into JavaScript."

    HotRuby implements, in JavaScript, a VM that executes Ruby 1.9 bytecode; it does not translate Ruby into JavaScript.

  8. Re:screaming monkey? by larry+bagina · · Score: 4, Interesting

    "Spider Monkey" is the mozilla/firefox javascript implementation. I read screaming as "kicking and screaming" -- ie, IE will get javascript 2 whether they want it or not.

    --
    Do you even lift?

    These aren't the 'roids you're looking for.

  9. Google Web Toolkit? by TheNarrator · · Score: 4, Interesting

    I can't believe nobody brought up GWT (http://code.google.com/webtoolkit/) yet.

    GWT is a system put out by Google whereby you write your code in a subset of Java and then it compiles the Java down to cross-browser compatible speed and size optimized Javascript.

    The implementation of Java is pretty good and includes just about everything you would expect except for threads. It's absolutely effortless to program in compared to hand coded Javascript -- especially for large projects.

    The other benefit is "hosted mode" whereby you run your webapp in a special runtime that lets one use Eclipse's modern interactive debugger to fix bugs in the Java code that gets turned into equivalent Javascript.

    If you want to see a neat demo of what can be done with GWT check out :

    http://www.gpokr.com/

    1. Re:Google Web Toolkit? by AKAImBatman · · Score: 5, Informative

      I've used GWT. Here's the long and short of it...

      Pros: GWT is very cool in that you can quickly write Java-based interfaces that run in the web browser as Javascript. Because GWT includes a wide variety of components, interfaces are super-simple to create. You can even make your own widgets and reuse them as libraries to make even more complex widgets.

      Cons: (Better grab a seat.) It's nearly impossible to debug code outside of the GWT test shell. Which really sucks if your code relies on a web application in some way, but you can't decipher "Error in line 127: b is null". Which brings me to the next major problem. GWT does not integrate with Javascript very well. You can use a JNI-style interface to run bits of Javascript code in a Java method, but for the most part the worlds stay far apart. Which means that you can't easily use GWT objects or Javascript objects interchangeably to solve problems. More often than not, a Javascript object would be faster than the Java code you're writing. But since you can't intertwine them...

      Which brings me to the next con. Because the layout is determined by the construction of the built-in widgets, it's often difficult to achieve a layout that meets the specs. Doing simple things like removing spaces from tables, or applying pre-existing styles invariably end up more difficult to do than they should be. And even when you can apply a style, it applies the style to an element which is inside a container element (or vice-versa), thus preventing you from styling the layout of the specific element you're trying to target.

      Another frustrating aspect is that GWT dumps out hashed file names. Different hashes for every compile, too. Which wreaks all kinds of havoc with source control systems. Ideally you'll want to generate the Javascript code at compile-time because of this mis-feature. Unfortunately, GWT does not ship with an ANT plugin. You can find a few that people have made, but I haven't yet found one that's of particularly high quality.

      Generated GWT code is obviously quite large. Whatever you save with GWT's obfuscator is more than made up for by the fact that GWT compiles in its libraries every time.

      Last but not least (and quite possibly the most frustratingly), you can only plug the components together at compile time. Mixing and matching renderers, data models, and I/O backends at runtime is pretty much a no-no. You get it right when you compile it. Period. Which really reduces the flexibility of the technology. Instead of being able to combine plugins at runtime, you have to create a new project for every variation of the component. Alternatively, you can write your code to have a half-billion runtime settings.

      --

      If you want my advice, learn Javascript. GWT may provide you with a good stop-gap solution, but the trade-offs can be incredibly painful at times. And since Javascript is obviously not going anywhere, you know you'll get a good return on investing in the education. If you need a good place to start, Douglas Crockford has an excellent introduction to the language here. Also, trying READING the Javascript Client Guide. It really does explain the language well, including some of its incredibly advanced features. (That 95% of so-called JS coders have no idea exist.) :-)

  10. The Point: OO != Classes & imp. inheritance by weston · · Score: 5, Interesting

    Not the same as saying that he didn't want java to be OO.

    Oh, no, that's not the point at all. The point is this:

    OO != Classes

    And in fact that Classes may not be the ideal way to orient a program around objects. And the bonus point is that the person who implemented what's the arguable current king of OO languages understands this. He's not the only one. The Drupal Devs also have a thing or two to say on the subject.

    I'm very familiar with the Allen Holub article you referenced -- stumbled across it three or four years ago, and it eventually led me to buy Holub's book on patterns. The takeaway point about the hazards of implementation inheritance is one that I think he overstates, but it's absolutely necessary given the way most people learn OO programing these days. Most books and tutorials hammer on extends and necessarily use examples of class hierarchies because it's necessary to teach what all the OO syntax does, but this really isn't what OO programming is about.

    The interesting thing is that Javascript is one of the few popular languages where this is quite clear. There are weak clases, there is no "extends", and therefore very little magic implementation inheritance. You can code up syntax for this, if you like, as many of the major libraries do, which I think illustrates the power of the model and the language, but by and large, the prototype inheritance method means that you're doing interface inheritance or very explicit implementation sharing. This means the pitfalls Holub points out are easier to avoid, and there's many other bonuses. It also unfortunately means a bit extra work in some cases where implementation inheritance is handy and less dangerous, but it's not all that much, and I think the tradeoff is worth it.

    Now, the next version of Javascript will particularly be nice for developers of libraries who have reasons not to trust the developers using what they're producing, because they'll be able to freeze things they can't freeze now with the static typing and class definitions.

    But I'm pretty afraid a prevalent culture that seems to have a fairly narrowly scoped idea of object orientation and "best practices" is going to clap their hands and grab onto the familiar classes as they approach Javascript, rather than really understand the breadth of the language, and in 3-4 years, you'll have newly-minted team leads fresh from their recent readings of Fowler and GoF talking about tortured design patterns using static types and classes when a little sprinkling of dynamic language will do the job.

    Please, allay my fears by not saying "JS2 finally bring real OO programming to Javascript."

    1. Re:The Point: OO != Classes & imp. inheritance by weston · · Score: 4, Insightful

      instead exposing the virtual method table directly. (Prototype is nothing else)

      Not precisely, since the prototype property also exposes properties, as well as methods. Or, more precisely, methods are properties in javascript, since functions are first-class.

      You cannot really design big systems without those two constructs

      Not at all true. Well, it's tautologically true. You can't design big systems the way that most programmers who currently work on big systems design them in statically-typed explicitly class-based languages. And by some accounts, this turns out to be a huge advantage, because you get a LoC compression similar to what you'd see with Ruby.

      (As for namespaces -- PHP has the same problem, but worse, given that you can't even appropriate static ad-hoc classes as a namespace mechanism. And yet the namespace problem has been more or less practically addressed by conventions, and you can't argue anymore that people aren't building large systems in it.)

      different incompatible inheritance constructs by third party libraries

      It's true composing "extends" implementation inheritance implementations across libraries is likely to get you in trouble. But then again, simply using implementation inheritance can get you in trouble, in C++, in Java. And having to settle on conventions and libraries is not a fatal hit to a project.

      In the end javascript is the classical example of a 95% academic language.

      Acadmic? Why? Because it's functional, or didn't start life with "extends"?

      Javascript's shown itself as quite practical contender in a huge amount of the heavy lifting that's gone on in the RIA space over the last 5 years, and that's not half what's going to happen as it gets traction elsewhere.