Google Web Toolkit

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
I'm building a website at home that contains a fair amount of AJAX and recently started using the Google Web Toolkit (GWT). although it's still early, i have to admit, I'm very impressed. the basic idea behind it is that you write Java code and GWT compiles it into JavaScript. Why would you want that? Here's a few things this offers:

* You can use any Java development tools (Eclipse, IntelliJ, JProfiler, JUnit).
* Static type checking in Java reduces errors. Common JavaScript errors (typos, type mismatches) are caught at compile time.
* Your can write clean, OO Java instead of incomprehensible JavaScript.
* Generated JavaScript is cross browser compatible - you don't have to deal with stupid browser quirks!
* You can test your code with JUnit!
* You can debug the code (step through it)!
* AJAX calls look like regular Java method calls

If you're doing web development with any significant amount of JavaScript in it - especially Ajax - I *highly* recommend you check out GWT.




EDIT: forgot to mention some VERY nice libraries to use in conjunction with GWT:

http://gwt-ext.com/
http://code.google.com/p/rocket-gwt/
http://gwt.components.googlepages.com/
http://gwt-widget.sourceforge.net/
http://gwtiger.org/
 

Modeps

Lifer
Oct 24, 2000
17,254
44
91
I took a look at it when I was investigating AJAX libraries. Unfortunately, I don't know Java well enough to use GWT, so I'm stuck using Scriptaculous because I'm much better with JS.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Man, I would love to be able to code my client-side in C# and have it translated into cross-browser compatible script resources. Maybe I need to learn Java now.
 

imported_Dhaval00

Senior member
Jul 23, 2004
573
0
0
Originally posted by: Markbnj
Man, I would love to be able to code my client-side in C# and have it translated into cross-browser compatible script resources. Maybe I need to learn Java now.

Don't be sad, Mark. This is again one of those M$ ideas that Google was able to evolve before M$... look at http://projects.nikhilk.net/default.aspx. Nikhil has been working on Script# for quite some time. So us .NETters will just have to be patient, I guess.

By the way Nikhil is the mastermind behind many ASP.NET architectural acheivements, as well as IIS's pipeline.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Originally posted by: Dhaval00
Originally posted by: Markbnj
Man, I would love to be able to code my client-side in C# and have it translated into cross-browser compatible script resources. Maybe I need to learn Java now.

Don't be sad, Mark. This is again one of those M$ ideas that Google was able to evolve before M$... look at http://projects.nikhilk.net/default.aspx. Nikhil has been working on Script# for quite some time. So us .NETters will just have to be patient, I guess.

By the way Nikhil is the mastermind behind many ASP.NET architectural acheivements, as well as IIS's pipeline.

Cool, thanks for the tip. Looks like that is exactly the medicine we need.
 

Aikouka

Lifer
Nov 27, 2001
30,383
912
126
I'd give it a try if I could ever get Eclipse to install on my Vista x64 machine. Installed JRE 1.6 (aka v6) and would always boot to an exception filled with a bunch of mumbo-jumbo about wanting version 1.5. So I put in version 1.5 (JRE5) and that didn't work.

Sigh @ Java.
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: Markbnj
Man, I would love to be able to code my client-side in C# and have it translated into cross-browser compatible script resources. Maybe I need to learn Java now.

if you know c#, switching to java will be a piece of cake. IMO, with the giant open source community java has and the huge number of cool, free projects (such as GWT), it's well worth the switch...
 

scootermaster

Platinum Member
Nov 29, 2005
2,411
0
0
Okay, dumb question here: Is there any downside to using this? (Speed, code size, portability, compatibility, code-reuse?) You usually don't get things for free in the programming world, so I'm wondering if someone was to start to develop an AJAX-heavy site, why they wouldn't use this?
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: scootermaster
Okay, dumb question here: Is there any downside to using this? (Speed, code size, portability, compatibility, code-reuse?) You usually don't get things for free in the programming world, so I'm wondering if someone was to start to develop an AJAX-heavy site, why they wouldn't use this?

