38 comments

[ 2.6 ms ] story [ 81.8 ms ] thread
What is wrong with blog posts

Lately I've been reading a lot of blog posts assailing a technology as though proponents of that technology think all other tools are useless in all situations.

Replace "GWT" and "JS" in this article with "C++" and "Assembly," and all of the points still hold. But C++ is still incredibly useful for many developers, and so is GWT.

GWT largely exists because it has a reason to exist. One of its main reasons to exist is that browsers are not standards compliant, and sometimes the standards are ill-defined. A well-defined abstraction layer on top of that is very useful... right up until it's not. Sometimes you need to dig in to Assembly, and sometimes you need to dig in to JS. But quite often, higher-level abstractions get you all the way from start to finish.

Actually, my first thought when reading this blog post was "oh no, it's C vs. hand-tunes assembly again." We know, how that ended up.
You know... It's in fact much more like the reverse: compiling assembly language into C. Java is a less expressive language than JavaScript. The result is that you code in the slow-to-develop/fast-to-run language and it spits out fast-to-develop/slow-to-run code.
Another way of saying the same thing would be

GWT: develop in a language where managing complexity is doable and well-understood, and run in a write-only language that can be run everywhere

Java has lots of advantages, like coherence and interoperability between libraries that javascript lacks (never mind the actual existence of more than 5 libraries). Also GWT allows you to write run-anywhere code.

These days it's pretty much a safe bet that all your code will work perfectly well on all browsers, not just the desktop ones. If you develop for mobile and don't have 500 phones, this is a blessing.

This is an old article, and a poorly written one at that.

Strikingly though one of the criticisms that seemed most poignant to me is:

"GWT completely ignores the fact you are creating a website, NOT an application"... I think this shows a serious lack of forethought on the author's part to not see that many websites were turning into web applications, and many enterprise applications with desktop clients had also started to go down this route.

You should have read the link at the top as well, providing a follow-up that mostly contains "Ok, I didn't know thaat much about GWT when I wrote the first post, so here's my largely revised and far less polarizing opinion".
And this is why my blog only has 4 posts over 2.5 years. I simply don't have the desire to take on such polar opinions with such little topic background. It seems these knee-jerkish opinion bits on Dart, GWT, X, Y, Z have grown in popularity here. I enjoy the discussion because the comments here are full of more information than I could quickly aggregate myself, but I wonder when I will become a pompous enough software engineer to feel the need to write posts like this.
This is just another example of the "there is only one way to do things, my way" philosophy that taints so many discussions about software development.

Sure, GWT does not create the cleanest mark-up and javascript in the world but maybe that is not always your goal. You may just want to get a web app up and running quickly but are lacking the javascript expertise - cue GWT, which allows you to harness your java expertise to create a web app.

If you don't like to create web apps this way (I for one would much prefer to hand code javascript), then don't but also don't go around name-calling the technology "disgraceful" just because it does not serve your own specific purposes.

Why does one need JavaScript to build a web application?
EVERYTHING is wrong with GWT - just dont use it.

Generally I believe the idea of writing code in one language to be converted into another is wrong. Languages are tools to do a job - pick the right one for the job or it will end in tears.

(comment deleted)
Unless you write your software in binary, every piece of code you write will be converted into another language.
I believe his point is that you should write in the most human friendly language you can and, maybe, let the computer translate what you wrote into something less human-friendly that the computer can run fast.
Well, believe it or not, some people will choose safety net of Java the language over JavaScript, especially for web application.

It takes a lot of discipline to work on large JS code bases, and writing Java instead of JS could be a good choice for some projects if developer skill set is leaning towards Java.

Also, it seems that there is a fraction in Google which likes Java, hates JavaScript and has enough resources to go with projects that bring Java to browser like GWT or Darts.

Personally, if they already like Java so hard, why they don't "just" create nice JRE/browser/DOM integration package so we could use any JVM language instead of JavaScript.

You don't really believe that.

Or if you do, you will have to concede that it is wrong to write anything but assembler code.

Javascript is interpreted. Which actually highlights my point that languages (of any level) have usually been designed to solve a particular set of problems or targetted for a particular type of runtime environment.

Thus, the likelihood is that converting Java into Javascript or Pl/SQL into LISP or ActionScript into Python will provide no benefit but will almost certainly complicate the development process.

Javascript is interpreted.

No, it's JIT compiled, at least in any recent browser or in Node.JS.

