October 30, 2007

Google Web Toolkit by Microsoft = Volta

Apparently Microsoft is working on a new product (Volta) to improve web development. Basically it boils down to a GWT-like approach. It's a VisualStudio plugin that compiles msil-code to JavaScript (or Flash or Silverlight) for the client tier.
They claim that it's only used internally but it wont surprise me if they release it to interrupt the fast adoption of the GWT technology.

October 23, 2007

Flex vs GWT vs Echo2

Past 2 weeks I needed to investigate the best framework to port the front-end of a Java/Swing framework to a rich web UI environment.
The contenders:
  • Adobe Flex2
  • GWT (Google Web Toolkit)
  • NextApp Echo2
The idea was to have a rich UI similar to the existing Swing framework running inside the web browser, that seamlessly integrates with existing Struts webapps. Applets / WebStart was out of the question, because of fear for deployment and decompilation issues.

So with these constraints in mind I started looking for the best framework amongst our 3 contenders. The odd one in the list is obviously Flex, but although not based on DHTML and JS it offers a lot of richness, and the deployment and security risks where less of a concern to the client.

Echo2 soon failed one of the main constraints: to seamlessly integrate within other webapps, maybe there are good solutions but I didn't seem to come across those. Because the API was very similar to Swing it was very easy to port some of the basic functionality for my proof of concept, too bad. Another concern is that Echo2 maintains the view-state server side, which could become an issue when scaling up to many concurrent users.

Flex also failed in favor of GWT. The main concern was the difficulty to integrate it with a J2EE or JEE backend, you need to use WebServices or REST. There is a free version of LiveCycleDataServices which takes care of this but it's limited to single CPU systems. Licenses for the enterprise edition however are pricey. Another concern was the lack of quality opensource plugins for Eclipse, requiring a FlexBuilder license at 500€ per developer to have a comfortable productive development environment. And another inconvenience is that it's not Java, rather annoying to migrate all developers to this new language (ActionScript). Flex still has to prove itself as a technology ready for enterprise adoption, and you still need a browser plugin and it can be decompiled.

GWT on the other hand doesn't require all those changes of habit, you can keep developing and debugging in Java, with your preferred and well known tooling, JUnit testing, refactoring, you name it. Now a year after the first release there's already a large community adopting and extending the framework. Numerous enterprise applications have been built with it and it seems like a platform that improves productivity for rich internet application development. GWT shields all HTML, CSS, DHTML, JS and browser incompatibility issues from the developer. And as bonus you get free client side code compression and obfuscation. It's a pure WIN WIN situation.

A first implementation of the web port of the Swing based framework has begun with GWT 1.4.60 as platform and GWT-EXT (wrapper around EXT-JS) for some richer UI widgets. Everything gets built by Maven2, is developed in Eclipse and tested and debugged in the GWT Development Shell.

With the inception of GWT, Google gave JavaScript based applications a second life. IMHO if it wasn't for GWT, JavaScript would be dropped rather sooner than later in favor of Swing / JavaFX / Silverlight or Flex-like solutions for enterprise applications because of project maintainability issues.

Be sure to tune in later when I post my GWT / Maven2 project setup for Eclipse...

September 22, 2007

Java Memory Leaks

Yesterday is stumbled upon some interesting blog posts by Scott Violet from the (former) Swing Team and Tim Boudreau from Netbeans. Apparently Swing action listeners before Java 6.0 were registered, and as such tied with normal references instead of Weak References causing unused objects to remain in memory. So if you're developing in pre-6.0 be sure to think about this issue, you're most likely preventing unused memory for liberation by the garbage collector (= memory leak, yes Java has memory leaks too!). Second concern is that still a lot of Swing developers tend to extends Swing components:
public class MyFrame extends JFrame {}
This has the unfortunate effect that the GC needs more passes (at least 2) to recollect unused memory. This is because somewhere up in the inheritance graph Component implements finalize() causing the GC to do extra effort to collect memory because it needs to run the finalizer and then reschedule another GC pass. So in case you're just USING the Swing components and not adding features, use them like you use other Java objects like ArrayList, HashMap,... It's a quote from Erich Gamma: 'Favor composition over inheritance'.

Although memory leaks are more likely to happen in combination with, they're not limited to Swing. There are other concerns: static inner classes, misplaced fields with respect to their scope, collections used as cache, ... You don't do it on purpose and there are commercial profilers that do a good job in detecting these issues but you need to find them yourself. However the Netbeans team has a nice tool to test for these errors. The extended the JUnit TestCase with a method: assertGC() to test if a certain object reference can be GCed or not. If not they launch the INSANE library to detect which chain of objects is still referencing your object, and so preventing it from garbage collection. Their files can be found here with an easy example: Tim Boudreau in his LeakDemo source code. Take note that the example now correctly passes the JUnit test because of the adaptions in Swing from Java 6.0, but it explains how to work with the test-cases.

September 19, 2007

Playing Flash Video (FLV) with Java

*** Update: Read this post first!! ***

Today I was challenged by one of my coworkers to be able play an FLV movie inside a Java client (Swing) application. Well it seems like it's a piece of cake. All you need:
To spice up the challenge I added the player inside the ReflectionPanel from the great book: Filthy Rich Clients.
There's nothing special to it... I created this demo in about 15minutes. If you take the FOBS4JMF binary build, all you need is included and preconfigured.

September 12, 2007

Swing Debugging

Kirill Grouchnikov wrote a nice article on the subject of Swing Debugging. This is still a dark area for newcomers to Swing application development. Blocking the EDT (Event Dispatch Thread) or updating Swing components off the EDT are common problem areas for newcomers and contribute to the fact that people think that Swing is crapy or slow.
Fortunately some people have contributed tools to verify against these violations, you can find 2 classes for debugging Swing here (CheckThreadViolationRepaintManager and EventDispatchThreadHangMonitor).

August 26, 2007

OpenLaszlo vs Flex

When talking with some colleagues on the subject: Java Swing rich client vs rich web-client RIA, we came across the new Flex2 and Flex3 technology as alternative to Web2.0 AJAX styled RIA.
I first came in touch with Flex at the JavaPolis event last year, but I wasn't too excited, being more of a desktop application guy. But when you start to think about it, it makes sense in such a comparison. It seems to improve productivity, is widely available on all common platforms, is configurable, styleable, ... what not!?
So in my search for a good comparison of Flex vs other technologies I came across another contender: OpenLaszlo - 'the premier open-source platform for rich internet applications'. After seeing the demo applications I was amazed by this framework. It's so easy to do many of the most common things and the best part is that it generates both Flash and DHTML so it's not only dependant on your Flash plugin. Flex also has a lot of nice demos, somehow feels a little smoother and now has a free SDK. Now it's just a mather of trying them out to determince which one is the best to work with. To be continued...

June 28, 2007

Swing application architecture

In my previous post I talked about a presentation I'm preparing, related to this and a course i'm teaching in advanced desktop Java development I'm thinking about 'the best practice' architecture for a Java Swing 'rich client' type of application. More specifically I'm looking for an all round solution to separate business and GUI layers, pass around events, prevent EDT blocking, (asynchronous) tasks.
After having read Desktop Java Live by Scott Delap (great book by the way) I'm not entirely convinced by his RSS Reader example., I do things differently, not necessarily better. After a talk with Karsten Lentzsch (JGoodies.com) I'm still somewhat in the dark. It looks like there is no correct answer, just some guideline into the right direction. Use PresentationModel's and an application-level model to interconnect larger graphs of PM's together. Maybe the EventBus could come in handy here, but I still haven't tried it.

May 30, 2007

Desktop Java on dope

It's been a while since I wrote here, mostly because I'm occupied with a new task besides my daily consultancy job at the client. I'm preparing a presentation on Desktop Java. More specifically focussed on Rich Client Java Apps with Swing. So the past few weeks I've been going over and over all JavaOne 2006, 2007 and JavaPolis 2006 desktop related presentations to make sure I didn't miss anything.
So far Java 6 seems promising for the Desktop developer, but as always it will take 3 or 4 more years until the businesses start adopting it. Heck I would love to just be able to start using Java 5, but the client I'm working at is still stuck at 1.4 :-( Too bad, no annotations, no generics, no SwingX or other cool components based on Java 5... I've actually been back porting quite a lot because of this. May this be a call out to all Swing component writers... preserve 1.4 compatibility for just a little longer please!

It's somewhat remarkable that desktop Java is making a serious come-back, all the UI bug fixes and improvements put into Java 6 and the promising upcoming JavaFX , Swing App. Framework, Beans Binding. Desktop Java is finally evolving rapidly, and that's good news but for now using JGoodies SwingSuite can get you started today with the technologies promised for Java 7.
Another thing I noticed is that Eclipse platform is also gaining momentum, so I'm expecting some more EclipseRCP / SWT projects in the near future.

March 27, 2007

Hello World and welcome

I will be spending some time here in the near future to make comments and write articles about subjects that matter to me, my job as a Senior Software Engineer / Technical Project Lead, and my life in general...

Enjoy the reading!