there are some down sides, all of them interrelated, such as:

1. The JS code that's produced might not be as efficient as custom, hand written JS code for your specific application. the folks at google spent a LOT of time optimizing GWT, however, and in many cases I'd guess it's at least as fast if not faster.
2. If a new browser version comes out, you'd have to wait until GWT supports it.
3. There may be bugs in the framework.
4. The framework probably doesn't allow you to do everything you could do in just plain JS. The plugins/extensions I linked in the OP add a LOT of useful functionality, but in the end, there will be JS functionality you lose when using GWT. Of course, in those cases, nothing stops you from just adding a JS file...
5. Web designers are traditionally familiar with HTML, CSS and JS. Making a jump to Java can be quite daunting and blurs the standard separation of presentation and functionality in a company.
6. Depending on how you code it, you may also be losing some of the separation of content, style & functionality in your code. Without GWT, in modern day web design you have an HTML file (just containers + content), CSS file (styling/layout), and a JS file (dynamic functionality). With GWT, things are a bit more mixed: HTML file (some of the containers, lots of placeholders, some content), CSS file (some styling/layout), Java source code (some content to fill the placeholders, some layout if you use the widgets/panels, dynamic functionality).

Overall, I'd have to say these are all extremely minor. most people use some kind of framework for AJAX anyway, but those frameworks usually just make the JS code a bit prettier & more tolerable. GWT abstracts the JS code away and replaces it with Java, which has tons of advantages that, IMO, far outweigh the disadvantages.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!
 

jman19

Lifer
Nov 3, 2000
11,225
664
126
Originally posted by: kamper
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!

Yeah, these days, JS is quite nice :thumbsup:
 

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
Hmm. Interesting. Are there any Java dev environments as usable as VB/VS? Particularly ones with something as useful as vb's intellisense and particularly some way of turning off case sensitivity?
 

txlonghorn

Senior member
Jul 26, 2004
380
0
76
Originally posted by: brikis98
Originally posted by: scootermaster
Okay, dumb question here: Is there any downside to using this? (Speed, code size, portability, compatibility, code-reuse?) You usually don't get things for free in the programming world, so I'm wondering if someone was to start to develop an AJAX-heavy site, why they wouldn't use this?

there are some down sides, all of them interrelated, such as:

1. The JS code that's produced might not be as efficient as custom, hand written JS code for your specific application. the folks at google spent a LOT of time optimizing GWT, however, and in many cases I'd guess it's at least as fast if not faster.
2. If a new browser version comes out, you'd have to wait until GWT supports it.
3. There may be bugs in the framework.
4. The framework probably doesn't allow you to do everything you could do in just plain JS. The plugins/extensions I linked in the OP add a LOT of useful functionality, but in the end, there will be JS functionality you lose when using GWT. Of course, in those cases, nothing stops you from just adding a JS file...
5. Web designers are traditionally familiar with HTML, CSS and JS. Making a jump to Java can be quite daunting and blurs the standard separation of presentation and functionality in a company.
6. Depending on how you code it, you may also be losing some of the separation of content, style & functionality in your code. Without GWT, in modern day web design you have an HTML file (just containers + content), CSS file (styling/layout), and a JS file (dynamic functionality). With GWT, things are a bit more mixed: HTML file (some of the containers, lots of placeholders, some content), CSS file (some styling/layout), Java source code (some content to fill the placeholders, some layout if you use the widgets/panels, dynamic functionality).

Overall, I'd have to say these are all extremely minor. most people use some kind of framework for AJAX anyway, but those frameworks usually just make the JS code a bit prettier & more tolerable. GWT abstracts the JS code away and replaces it with Java, which has tons of advantages that, IMO, far outweigh the disadvantages.