Which actually highlights my point that languages (of any level) have usually be designed to solve a particular set of problems or targetted for a particular type of runtime environment.

But what if you have a problem that fits Java much better than JS, but you just need to distribute the client through the browser?

Actually, I think your last sentance exactly highlights my point (I dont know how to do that italicy/quote thing).

Whether you choose to write your code in Java or Javascript doesn't matter because it will HAVE to be run in a Javasript environment (browser) so you will always be limited to the target language - Java allows you to connect to databases with JDBC, read/write files and create rich user interfaces - none of these language features can be used by javascript in a browser.

So solving a problem that is more appropriate for Java can never be a problem that needs to be solved inside a browser by javascript...

(I dont know how to do that italicy/quote thing).

Enclose the quoted phrase in asterixes...

You are mixing up the languages with the platforms.

Java doesn't let you connect to databases or any of that - the JVM does, and for any language running on it (Scala, Clojure, etc).

Java the language just gives you a certain set of syntax and semantics which can be useful to model a problem and its solution - classes, interfaces, etc.

Even if you're limited by the API of the platform - the browser - that has nothing to do with whether a different language is useful or not for your particular problem.

Independently of the merits of GWT or the follow-up apology post, Java is an awful language to write web applications with. Languages like Ruby and Python (mostly when associated with frameworks like Rails or Django) allow you to become much more productive, yield a much smaller codebase and much lower long-term maintenance costs.

As for the JavaScript side, if you find it daunting, you may try Coffeescript or even Closure (which provides some Java-developer-friendly limits to JavaScript).

Java has its strengths, but writing web applications isn't among them.

I've got complex feelings about Java.

The comparison with Ruby and Python isn't really fair. A better comparison is C#, which is like Java in spirit but has a large number of incremental improvements over Java.

Underlying it all, Java has an attitude that concision doesn't matter. One reason why people don't do anything interesting with generics because you always have to write

GenericContainer<AnotherGenericContainer<ArbitaryTypeA>,AbitraryTypeB> = new GenericContainer<AnotherGenericContainer<ArbitaryTypeA>,AbitraryTypeB>();

C# has var, extension methods, function pointers, generics without type erasure and many other little things that show respect for the programmer. You realize then that the "problem with Java" isn't an all or nothing thing (static types suck), but an obstinate cultural attitude that's gone on for 15 years.

C# might not be as concise as some languages, but it shows you can have something a lot like Java that isn't as bad... and that makes it clear how outrageous Java is!

> The comparison with Ruby and Python isn't really fair.

It's fair because there is nothing stopping you from picking up any of them, a decent framework and be orders of magnitude more productive than either a Java or a C# developer. C# is a better language than Java, but it still comes short when it comes to developing web applications.

There are hugely successful apps written in C# and Java, I agree, but their existence is owed more to the brilliance of their developers than a brilliant choice of tools.

"Orders of magnitude more productive" isn't true -- except in the case that the productivity of people on a failed project is zero.

For projects that get completed, I could believe two or three... Maybe more in cases that are trivial to do with rails.

The nightmare I've seen happen with Ruby projects is that the "developers" are often web designers who know how to do things that are easy (or trivial) to do with rails, but get in over their heads rapidly.

Python, on the other hand, has a culture of doing the 20% of the work that gets you 80% of the way to production, announcing that they're done, moving on to a greenfield project, and then laughing at the "Blub" programmers in PHP and Java who work so much harder to get things production-ready.

Java's greatest strength, on the other hand, is it's greatest weakness. Java has a huge number of libraries that make it possible to do wonderful things, like Lucene and Hadoop. There's "more than one way to do it", which means that real-life systems might have 5 different JSON libraries used in different parts of the system. A programmer who needs to work on a small part of an application might need to wait for Maven to download 650 megabytes worth of JAR files. When you have 650 megabytes of dependencies to deal with to work on 65 kilobytes of code, it takes a very small amount of bullshit per kilobyte in the dependencies for you to spend more hours messing around with the build system than you spend developing.

I have to disagree with your two misconceptions:

> Ruby (...) "developers" are often web designers who know how to do things that are easy (or trivial) to do with rails

> Python (...) has a culture of doing the 20% of the work that gets you 80% of the way to production, announcing that they're done, moving on to a greenfield project

I have met, during my career, a lot of incompetent professionals like the ones you describe above. Most of the time, they work with "safe" technologies, the ones they are sure there will be demand for. Java, PHP, C#, ABAP and VB are their favorite tools. When you see someone proposing something crazy, like using Python (or Ruby, or Smalltalk, or Lisp, or Erlang) on a very enterprisey application, they are either lunatics or just very, very smart. BTW, to be fair, I've seen lots of very competent Java, PHP, C# and even VB programmers. But they are exceptions, not the norm.

