Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
Portables (Apple) Software The Internet Upgrades

Next-Gen JavaScript Interpreter Speeds Up WebKit 193

JavaScript is everywhere these days. Now WebKit, the framework behind (among others) Safari and Safari Mobile, as well as the yet-unreleased Android, is getting a new JavaScript engine called Squirrelfish, which the developers claim provides massive speedups over the previous one. The current iteration of the engine is "just the beginning," they claim; in the near future, six planned optimizations should bring even greater speed. With JavaScript surviving as a Web-page mainstay despite many early gripes, and now integral to some low-powered mobile devices, this may mean many fewer wasted seconds in the world.
This discussion has been archived. No new comments can be posted.

Next-Gen JavaScript Interpreter Speeds Up WebKit

Comments Filter:
  • by AKAImBatman ( 238306 ) <akaimbatman AT gmail DOT com> on Tuesday June 03, 2008 @02:53PM (#23641915) Homepage Journal
    ...how does this compare to Tamarin [mozilla.org]? With Javascript running for longer periods of time, a runtime-optimizing JIT seems to make a lot of sense. SquirrelFish's optimized bytecode engine sounds interesting, but I can't help but feel that it's going to fall short in the next-gen race for Javascript performance.

    Of course, anything that improves JS performance in browsers (making some of the libraries faster and/or hardware accelerated always helps... hint, hint!) is a win for the consumer. And from that perspective this sounds very interesting. :-)
  • Re:squirrelfish? (Score:4, Interesting)

    by Anonymous Coward on Tuesday June 03, 2008 @03:10PM (#23642185)

    squirrelfish? What's next? rabbitelephant? curvaceous coelacanth? fishfishfishrabbitfish? We desperately need an automatic "hip open source software name generator" before someone gets hurt.

    Usually what happens is a development team uses themed codenames to easily distinguish product versions. In this case, they're probably using fish names. I worked somewhere with the same theme. We had all sorts of fish names and eventually they got a bit wacky (aquaman). The problem is when in OSS or other open development models, those names become public instead of a properly chosen name. With OSS, this happens because name recognition builds up as people discuss the unfinished software. We only had this happen once, where Man-O-War was demoed for the defense department and they liked the name so much we had to keep it for PR reasons.

  • by Anonymous Coward on Tuesday June 03, 2008 @03:13PM (#23642233)
    It feels like Safari is moving so incredibly quickly. Webkit 3.1 already felt around twice as fast as webkit 3.0 in terms of javascript execution; now SquirrelFish is around one and a half times as fast again... in what's basically its first stable implementation. And they're already targetting optimisation points, and it's already caught up to Tamarin (and iirc webkit 3.1 is at least on par with firefox 2/3). Absolutely amazing.

    The iPhone is the one to really benefit from this, because it's where the pauses are currently noticeable.

    And IE really, really suffers in comparison. Microsoft has to be wincing about all this, if only for pride's sake... I'd love to see speed improvements to IE 8 beyond the what's known already [ejohn.org], though the DOM speed improvements will help a lot for parity.
  • by kai6novice ( 1093633 ) on Tuesday June 03, 2008 @03:13PM (#23642251)
    I think all the future web browser should have a standard javascript and CSS, plug-and-play function, allowing users to choose their favorite javascript interpreter and CSS interpreter. For instance, I like Safari's javascript interpreter, but firefox CSS interpreter.. then I can just get those plug-in and put it in my browser (which have a built in HTML interpreter.)
  • by Daniel Dvorkin ( 106857 ) * on Tuesday June 03, 2008 @03:23PM (#23642375) Homepage Journal
    It's the old "modular vs. monolithic" argument -- do you write your app as a bunch of small pieces that all communicate through some standard protocol, so you can swap them in and out and upgrade them at will, or do you make everything tightly coupled and interdependent? Browsers, like most apps, tend to go back and forth on this, because there are real advantages and disadvantages to each approach (and most apps end up meeting somewhere in the middle.) Every few years someone comes along with an idea that promises to Revolutionize! Programming! by making everything modular and completely independent, and everyone gets all excited about it and plays with it for a while, and then comes to the conclusion that if it works, it's still too slow. The good ideas that come out of these Revolutions! In! Programming! get absorbed into the mainstream (e.g. OOP, and to some degree microkernels) but they never seem to take over completely.
  • Re:iPhone Safari (Score:2, Interesting)

    by Samgilljoy ( 1147203 ) on Tuesday June 03, 2008 @03:45PM (#23642669)

    Jeeze, I wouldn't mind if Microsoft picked up on one of these as well. Imagine if IE actually used the same standards as the browsers us open sourcies like to use.

    Wouldn't the effect of such compliance threaten the fabric of the space-time continuum or something?

  • by p0tat03 ( 985078 ) on Tuesday June 03, 2008 @04:08PM (#23642995)

    I think early gripes were due to the fact that practically nobody was using JavaScript in a productive way. No, we don't want bouncing images, no, we don't want insane drop-down menus that don't behave right, and no, we don't want the web page to break back/forward buttons by doing some underhanded sly scripting work. Or worse! We don't want no stupid popups that ask me for my name.

    I think JavaScript has proven now that it has *some* redeeming qualities and legitimate uses :)

  • by Etcetera ( 14711 ) on Tuesday June 03, 2008 @04:16PM (#23643087) Homepage
    With there finally being a nice Javascript implementation that cleanly and efficiently sends to bytecode, I'm wondering if the dynamically-typed-specs in the Parrotcode [parrotcode.org] project could be of some assistance. The ECMAscript implementation they're already working on still has a long way to go, and this would be one way to help consolidate development efforts -- plus get some additional motivation behind both projects.
  • by samkass ( 174571 ) on Tuesday June 03, 2008 @04:19PM (#23643127) Homepage Journal
    According to the article the Windows version of SquirrelFish aren't as optimized as the Mac and Linux versions because of some API dependencies, although I haven't seen any benchmarks.

  • by Anonymous Coward on Tuesday June 03, 2008 @04:28PM (#23643239)
    Yo
    Even Javascript creator Brendan Eich doesn't think much of it as a programming language :
    http://weblogs.mozillazine.org/roadmap/archives/2008/04/popularity.html#more

    Read what He has to say about it :

    "I was recruited to Netscape with the promise of "doing Scheme" in the browser."[...]"Whether any existing language could be used, instead of inventing a new one, was also not something I decided. The diktat from upper engineering management was that the language must "look like Java". That ruled out Perl, Python, and Tcl, along with Scheme. Later, in 1996, John Ousterhout came by to pitch Tk and lament the missed opportunity for Tcl.

    I'm not proud, but I'm happy that I chose Scheme-ish first-class functions and Self-ish (albeit singular) prototypes as the main ingredients. The Java influences, especially y2k Date bugs but also the primitive vs. object distinction (e.g., string vs. String), were unfortunate."
    [...]
    "Is JavaScript popular? It's hard to say. Some Ajax developers profess (and demonstrate) love for it. Yet many curse it, including me. I still think of it as a quickie love-child of C and Self. Dr. Johnson's words come to mind: "the part that is good is not original, and the part that is original is not good.""

    The only reason Brendan Eich created that damned language was because Netscape wished to create their own language so they could stranglehold the web, instead of using something that was already standard. That much they did, indeed, looking at the state of the web today, we only somewhat recovered because of a Microsoft invention (XmlHttpRequest was created at Microsoft !) and Javascript prototyped object orientation allowed to work around its language deficiencies with powerful libraries. But they are ugly hacks, not work of art.

    Frankly, only someone who doesn't know there are languages like Lisp, Smalltalk, Scheme, Haskell, Ocaml, Ruby, Python and so on would think Javascript is any good. Javascript sucks. The end. Nearly all implementations were of the slowest dynamic language implementations possible (ruby notwithstanding), all had lots warts, the language itself grew with lots of warts (after all in the beginning javascript was intended to be used as a toy to add little bits of dynamism in the browser) and it has no standard library any good.
  • by jamshid ( 140925 ) on Tuesday June 03, 2008 @04:30PM (#23643277)
    This was a really interesting article about the kind of optimizations javascript is getting. Btw, it still amazes me that after the GUI class library wars of the 90s, and all those Java ui frameworks in the early 2000s, "javascript over http" is state of the art in human-computer interfaces. Anyone who would have accurately predicted this future would have been labeled a madman.

    http://steve-yegge.blogspot.com/2008/05/dynamic-languages-strike-back.html [blogspot.com]

    "Why JavaScript? Well, it was Ajax. See, what happened was... Lemme tell ya how it was supposed to be. JavaScript was going away. It doesn't matter whether you were Sun or Microsoft or anybody, right? JavaScript was going away, and it was gonna get replaced with... heh. Whatever your favorite language was.

    I mean, it wasn't actually the same for everybody. It might have been C#, it might have been Java, it might have been some new language, but it was going to be a modern language. A fast language. It was gonna be a scalable language, in the sense of large-scale engineering. Building desktop apps. That's the way it was gonna be.

    The way it's really gonna be, is JavaScript is gonna become one of the smokin'-est fast languages out there. And I mean smokin' fast."
  • Re:Real question: (Score:4, Interesting)

    by paulpach ( 798828 ) on Tuesday June 03, 2008 @04:31PM (#23643295)

    I am pretty sure that KHTML has been merged/dropped and there is only WebKit in Konqueror now. But I am subject to correction on this.

    no, konqueror is using KHTML and will use it in the foreseeable future. There is a google summer of code to work on the webkit kpart [google.com] so that konqueror will be able to use webkit by the end of the summer, but it will probably wont be mainstream for a while:

    A while ago, konqueror developers posted a FAQ [froglogic.com] describing the future of KHTML. As of today, it still applies

    A posibility is that, a new browser may be added to kde, that will be tunned for web browsing as opposed to konqueror which is a swiss army knife. Kind of what Dolphin did for file management. There is already a webkit based browser [google.com] in the works that could achieve this in the future.

  • by sqldr ( 838964 ) on Tuesday June 03, 2008 @05:31PM (#23644069)
    the framework behind (among others) Safari and Safari Mobile,

    It's bad enough that web developers ignore my minority browser (rather than defaulting it to the same template as safari), but ignoring the history of webkit completely must be hugely insulting to the authors of khtml. Give them some credit.
  • by Gavagai80 ( 1275204 ) on Tuesday June 03, 2008 @06:55PM (#23645105) Homepage
    Konquoror doesn't use webkit (yet), so it'd be silly to lengthen every summary to insert "and by the way, webkit owes a lot to konqueror's KHTML." Not compulsively mentioning something where it's irrelevant to the subject isn't the same as ignoring something.
  • by Estanislao Martínez ( 203477 ) on Tuesday June 03, 2008 @07:22PM (#23645367) Homepage

    Heh, that's what I thought at first as well (oh look, doubling speed every release, they must still be at the bottom of the curve) - but then how is it that they're essentially in the lead now? Or are you saying *all* previous js interpreters have been bad?

    I don't know anything about Javascript interpreters in particular, but as a general rule, interpreters for any sort of "scripting" or "dynamic" languages tend to be pretty simplistic and weak. There are a lot of techniques for making language implementations run faster, but they almost always get applied to systems that emphasize compilation.

    Even when people implement dynamic languages by compiling to bytecode, they tend to write very simple VMs where the operations are at a fairly high level, and are all costly to execute. The "compilers" tend to do very simple and quick translations to bytecode, without much optimization, because when compilation happens at runtime, you want to minimize compilation time. The bytecode VMs also usually do very little to optimize bytecode; there's hardly ever any type or data flow analysis of bytecode, bytecode-to-bytecode transformations, etc.

    Nearly every interpreter out there could be made a lot faster without a lot of work.

  • Still seems slow... (Score:5, Interesting)

    by Equuleus42 ( 723 ) on Tuesday June 03, 2008 @10:47PM (#23647015) Homepage
    I just loaded the latest nightly of WebKit, which from what I gather is supposed to be using Squirrelfish, but it still seems to run the "Wundermap" at wunderground.com more slowly than Firefox 3.0RC1. I consider the Wundermap to be the ultimate browser test, as it has to process so much JS and images... I recently tried running it on a Mac Pro 8-core at the local Apple store, and it still loaded slowly! The Mac Pro absolutely flew through everything else I threw at it, including playing multiple HD movies at the same time, but when loading the Wundermap, it is almost as slow as my puny 2.0 GHz G5.
  • by cryptoluddite ( 658517 ) on Tuesday June 03, 2008 @11:23PM (#23647217)

    they began by interpreting everything, but if you spent a lot of time executing a part of the code, it will aggressively optimise it. The newer Java VMs do the same thing.
    Newer as in since 1.2... ten years ago.

    I have to disagree with you about Smalltalk. Before it in performance are LISP and on the great benchmark shootout even LuaJIT (!) is faster than VisualWorks smalltalk -- vw is pretty fast for a smalltalk. Smalltalk has been optimized a lot, but it's not really a 'fast' language.

    For most JavaScript, this is a complete waste of time. It is very rare for JavaScript to run for more than a fraction of a second at a time and so latency caused by interrupting execution much worse than just running it slightly more slowly. The ActionScript VM in Flash is very different, since it is designed to run scripts that stay running for minutes at a time and are fairly CPU intensive.
    JavaScript will be the main programming language in the next decade at least, imo, and improving execution speed of JavaScript is never a waste of time. The faster it is, the more it will be used.
  • by TheRaven64 ( 641858 ) on Wednesday June 04, 2008 @08:02AM (#23649825) Journal
    I forgot to count Lisp - SBCL really sets the standard for how fast dynamic languages ought to be. You are right that LuaJIT is faster than Smalltalks (I'm really surprised it's faster than VW, although looking at the benchmarks it seems performance is pretty close, except for two cases where VW does really badly. Compiling Smalltalk is harder than Lua, because all of the flow control is done via calls to closures (an if statement in Smalltalk is done by sending an ifTrue: message to an expression with a closure as an argument), while Lua has explicit flow control, so I'm not entirely surprised. My point was not to compare specific languages, but rather execution techniques (JIT vs Bytecode vs interpreted AST).

    JavaScript will be the main programming language in the next decade at least, imo, and improving execution speed of JavaScript is never a waste of time.
    Oh, I completely agree. JavaScript certainly isn't my favourite language, but it's a lot nicer than any of the other mainstream languages at the moment. My point is not that it's not worth optimising, it's that many traditional optimisation approaches will have a negative impact on user experience. A lot of JavaScript 'programs' at the moment have a tiny CPU usage and complete very quickly. The test of the new implementation took 2 seconds to complete with a bytecode interpreter. In this kind of situation, the rules are very different.

    Compare something like TCC to GCC. TCC can compile and run a short program in two seconds, although it does hardly any optimisation. GCC will still be in the middle of running optimisations by the time TCC has finished running the program. On the other hand, compare a server-side component of a web app. GCC may take a few minutes to compile it while TCC would take a few seconds, but the version compiled with GCC will be able to service twice as many clients on the same hardware. Something like Google Spreadsheet, or browser-based games, are the same. They use enough CPU power that adding a little compiler overhead for better code is a net gain. Things like dynamic menus and the Slashdot background comment loader aren't - they run fast enough on a crappy JS implementation, and on a faster one they are speed-limited by the network, not the CPU. For these, a fast bytecode interpreter will always be (or, at least, seem) faster than an aggressive JIT, because the time they spend executing is so small.

  • by samkass ( 174571 ) on Wednesday June 04, 2008 @09:51AM (#23651281) Homepage Journal
    [citation needed]

    I try not to be a Java apologist on Slashdot, but the latest JDK6 (especially in -server mode) and public builds of JDK7 are awfully fast. Considering Objective-C's dynamic lookup overhead and lack of inlining opportunities, is it really much faster? Especially when you're running it on a chip architecture other than the one it was compiled for, such as moving between some of the Atom, Core, AMD, and virtual machines. (Although I suspect the LLVM stuff will bring Objective-C up to Java performance in the latter case.) And, of course, Java runs very fast on chips that have native Java bytecode execution capabilities-- like the one in the iPhone (although Apple refuses to activate it and lets it go to waste.)

    Also, as someone else pointed out, the "newer" Java VMs have been re-optimizing commonly executed code for a decade now, so that's not really very new. I think your Java news may be a little out of date.

    Finally, I'd like to point out that the language choice also affects the selection of algorithmic efficiency. I think this is where Objective-C really falls down compared to Java. Java's simple syntax and rich standard library lead to a very large algorithmic selection available at many points in coding. Cocoa on the Mac somewhat makes up for this lack in Objective-C, but it's still catching up.

  • by Paperkirin ( 888073 ) on Wednesday June 04, 2008 @12:53PM (#23654909)
    Many people seem to get rather uptight about this. KHTML (an open-source project) was forked to produce WebKit, since KHTML didn't fit someone's (Apple's) needs. That fork is also open-source, and has since overtaken KHTML in popularity. What exactly is the problem with this sequence of events? Isn't the ability to fork one of the tenets of OSS?
  • Apple forked because (Score:1, Interesting)

    by Anonymous Coward on Friday June 06, 2008 @04:47PM (#23687245)
    a) khtml had a clean codebase
    b) it was open source, so they could grab it
    c) they could develop Safari in secret

    Whether or not this is good for the rest of us is debatable. If you aren't a KDE user, it doesn't matter. If you are, then you can be sad at some of the community infighting. And that it will make some things harder:

    Its worth noting that in the time since they forked, they diverged the codebase enough to make a merge problematic.

    It would also make open source developers unpaid apple employees, if they were to switch from khtml to webkit. khtml developers do it because they want to help kde, not because they want to help apple/todays's cell phone company/etc make a profit. They care about their users and they do it because it's interesting.

A morsel of genuine history is a thing so rare as to be always valuable. -- Thomas Jefferson

Working...