To me, the main problem with GWT is the same problem that dogged language generation/translation tool for ages: no round-tripping. I investigated a bunch of AJAX toolkits in depth. I really like GWT in concept. However, when I tried to use it for actual clients, it fell short in 2 areas. One is that the generated code is never exactly what the client wants/needs. If I were building the application for myself, I'd have settled for the the default GWT implementation as close enough. However, when client is paying top-dollar for custom application..... there is no settling. Once you start tweaking the generated code, you can't round-trip the code back to Java source. Now you face a big decision: try to hack GWT into generating the code you need, or abandon the Java source and start hand-tweaking the JS code. Either way you go, it kind of negates some of the advantage of GWT.

The 2nd area it fell short for me is that my large clients all have standard look-and-feel for their web applications, and none of them has adopted the Google web application look-and-feel, yet. So, I have to re-skin the entire GWT application. That becomes another PIA.

That's my $0.02
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: txlonghorn

To me, the main problem with GWT is the same problem that dogged language generation/translation tool for ages: no round-tripping. I investigated a bunch of AJAX toolkits in depth. I really like GWT in concept. However, when I tried to use it for actual clients, it fell short in 2 areas. One is that the generated code is never exactly what the client wants/needs. If I were building the application for myself, I'd have settled for the the default GWT implementation as close enough. However, when client is paying top-dollar for custom application..... there is no settling. Once you start tweaking the generated code, you can't round-trip the code back to Java source. Now you face a big decision: try to hack GWT into generating the code you need, or abandon the Java source and start hand-tweaking the JS code. Either way you go, it kind of negates some of the advantage of GWT.

I definitely agree with you that the lack of a round trip can be a bit of a problem, although from what I've seen of GWT so far, the JS it outputs is at least as good as what I would do. Of course, the question is, how do you complete the second half of the round trip? Make a compiler that turns JS into Java? Some interface for GWT to accept custom JS code (you can include custom JS files as-is...)?

One great thing about GWT is that it's open source. If you don't like the exact JS code they are spitting out - but you do like the Java to JS framework in general - you can easily change or extend GWT for your own purposes.

Originally posted by: txlonghorn
The 2nd area it fell short for me is that my large clients all have standard look-and-feel for their web applications, and none of them has adopted the Google web application look-and-feel, yet. So, I have to re-skin the entire GWT application. That becomes another PIA.

That's my $0.02

I don't really see that as a big problem - in fact, you can either skin the GWT application or you can skin your own code, and the amount of CSS will probably be roughly the same. Moreover, some of the extensions I included feature widgets w/ various (skinnable) look & feels and again, you can always create/customize your own widgets since GWT is open source...
 

Martin

Lifer
Jan 15, 2000
29,178
1
81
Originally posted by: jman19
Originally posted by: kamper
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!

Yeah, these days, JS is quite nice :thumbsup:

I was just about to say that - JS is probably the most misunderstood and unappreciated language out there. I've been doing more and more of it lately and I find that the more I use it, the more I love it, to the point where going back to things like PHP and (god forbid) Java makes me want to start crying

While the language itself is fantastic, it certainly could use better tools and libraries. Thankfully with things Firebug, ExtJS 2.0, Prototype 1.6, and AIR its increasingly feasible to write the bulk of your apps in JS.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
My biggest complaint about Javascript is the lack of a GOOD development environment.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
It's a great language for what it was designed to do, and as you say it is getting easier to use it in a professional way as the tools improve. I'm an MS developer for the most part, and VS2008 integrates script debugging more gracefully than previous versions. That said, it's a dynamically typed language, which almost, but not quite, means the same thing as "toy" in my book. Obviously you need it for some client-side things, and those are the things I think it should be used for, and occasional hacking around.
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
Originally posted by: Martin
Originally posted by: jman19
Originally posted by: kamper
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!

Yeah, these days, JS is quite nice :thumbsup:

