19 thoughts on “how to say hello world with JavaScript

  1. It is located within the script tag within the hidden iframe. This iframe is apparently injected into the page by the gwt.js script. Correct? 🙂

  2. I know that some people prefer to write in Java over JavaScript but this is just stupid. How hard could it be to translate:import com.google.wtk.browserom;class Test extends WebPage { public static void main(String[] args) { window.alert('Hello World'); }}to <script>alert('Hello World');</script>

  3. Well, I do prefer JS but please consider that GWT is much more than just a "Hello World" example. My company is already evaluating GWT as it has nice set of widgets (not to be confused with Opera widgets) and is easier to connect Java-faked Javascript frontend with Java-based backend.Anyway please do not make statements right after seeing one silly example.

  4. Well, maybe we should not judge GWT on one example – but in my opinion the example seems to demonstrate one thing quite nicely: if you use GWT you get nice widgets and can write in Java (which is good for you if that's what you prefer) but it comes at a cost: what you sacrify is maintainability and debuggability of the end product. So if your app doesn't work as expected in IE8, good luck trying to understand the issue. If you want your apparently very simple web app to work in more browsers than GWT supports (see browser sniffing in http://code.google.com/webtoolkit/documentation/examples/helloworld/com.google.gwt.sample.hello.Hello.nocache.html?0&1175090525093 for example).GWT is such stuff browser QA's nightmares are made of.

  5. Well, I'll probably use it for intranet app so only Opera and Firefox are considered :)What I say is that I also prefer pure Javascipt, which I know better that Java. But webapps are getting complex than one could imagine few years ago. Maybe it's time for frameworks, another abstraction layer, magic box. Maybe one day one will write in his CV that he knows GWT, propotype, jQuery, not the Javascript. I hope not but the future will tell.I do not understand exacly what's "under the hood" of PHP to use it. And when I discover bug in PHP I go to bugtracker not to C sources. So when GWT will not work in IE8, Google should be the one who will fix it not me. Heh, but this world isn't perfect :)Anyway I understand that GWT sources debugging can be a hard work. And seeing how different Google services work in Opera I could only wish you luck… 🙂

  6. When I present GWT at conferences (including one recently in Oslo, which seems like a very cool place, btw), I always make sure to mention that you wouldn't really gain anything by writing something as simple as "Hello, world" using GWT. Out of context, the output does indeed seem silly. But it is a mistake to extrapolate from that a conclusion as to how effective GWT is for larger AJAX apps. That seems to be happening here, which makes me want to clarify a little bit about the engineering philosophy of GWT.When you start to build up a larger code base, GWT compiler optimizations really start to have a very positive impact on size and speed that couldn't be achieved easily with handwritten script. There is an entire class of optimizations (e.g. dead code elimination, polymorphism removal, inlining) that stem from starting with the Java language (because it has a static type system). So, while "Hello, world" is ~25K (hilariously large, granted), please also note that "Kitchen Sink", which includes *all* of the GWT widgets, is only 95K in the latest version of GWT. Because of compiler optimizations, the marginal size cost of additional code is very small. This benefits the code you write with GWT, too.If you actually want to understand what makes GWT tick, please take a minute to read "Making GWT Better", our open source charter at http://code.google.com/webtoolkit/makinggwtbetter.html I'd like to think that people are at least evaluating GWT relative to its actual aims rather than in a vacuum.

  7. I'm sure toolkits such as GWT and ASP.NET AJAX have their merits: for instance for serverside developers that don't want to bother with clientside technologies but still want to slap on a Web2.0 label on their products because it sells better :PAll in all these toolkits are still a big black box when it comes to the clientside code; nothing more than mere code-generators. Essentially at the end of the day it doesn't really teach you anything or stimulate you to actually learn a new technique. It's just point and click et voilá (look Mum, I can do javascript!).Although these generated javascripts probably do a pretty good job at abstracting most differences between browsers (although browser-sniffing is an absolute no-go, Microsoft has already made that mistake before) there is absolutely no guarantee that it does a perfect job nor that the compromises made are really necessary (why does GWT use iframes iso XMLHttpRequest? To support browsers like IE4?) or that it actually plays nice with other javascript libraries. The clientside environment (browsers) is not homogenous like the serverside so eventually you are bound to run into a problem (abstractions leak) and then you get the QA nightmare Halvord is talking about and no-one there to solve it for you (because with GWT management decided not to hire a clientside expert since the serverside boys can do javascript just as well – how does that add to the stigmata?)In that sense javascript libraries like DoJo and Prototype are the real toolkits: they provide you with the hammer and saw and you use them to create something nice out of a piece of lumber. GWT is more like a box of Lego that comes with a manual that tells you what you can create and how to create it, but when you want to create something different you will soon run out of suitable building blocks.

  8. Bruce: thanks for jumping in and commenting. I'm sorry for being critical "in a vacuum" as you put it, based on the least meaningful example of GWT usage. It's very interesting to hear about the compiler optimisations (and the list of "done" features on your roadmap was exciting too). However, I would very much like to hear your team's thoughts and plans on browser compatibility and – naturally MY pet issue – whether you can/should make the GWT-generated code easier to debug.. I guess many web developers will also be worried about not being able to debug the generated code if they use GWT so I expect it is an issue you have discussed and addressed in some way or another, or will have to handle in the future.

  9. It's totally understandable to fear, upon first impression, that GWT's compiled JS may be hard to debug. We've all rightly become suspect of naive "code generators". However, the GWT team has gone to a lot of trouble to make sure that this is not the case with GWT: we *never* want developers to have a problem and be stuck. I'm happy to say that we hear few complaints from users regarding debuggability of the compiled JS, and it's because once you actually use GWT, you realize a few things:1) It is extremely rare that you ever do *need* to debug the compiled JS. Robert Hanson explained his experience in a GWT Round Table podcast (http://javaposse.com/index.php?post_id=140955). The first week you use GWT, you're constantly afraid that something is going to blow up and leave you very confused. But it really does work as advertised, so after that, you start to relax and actually enjoy the additional leverage.2) A big reason people seem to be worried about GWT emitting debuggable JavaScript is that (a) they like being able to debug and (b) they have always written in JavaScript, so they equate "debugging" with "debugging JavaScript". But when you use GWT, you can debug using powerful full-featured Java debuggers to debug the same code (as Java source) that you would have otherwise had to debug using a JS debugger. So, the question is not "Is my GWT app debuggable?" The question is, "Do I want to debug mostly using a Java debugger or a JavaScript debugger?" GWT gives you the option to do both, focusing on whichever you prefer. (Of course, when explaining GWT, we emphasize Java debugging since it's hard to deny the richness of the typical Java debugging experience.)3) You can instruct the compiler to emit unobfuscated JavaScript. (After all, how do you think we debug the compiler :-)? You can use- style OBFUSCATED [nice and small]- style DETAILED [verbose but very precise]- style PRETTY [a good mix: readable without overwhelming detail]4) Abstractions leak, we know that. This is how we described it in "Making GWT Better","GWT is not an attempt to abstract away the browser from you. Neither is GWT an attempt to prevent you from writing JavaScript when you want to. GWT is simply a way to give us developers some extra leverage in the form of productivity tools and the ability to create higher-level abstractions when it's useful. If you're a JavaScript guru, we hope you'll find GWT is a great way for you to package up your best JavaScript work and make it easy to reuse."So, by explicitly not trying to hide the details of the GWT UI from you, you hopefully don’t feel surprised about the how the JS code works under the hood. This helps you use GWT more effectively and reduces the odds that you’ll feel stuck when you encounter bugs.5) You can write as much JavaScript as you want to and integrate it easily into your Java code base. See GWT’s JavaScript Native Interface (JSNI) at http://code.google.com/webtoolkit/documentation/com.google.gwt.doc.DeveloperGuide.JavaScriptNativeInterface.html6) The GWT compiler is a real compiler, not a dumb source-to-source translator. We even parse the handwritten JSNI code, check references between Java-to-JavaScript and vice-versa. (Parsing the JSNI code also lets us safely obfuscate your handwritten JS.)Here's a decent way to summarize all of the above: we view GWT as a form of leverage, not "Java language vs. JavaScript language".

  10. I am having soooooo much trouble with GWT. It takes hours on end, just to think that I am getting somewhere with a single project. I can't seem to get the Project Creator command window up. I have tried every angle.Does anyone out there know?

  11. huh writes:function hello(){var M='',nb='" for "gwt:onLoadErrorFn"',lb='" for "gwt:onPropertyErrorFn"',Y='"> ',$='#',Kb='.cache.html',ab='/',Fb='064BD9AE2CA20065AE625823CEC92358',Gb='391B703F551F1A8E2492DBE556AC57D7',Hb='442A1C7D3B30D2EE6C0982E932C604B2',Ib='4C349ECA8C5A70BF11504ADF354DA36F',Mb='

Leave a reply to Mogog Cancel reply