Friday, February 25, 2011

RIA in Grails using Ext JS

I've been looking for quite some time now for a client-side library that'd allow for creation of rich internet applications (RIA). I've evaluated (however briefly) Flex and Silverlight at first but this is not what I've had in mind. I wanted something that will just work, without any sophisticated plugins that get outdated (Flash) or are not supported on all platforms (Silverlight).

Knowing what Google did to make real applications possible in the browser I've looked at GWT and again this is not what I've had in mind. I dismissed Silverlight and Flash for the reason that I wanted to code in JavaScript and have the whole power of that language at hand with the ability to use CSS and HTML as I please. Coding in Java is, how should I put it, a pain in the a$$. I personally hate this language and there's nothing that will change it. Oh, and btw this also means that all the frameworks that build on GWT (like Vaadin to name just one) fall into the same category.

And then I stumbled upon Ext JS. Man that was a surprise! First the object model baked in into the framework turned out to be perfectly suited for real-life applications. The GUI itself looks just gorgeous! There's a client-side part for direct communication with server (Ext.Direct) and a model for data access (the Ext.data.Store and descendants). But that's not all! There's a JsonStore that can be configured to work with RESTful JSON service!

As you might have guessed I'm using Ext JS with a Grails backend. Those two play so nicely together it's almost to good to be true but to make things even simpler I've created a Grails plugin called json-rest-api that taps into the domain objects and exposes them in a RESTful way for the JsonStore to consume.

Now creating an application with editable grid and all the usual CRUD functionality takes less than 5 minutes!

Check out the plugin here and the two examples here and here. You'll be amazed!

Stay tuned for more examples and tricks on using Ext JS with Grails!

Sunday, February 20, 2011

Creating desktop-like web applications

For the longest time there's been a gap between web developers and the so called desktop developers. Both branches used different tools and different techniques to get things done.

What has changed in the past couple of years is the web itself and what's being expected from web application. With the change that occurred in the field of RIA (Rich Internet Applications) many products that would previously just be a set of web pages turned into SPAs (Single-Page Applications), utilizing the power of Ajax, dynamic DOM manipulation and recognizing the full potential of all the 3 core technologies (HTML, CSS and JavaScript).

The Misery



With that in the picture it is worth taking a moment and looking at the options we have when creating a new application (be it a web app or a desktop one):

1. Operating system.



Nowadays if someone targets their product at one OS it means pretty much that they allow for competition right from the beginning. And not only allow for it but in a sense ask for it. Sure there's Java that compiles and runs on everything that has a CPU but talking seriously about creating an usable GUI in Swing or SWT is plain and simple asking for trouble.
Then there's .NET and Mono as its multi-platform solution. It all looks nice and dandy but the truth of the matter is that WinForms is still not 100% usable and with WPF in the game it's going to be very hard for Mono guys to keep up. So even though creating breath-taking and maintainable UI under .NET is feasible it narrows down the potential clients to Microsoft Windows.

2. Windowing System.



Platform (and operating system) aside there are some great windowing toolkits. WX, GTK (and even recently GTK#) and even SWT - those are all viable options and should be considered as candidates for new projects. There's only a couple of small issue with most of them: they look and feel different on different platforms and have very little support. Don't get me wrong here - with the right amount of desperation one can work out miracles with those - it's just not something that you'd take, toy around it for a day or two and start using it. WPF, WinForms and VCL included!

3. Maintenance.



Even though we developers don't like to think about what our application will do in 3 years and how those new features will be delivered to the customer it is vital for the continued success of our efforts that the deployment of new versions is as painless as it gets. Different platforms (and I'm talking managed platforms only here) have different solutions to this problem. On .NET you get the "Click once" capability which pretty much covers it. On Java you get the web launch capability which is close to the Click Once, but less feature-rich.

4. Access to developers.



Finally if you're so damn successful like Facebook or YouTube you might want to hire some new developers to do your dirty work. Choosing (or as I like to call it: closing yourself on) one technology means that the amount of people you can hire is not enough to find the right people for the job in a reasonable amount of time.

So it seems that all is lost and the fragmentation of what's available and what's struggling with the rest of the world brings an end to reason in software development.

The Solutuion.



As it turns out not all is lost. Let's examine what's available on the market to make our future more predictable.

Desktop Web Applications.



As weird as it might sound it is not science fiction at all. Right now with the capabilities of HTML5 this actually is a viable option.
Redeployment is as easy as it gets (just hit the damn F5 button and you're done), technology is already there (just take a look at Ext JS to know what I'm talking about) and the actual browser platform is getting faster and faster every day (look at Internet Explorer 9 and the direct hardware access they are doing - it's amazing!!! - not to mention Google Chrome and FireFox that kick ass since god knows when already).

If the flexibility of CSS+HTML+JS is not good enough (for whatever reason) and you just need to go all crazy there's Flash (and Flex), Silverlight and JavaFX. My personal choice would be Silverlight but that's mine .NET fetish talking :D

So what's the future going to bring? Who knows? But one thing is certain: After the web revolution that happened since Ajax the world is never going to be the same. The browser attack is not going to go anytime soon and in fact (with Google's Chromium in the picture) it might very well be that the OS to win users is not going to have the two whacky glossy panels or an animal but a circle in the logo.