I was just about to say that - JS is probably the most misunderstood and unappreciated language out there. I've been doing more and more of it lately and I find that the more I use it, the more I love it, to the point where going back to things like PHP and (god forbid) Java makes me want to start crying

While the language itself is fantastic, it certainly could use better tools and libraries. Thankfully with things Firebug, ExtJS 2.0, Prototype 1.6, and AIR its increasingly feasible to write the bulk of your apps in JS.

I have been coding for a long time and in all honesty, i'm shocked that anyone can prefer coding in JavaScript over Java... I mean, obviously they are vastly different languages for different purposes, but if all else was equal and you could pick Java or JavaScript, I'd wager 99% of experienced software engineers would pick Java. that's not to say that Java is the best language out there, but compared to JS, it's not even a contest.

one of the reasons we have all these frameworks - ExtJS, ProtoType, and of course, GWT - is because JS is such a PIA to work with. lack of proper scope, proper typing, proper debugging tools, proper class/interface definitions, strange syntax, weak unit testing frameworks, etc etc make it a nightmare to deal with. to compound the situation, different browsers handle JS differently, making you have to deal with tons of stupid browser quirks all day long.

to each their own of course, but honestly, i'm curious what on earth makes you prefer JS over Java?
 

Martin

Lifer
Jan 15, 2000
29,178
1
81
Originally posted by: brikis98
Originally posted by: Martin
Originally posted by: jman19
Originally posted by: kamper
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!

Yeah, these days, JS is quite nice :thumbsup:

I was just about to say that - JS is probably the most misunderstood and unappreciated language out there. I've been doing more and more of it lately and I find that the more I use it, the more I love it, to the point where going back to things like PHP and (god forbid) Java makes me want to start crying

While the language itself is fantastic, it certainly could use better tools and libraries. Thankfully with things Firebug, ExtJS 2.0, Prototype 1.6, and AIR its increasingly feasible to write the bulk of your apps in JS.

I have been coding for a long time and in all honesty, i'm shocked that anyone can prefer coding in JavaScript over Java... I mean, obviously they are vastly different languages for different purposes, but if all else was equal and you could pick Java or JavaScript, I'd wager 99% of experienced software engineers would pick Java.

one of the reasons we have all those frameworks you mention - ExtJS, ProtoType, etc - is because JS is such a PIA to work with. it also doesn't help that different browsers treat JS differently, making you have to deal with tons of stupid quirks all day long.

to each their own of course, but honestly, i'm curious what on earth you like about JS that you can't do with java?

Well, the analogy I always make is that Java makes me feel like I'm writing legal contracts, while with JS it's more like having a conversation. Java is just so damn verbose, and everything has to be laid and and specified in such detail that it starts to drag you down after a while. JS on the other hand is really flexible and tends to get out of your way. You can do either prototype or classical inheritance if you need it, you can use anonymous functions and objects (no need to declare them before using them), you can easily create dynamic classes, eval code etc, it just makes it a joy to use.

As for the libraries, well, the JS spec itself is pretty simple - its just EMCAScript plus some browser supplied objects (DOM, String, Number, Window etc). Things like prototype and JS simply take the place of APIs that are included by default in Java. But thanks to them, browser compatibility much less of an issue. With Prototype 1.6 you can create whatever UI you want and never type a single line of HTML and it'll guarantee execution on the majority of browsers (FF1.5+, IE6+, Safari2+, Opeara 8+.. basically, all the ones you'd care about).

Anyway, I'll let some of JS's evangelizers say it better than me:
http://www.joelonsoftware.com/items/2006/08/01.html
http://javascript.crockford.com/javascript.html
http://javascript.crockford.com/little.html
http://steve-yegge.blogspot.com/2007/12/codes-worst-enemy.html
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Originally posted by: brikis98
Originally posted by: Martin
Originally posted by: jman19
Originally posted by: kamper
Originally posted by: brikis98
* Your can write clean, OO Java instead of incomprehensible JavaScript.
That's not an advantage, javascript is a very nice language!