And no. I have developed tons of Python code from concept to production. If we have this 80/20 culture, I have, so far, managed to be completely oblivious to it. The main difference between your anecdote and Java projects I have seen in the past is that nobody but management claims they are done.

Absolutely. I am at a loss as to why people use Java for Internet facing sites and apps. Of all the things Java 'should' be used for (embedded apps and desktop applications) it gets most used for the one thing it wasn't designed for - the web.

So...was GWT developed for Java web developers that didn't want to learn Javascript? Javascript is just one of the things you have to know how to use to build a modern web site or web application.

"Any time you program one language in another, you lose all the benefits of the target language"

... yeah, like when C gets compiled to machine code, you lose all the benefits of machine code.

On some level that's true. You can certainly write machine code that's faster than C, and often you can take advantage of hardware features that the C compiler can't use (in some cases, SIMD.) On the other hand, C code can be portable across platforms and developers can be more productive.

GWT keeps one important attribute of Javascript: the ability to run cross-platform on web-browsers. It trades the benefits of programming in Javascript for the benefits of programming in Java. Static types have some advantages, and you get to work with Eclipse and have automated refactoring and a good debugger.

His fundamental criticism against single-page webapps is valid, but this is true about Java applets, Flash, Silverlight as well as some Javascript frameworks.

A fundamental criticism I'd have of GWT is that it's very to build very complex applications in GWT, complex enough that the problem of managing asynchronous communication becomes a real bear.

> ... yeah, like when C gets compiled to machine code, you lose all the benefits of machine code

You know that's an apples to oranges comparison. JavaScript and C are much more expressive than assembly language. This complain is that you are writing code in a less expressive language (Java) that's being compiled into a subset of a more expressive one (JavaScript).

Assembly, C, Javascript and Java are equally "expressive" in the sense that they're Turing complete. Anything that can be "expressed" in Javascript can be "expressed" in Assembly.

Most of the features people like in Javascript can be faked in some manner in Java. Anonymous objects can be used to insert anonymous functions into Java code... At great cost in verbosity. Variables never really escape Java "closures" but the resulting immutability leads to a functional programming style that has real benefits.

Javascript's real advantage is a clearer syntax that's easier to learn and easier to read. If statically typed languages value concision, we can get the benefits of static types with little cost.

Expressiveness of a language is not the scope of what it can express, but how much you must write in order to express something.
Our customers were thrilled to see their 20 year old applications running on an iPad. I don't know how that would be possible without a java interpreter for funky old languages, and GWT as a bridge to the web.
In my view, GWT is for creating large/robust web-based applications, and that is where machine-level optimizations really pay off. If you are writing a tiny utility on a page, hand coded javascript might pay off, but if you are writing a large/complex application, it becomes impractical for a human to do what a optimizer can.

I am not saying that GWT is perfect for everything, but it pains me to think of writing (and debugging, and refactoring) a large application in javascript, or any weakly typed language. I've tried it, and found it difficult to maintain.

Is there a good definition of "robust" in this context?
More than thousand lines ?

Javascript becomes a disaster to read or maintain. Tools like Jquery help, but not enough to make it usable.

Javascript is like perl. And, frankly, Java is not. You can actually manage a huge Java application (and you can even have the work done by barely-competent programmers, which is a plus). There is no way to have 50 programmers working on a 50000 line javascript app.

Check out scalagwt. They've enhanced GWT to read a protobuf abstract syntax tree so that any language could be compiled to javascript if it can target that output. The first language they have working is Scala, which is far more suited to working with frontend code than java and in my opinion better than javascript. The nice thing about GWT in general is that you get to use a traditional oop approach to maying out the components of a webpage ala java swing.

http://www.google.com/m/url?client=ms-android-verizon&de...

Oh hi, OP here. I wrote this a long time ago. My opinion has changed a little in that time. I've already heard the arguments for/against GWT and understand its benefits. Not really sure why it's on HN now and honestly a little embarrassed by it.
Just to beat a dead horse, most languages, especially scripting languages compile down to something else. I don't use GWT, but I could understand the lure of using a known language that has established great tools to create a powerful web applications. From what I understand it will even optimize then obfuscate the javascript for you. As for the degradation argument, that is a weak negative.