First to establish my perspective with these technologies - I write Java and Javascript professionally, I have used GWT off and on since its inception and most recently have been full time on a GWT project for the last 2.5 years. In addition I have been writing Angular apps since version 0.9 something. So generally speaking I have used GWT a lot more, but then again it has been around a lot longer. You asked for a comparison of when to use each so here is a list of pros and cons that I see with each.
GWT Pros:
* Mature, well tested, highly engineered solution for producing pure client side applications.
* Lot of examples/documentation/support available
* Highly efficient/performant, both in terms of app delivery size and runtime performance (they now even benefit from the closure compiler)
* Written using staticly-typed, well tooled language. In my case this is important as our app is safety critical (people can die if it screws up) so the idea that we have the compiler checking for a class of errors means one less set of tests I have to write.
* Great Development environment that makes you productive even though you have a compile step in your build
* The ability to use Google Guava library. Don't underestimate the power of having robust utility libraries to do things like argument assertions, collection traversal, exotic data structures etc. There really is nothing better than Guava when it comes to this kind of stuff. Of course because Guava is used by the GWT dev team it means that you dont have to worry about it surviving the JRE emulation - it will just work!
* The single greatest thing about GWT for me was the programming model of Activities and Places - more commonly known as Model, View, Presenter (MVP). This programming model is a perfect fit for web application in particular where you may want to reuse logic to power different shaped views (read phone, tablet, laptop etc.). GWT really embraced this pattern to great effect
GWT Cons:
* It's still Java. No matter how you slice it, and how ironic it is, Java just isn't web-ui friendly. Java is not a good choice for anything programming problem that involves a lot of click handlers, or one-off listeners. Anonymous Inner Classes are just not the right way to do it!
* Even with the speed ups you have to avoid compiling as much as possible. On my laptop (late-model quad core mac book pro) compile times range into the 2 - 3 minutes time frame. It is twice as slow on a dual core machine. That really is a long time to wait between making changes and seeing a result. Even though the GWT team have done a great job making compilation less necessary during day-to-day development it's still manages to suck time out of my dev cycle. Also, like taxes and my waist - compile times only seem to grow with time.
* Adapting 3rd party libraries is possible, but not fun and you end up writing this weird mix of "javascript-in-java multi-line comments" which never seems to format correctly in IDEs and is completely opaque to syntax highlighting apparently.
* GWT applications cant support dynamic module loading easily. Think of a portal like iGoogle where you want to include many modules, perhaps only determining which ones at run time. GWT will fight you every step of the way because GWT, due to the extreme optimization it does, likes everything in the world to be known at compile time. This means that you can't link code up in the browser which means you lose out on what I think is one of the greatest features of the web.
* Related to that last point, GWT is not very modular in and of itself. While there is the ability to do code splitting to improve load times, you still end up sucking down a lot of GWT library stuff for even the simplest hello world app. Now this may or may not matter to you, but if you have mobile dev in mind, every byte counts!
Angular Pros:
* Angular is "of the web" It embraces core web technologies and make it easy to write your app using standards.
* JavaScript is a great language for UIs. I find that the Functional/OO duality of JavaScript makes it a great target UI development.
* Angular - owing if I recall correctly to it's Flex influence - has a fantastic programming model with binding, DI, promises, and Dumb views. Some might call it a MVVM approach, but it still seems like MVP to me and so just like I loved it with GWT I also love it with Angular.
* The use of the MVP model also help mitigate the traditional problem with JavaScript apps. Namely that they become impossible to manage at a certain size. By keeping things contained in small controller/service/directive buckets you have a clean way to manage your applications growth.
* Integration with 3rd party libraries is a snap thanks to the public exposure of $apply and $digest. You can actually improve other libraries by extending binding capability directly to them using core Angular methods.
* Angular is nice a modular framework and works to build small apps all the way up to multi 10s of thousands lines apps - don't know about anything bigger than that cause I havent worked with it but I think it should work.
* Angular has a healthy and vibrant community where any question you have can be answered pretty quickly.
* Testability, testability, testability! If you are going to write code in a dynamically typed language then you have to have a fantastic tests story and Angular has created one. Both due to it's use of core test-enabling patterns like DI but also through the development of the Scenario Tester that lets me write Selenium style end-to-end tests using JavaScript as my language of choice.
Angular Cons:
* JavaScript is a notoriously difficult language to manage large teams and projects in. Its great strength as a flexible, almost assembly code of the web, is also the source of many problems when people do simple things like rename a variable or use constructs like - obj[a ? "en" : "dis" + "able"]() - As I mentioned before I think Angular can help a lot with the marco organization problem and even some of the micro code issues, however it is still JavaScript and it is possible to make a serious mess. Note that tooling is getting better especially in Intellij/WebStorm so perhaps these kinds of issues wont be a problem for long.
* Angular is new in a crowded space. Although I believe it is the first framework to truly get what is required to build "Application in the Browser". It remains to be seen whether enough mind share can be established to create a growing and sustainable community - one that shines in the face of a fickle JavaScript development community.
* Part of being a young project means the docs and examples out there aren't quite polished down which can be quite annoying. However, this problem is getting better by the day and as far as I am concerned Angular has exceptional docs given it's limited exposure to public consumption.
* Angular has been knocked for its dirty-checking for binding approach. While I cant comment on the alternatives to much I think for the most part this is a non-issue for most apps but you'd have to evaluate your applications binding needs.
Bottom Line:
If you have only Java developers - use GWT. If you would prefer to have a compiler help catch some, but by no means all human errors - use GWT. If you need to rely on extensive examples or documentation, for now GWT is better but that will change. If it is going to be a very large, long lived application - something static typing an the Java tooling ecosystem may help with then GWT is your option.
However, if you want to build apps from small to large and you are comfortable with JavaScript as a programming language - not just a way to make animated transitions - then Angular is the first framework to give you the power to build a proper application. One where you stop thinking about the incidental complexity and can therefore focus on the essential complexity. With Angular you can be as big or small as you want, as dynamic as you want and really use the web to its fullest potential. Don't forget that the JavaScript tooling ecosystem is getting better every day- I can even put my JS app in Sonar now, build it with maven, run JSHint in my IDE and more. So the days of JavaScript being considered a toy language which no real project can be done in are long gone. Using Angular you can really put the lie to that line of argument.
Personally, having discovered Angular I don't think I would ever recommend GWT as a place to start for a web app. While GWT represents a truly amazing engineering success, I think it is an idea whose time has come and gone. I look forward to a future building AngularJS apps and solving problems for customers in a way that not only makes them happy, but keeps me from wanting to know my finger tips off!
Sorry for the long post, but this is something I have had to argue both ways with clients as well as internals teams so by writing it down here, I can point them to this post and save my breath.
Adam
On Wednesday, July 11, 2012 6:14:50 AM UTC-6, Chris Oman wrote:
Both of these technologies seem to fill the same space, but coming at it from different angles. Has anyone done a comparison between the two and developed a synopsis of when best to use each one?
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/LDlePhuF5TsJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.