views:

585

answers:

3

I'm in a process of selecting an API for building a GWT application. The answer to the following questions will help me choose among a set of libraries.

  1. Does a third-party code rewritten in GWT run faster than a code using a wrapped JavaScript library?
  2. Will code using a wrapped library have the same performance as a pure GWT code if the underlying JavaScript framework is well written and tuned?
+1  A: 
  1. Depends on how well the code is written.
  2. I would think so.

Generally look at the community around a 3rd party library before using it unless it is open-source (so you can fix bugs) and specifically look for posts concerning bugs - how quick do the maintainers respond to items. How long is a release cycle, etc.

graham.reeds
+2  A: 

While JavaScript libraries get a lot of programming eyeballs and attention, GWT has the advantage of being able to doing some hideously not-human-readable things to the generated JavaScript code per browser for the sake of performance.

In theory, anything the GWT compiler does, the JavaScript writers should be able to do. But in practice the JS library writers have to maintain their code. Look at the jQuery code. It's obviously not optimized per browser. With some effort, I could take jQuery and target it for Safari only, saving a lot of code and speeding up what remains.

It's an ongoing battle. The JavaScript libraries compete against each other, getting faster all the time. GWT gets better and better, and has the advantage of being able to write ugly unmaintainable JavaScript per browser.

For any given task, you'll have to test to see where the arms race currently places us, and it'll likely vary between browsers.

Nosredna
I totally agree. You can read on the blog and groups that the JavaScript optimizations (per browser) are pretty serious. For example: on some browsers if(!!x) is faster than if(x) because of the forced coercion to boolean over the implicit cast. These are the kind of things you have going for you.In short: if the Java->GWT->JS is sensibly written it will be as fast or faster than what you could possibly write in JavaScript.
angryundead
Also, check this out: http://letusdemo.appspot.com/ and look how the JQuery and GQuery (GWT port of JQuery) compare.
angryundead
@angryundead. Yeah, GQuery wins by quite a bit. It's a bit out of date, though. And does GQuery keep up with the advances made in jQuery?
Nosredna
+1  A: 

In some cases you don't have another option. You can not rewrite everything when moving to GWT.

In a first step you could just wrap your existing code in a wrapper and if it turns out to be a performance bottleneck you can still move the code to Java/GWT

The code optimisation in GWT will certainly be better than what the majority of JS developpers can write. And when the Browsers change, it is just a matter of modifying the GWT optimizer and your code will be better tuned for the latest advances in Js technology.

David Nouls