

Ask HN: Your opinion on GWT vs raw JS - freebsd_dude

Im considering starting a new web app and want to know more about GWT vs just Javascript (GWT compiles Java to Javascript). Does GWT offer productivity gains over just using JS? Any tips on using GWT?
======
nostrademons
You've left out a third option: using a mature pure-JavaScript library like
JQuery, Closure, or YUI.

IMHO that's the best of the options, because you can fall back to pure JS if
you need extra flexibility or speed, and yet still don't have to deal with
cross-browser bugs.

~~~
freebsd_dude
ok yes I know about those libraries...I guess what Im asking is why use GWT
when such libraries exist?

~~~
nostrademons
If you have a piece of algorithmic code that really needs to exist on both the
server or the client, and maintaining two versions of it will be too much of a
pain. That's why Wave uses it (the Wave team would probably give you other
reasons too, I've heard they like it, but that's the only technically
defensible one IMNSHO).

If you want to have the same code run on both the server and client, your only
options (that I know of) are GWT, server-side JS like Rhino or V8 or Node.js,
and Pyjamas. GWT's the most mature of those.

Also, a _social_ reason to use GWT (and perhaps the real reason Wave uses it)
is if you know Java and don't want to learn JavaScript. This doesn't hold much
water with me - what sort of a programmer wouldn't want to learn a new
language? and JS is a pretty nice one all things considered - but it's
convincing for lots of other folks.

~~~
bmelton
This.

One of my developers is crazy about GWT, and has shoe-horned it into a number
of apps that he's primed, and it's proven to be problematic for a number of
reasons.

The main problem we have is that a lot of our apps fit into a larger portal,
so we have to worry a LOT more about JavaScript and CSS collisions, and
generated JS/CSS just doesn't work well for that. Outside of a portalized
environment, it might not be THAT bad, but for us, it's proven painful.

In the event that you find yourself duplicating your server side code and
client side code, or writing excessive form validation to match server-side
constraints, something like GWT is probably the way to go.

------
scorpioxy
Disclaimer: I've never used GWT professionally before.

I think its a good idea if your web application is driven by the JS instead of
just using it to add interactivity. As in, something like Gmail or wave which
are basically "javascript applications" rather than "web applications", if you
know what i mean.

JS can get a bit annoying when trying to impose the needed structure to write
big applications. That structure is "built-in" when using something like Java.

Also, with a JS-heavy application, you'd need to take care of the different
browser quirks(via library or otherwise). Apparently, GWT can take care of
this for you.

Having said that, I don't typically like "generated" code. At least not code
that I don't generate myself.

~~~
freebsd_dude
thanks. what development tools do you use to develop JS applications?

~~~
scorpioxy
Oh just the typical stuff. I'm old school so...

Your favourite text editor(I use vim) or you can be a bit more fancy and go
with something like Netbeans or Eclipse(although I always go back to an
editor). And firebug for debugging.

You can add a bunch of stuff to the mix, but that's all I need really.

(Oh, you might also want to throw in a mini-fier for when you're done.)

------
eliot_sykes
If you use GWT integrate it nicely into your build process. Worked at a place
where it was a bit klunky whenever you made a change to the GWT code and
subsequently GWT has left a bad taste in my mouth but I think that's probably
unfair.

If we'd taken the time, we could have ironed out the klunkiness.

Might be worth building a vertical slice of you app, first with jquery (or
another JS library) and then with GWT and see which one suits it better.

------
va_coder
I love my JQuery