Yeah, these days, JS is quite nice :thumbsup:

I was just about to say that - JS is probably the most misunderstood and unappreciated language out there. I've been doing more and more of it lately and I find that the more I use it, the more I love it, to the point where going back to things like PHP and (god forbid) Java makes me want to start crying

While the language itself is fantastic, it certainly could use better tools and libraries. Thankfully with things Firebug, ExtJS 2.0, Prototype 1.6, and AIR its increasingly feasible to write the bulk of your apps in JS.

I have been coding for a long time and in all honesty, i'm shocked that anyone can prefer coding in JavaScript over Java... I mean, obviously they are vastly different languages for different purposes, but if all else was equal and you could pick Java or JavaScript, I'd wager 99% of experienced software engineers would pick Java. that's not to say that Java is the best language out there, but compared to JS, it's not even a contest.

one of the reasons we have all these frameworks - ExtJS, ProtoType, and of course, GWT - is because JS is such a PIA to work with. lack of proper scope, proper typing, proper debugging tools, proper class/interface definitions, strange syntax, weak unit testing frameworks, etc etc make it a nightmare to deal with. to compound the situation, different browsers handle JS differently, making you have to deal with tons of stupid browser quirks all day long.

to each their own of course, but honestly, i'm curious what on earth makes you prefer JS over Java?


I've been "coding" for quite a while, and I don't mind writing JS code at all. I worked a little bit with Java a couple of years ago (for about 6 months on and off), and I agree with Martin's comments. In fact, I shudder at the thought of having to work with Java again. My favorite language to work with is C++, and I don't mind working with C# too much. I have found JS to be pretty much pain-free for the two browsers I target (IE + Firefox), but this may be because I don't have to worry about supporting older browsers too much.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Well, the analogy I always make is that Java makes me feel like I'm writing legal contracts, while with JS it's more like having a conversation

I think that's a great analogy. I also think that when it comes to asserting the logical correctness of programs, in applications where that is important, a contract is better than a conversation .
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Originally posted by: Markbnj
Well, the analogy I always make is that Java makes me feel like I'm writing legal contracts, while with JS it's more like having a conversation

I also think that when it comes to asserting the logical correctness of programs, in applications where that is important, a contract is better than a conversation .

I agree with you, but in general, I leave the "contract" part for the server while having some fun on the client/browser side. This provides a lot of flexibility and modularization. The most recent application I'm working on is coded in pretty much 90% JS and it's great to be able to make so many changes without ever touching the server code. I would hate to give this up and rely on a toolkit to generate the JS code.
 

brikis98

Diamond Member
Jul 5, 2005
7,253
8
0
out of curiosity, Singh and Martin - do you use Javascript in a company/team setting? that is, in one where many people are working on the same code?

while the links you posted show interesting features of JavaScript - really, just standard functional programming features - the language is generally hard to use in a development environment. JS has very little in the way of compile time errors, it can be a nightmare to debug (IE loves to tell you the error is ALWAYS on line 1, char 1), there are few good unit testing frameworks, it has problems with proper scoping/variable declaration/etc, and any functional programming language - where you can wrap an absurd amount of functionality into one line - is naturally very tough to read and maintain. there is a reason most modern languages are object oriented and similar to Java and that's because in a production environment, developing, maintaining and debugging JS is very very hard.

now don't misunderstand me. functional programming is very powerful and has it's place, but IMO, coding for UI and applications is NOT it. and yes, obviously large, effective applications have been built with JS, but not without a lot of blood and sweat. google, of all companies, is a master of JS (gmail, gcal, gdocs, etc etc), and they are using this framework themselves. that should probably tell you something...

i also agree that, in general, for simple things, JS has less overhead than Java. but if we were doing something simple, we wouldn't be looking for a JS framework to begin with. as soon as the complexity of the code increases, Java - in part because of all the "legal contracts", as you put it - is far more effective.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |