Thursday, 27 November 2008

ZK - First Impression

I first heard of ZK from several developer forums, where one of the authors of ZK posted articles comparing ZK with GWT trying to prove that ZK was superior. Ever since then, I have been wanting to learn/use ZK for several months now.

I was pleasantly surprised by the maturity and high quality of ZK from the first moment I started using it - I didn't expect it to have a drag-and-drop graphical editor - something that not many free web frameworks have out of the box. I believe it is a real contender of GWT.

The praises of ZK can be found easily and I will not repeat them here. Instead, I will outline the reservations that I have about ZK hoping to get advices from the community.

ZK Studio Installation

When I followed download instructions on ZK site to install the ZK Studio directly from Eclipse, it turned out to be an older version of the plugin. It took me a while to find out why my ZK Studio did not have the ZUL Graphical Editor mentioned in the documentation. I had to download the plugin (v0.9.x) and install it onto Eclipse manually.

ZUL Graphical Editor

The ZUL Graphical Editor is not really an editor at the moment. It only serves as a previewer. I believe ZK team is actively working on improving the editor right now.

Debugging

I am not aware of any special debugger for ZK. If something goes wrong, I have to inspect the web server's log file to get the stack trace - cannot jump to the line of source code automatically. Moreover, if the error occurs at the ZUL script, the trace shows BeanShell exceptions, which can be harder to locate the real position of the error in the ZUL file.

Centralised ZScript File

I understand that zscript can be isolated in its own file and be included into the .zul file, so that the script is not littered in the presentation code. However, I find that to completely separate the script and the ZUL code is not practical. For example, to specify the a renderer for a component, I need to instantiate the renderer and assign it to a variable, then put the variable to the components renderer attribute. For example,
<zscript>
import com.laws.address.zk.*;

renderer=new AddressRenderer();
</zscript>
   <listbox id="crudAddressList" mold="paging" pageSize="10" 
   itemRenderer="${renderer}">
    <listhead sizable="true">
     <listheader label="ID" width="30px"/>
     <listheader forEach="${afts}" >
      <attribute name="label">${each.name}</attribute>
     </listheader>
    </listhead>
   </listbox>

However, the bit of script that instantiates and assigns the new renderer cannot be separated into another file (unless a function is created to do it, which looks odd and impractical).

Event Handling

The event handling in ZK is strange - the sender has to specify the target for the event. The whole idea of events is so that the sender (or publisher) is not aware of who is going to consume the event, or how many consumers, and what the consumer will do with it. But in ZK, the target of the event is specified up front by the sender - i.e. the sender knows who should receive the event. I shall elaborate this point in another post in more detail.

To be fair, ZK does allow the target of the event to be null when posting an event. However, the event is only accessible from top-level components in this scenario.

Server Round Trips for Static Contents

Unlike GWT, even static contents in ZK will involve server decision (a bit like Echo 2). For example, upon clicking a button or menu, my application pops up an 'About' message box displaying static contents. The processing of the button click and the display of the message box involves the server and incurs a round-trip to the server. This certainly has performance penalty and puts presentation logic and load onto the server (which, IMO should be placed in the client tier - i.e. the browser). I know, there has been debate about whether the GWT way is better. I personally prefers the GWT way - especially considering it is broadband era now.

Overall, my experience with ZK has been quite positive. I think it is among my top 3 web RIA frameworks.

Saturday, 22 November 2008

N95 Must Haves: Panoman

I travel quite a bit due to the nature of my job. I used to bring my camera along on every trip. But due to my forgetful nature, and the bulkiness of the normal cameras, I stopped using them on my trips. Instead, I began to use my mobile phone camera, especially after I got my N95.

N95 must have one of the best phone cameras around. I feel that it is even better than many of the cheap digital cameras. It has a decent Carl Zeiss lens, 5M pixels resolution and intelligent image processing software built-in.

When traveling, many of my photos are scenery. Panorama pictures are the best to capture the landscape and the atmosphere of the new places that I visit. So far the best panorama software I found is Panoman. It is extremely easy to use: simple press start and move the handset horizontally, then press stop when you are done. The rest is handled by the Panoman software. Most importantly, the result is superb.

Friday, 7 November 2008

What Do VB & Applet Have In Common?

No, I am not talking about Victoria Bitter, which I quite like. I am talking about Visual Basic and Java Applets. They both have a bad reputation due to historical reasons, which is hampering their adoption.

In the heyday of IT, VB was probably the most widely used programming language at least in the Windows world. IT professionals and IT professional wannabes all flocked to write software to cash in on the golden era of IT. I still remember one of the managers at Australian Taxation Office (ATO) initiated an IT project and wrote the software in VB/Visual Foxpro by himself together with a public servant who had "13 years of programming experience" but also had trouble finding keys on the keyboard.

Today, VB has become VB.NET and the developer community is more mature. Still, there has been much discussion about why people perceive VB.NET to be inferior to C#. Many people choose C# over VB or even move from VB to C# simply because it will make them look better or making them feel better about themselves - real programmers use 'C-like' languages.

Unlike VB, the Java Applet never reached popularity since the beginning because those were the dial-up days. I can see three major hurdles for Java Applet in those days: slow internet links meaning downloading the JAR files was a big problem; 'complexity' in installing the JRE plug-in; awkward look-and-feel and lack of good frameworks.

Today, things have drastically improved: pervasive broadband access, improved browser plug-in capabilities, 80% new PCs are pre-installed with JRE, improved JRE (6 update 10), the imminent release of JavaFX 1.0 and more other applet-based frameworks. Still people doubt whether these frameworks can compete with Silverlight and Flex. I don't see the word 'applet' get mentioned much by Sun or JavaFX's promoters. The FUD is just too deeply entrenched in people's minds.

At the end of the day, great technology does not thrive on its own merit. The human factor has the final say. It's a bit like Wall Street.

Monday, 3 November 2008

A Musical Note

I spent last month at home on holiday (is that an oxymoron?) feeling lethargic as people do on holidays. As a result I did not touch my computer much and only spent a few hours learning Erlang.

However, I did get to learn music and ended up spending 1-2 hours per day in front of the electronic keyboard that I bought for my kids . I have to admit, I am not good at music at all - I did use to excel in singing in primary school; but since my voice broke I lost all enthusiasm on music - my parents sending me to a violin class where I was the only boy did not help either. Until last month, as I fiddled around with the piano/keyboard, I revived my thirst for knowledge on music and piano-playing. It turned out that piano-playing is really easy to learn (at least to start) if you are a fast touch-typist. So I relearned the basic music theory 101 by following the wonderful book Total Piano. As an IT professional geek, I couldn't help finding many striking similarities between the musical and computing worlds.

First of all there are the patterns in music. As a matter of fact, all musical pieces are based on establishing some patterns and then repeating them - there are quite a few symbols in the staff to represent repetitions (i.e. the GOTO statement). It seems like composers are lazier than system designers Also, there are chords and each chord has many variations - broken, harmonic, minor, etc. Again, it's all about repetition and reusing.

Then there is the arrangements. The same music can be (re)arranged to adapt to different environments/scenarios - e.g. to suit different musical instruments (e.g. piano solo, string quartet), or to suit different players (e.g. beginner vs. pro) etc. Thanks to simple arrangements of many great works included in the book, I was able to play some very interesting pieces and keep getting fully engaged in the learning process. By the way, how many AJAX'ian web frameworks have you come across recently?

Well-known musicians also remake other people's songs to boost their own career. Yesterday, I read an interview with Seal and his upcoming new album of remakes of classics that 'appealed' to him. In it, Seal revealed that quite a few young people in their 20s had not heard the original version of the songs. So Seal's version was the first time that they heard them and Seal kind of re-introduced the great classics back to the young generations. I hope the youngsters don't mistake Madona's American Pie with the original.

Every now and then I can hear curses coming from across the office when my colleagues cannot find some features in their MS Office 2007. I have mixed feelings about the ribbon interface of Office 2007 - I like the look and feel but hate the fact that so many features have been rearranged so that everytime I want to use them it's Easter all over again. I am sure if someone has never used the older versions, he/she will like the new ribbon interface.

Perhaps learning from the closed-door design experiences, Microsoft is openning up their design process for some of their major products - e.g. Enginnering Windows 7. On the other hand, music creation is usually an extremely personal experience, unless you are charged to write some propaganda piece or the national anthem (I will vote for Waltzing Matilda anytime for Aussie national anthem)!

Meanwhile, I'd better get back to practise the beautiful piano solo arrangement of Beijing 2008 Olympic theme song - You and Me.