Archive for the ‘Programming’ Category

Finally, CSS Demystified

Tuesday, August 28th, 2007

If you’re a programmer type like me and have tried your hand at CSS, it’s very likely you’ve struggled like I have to understand how CSS really works. As I programmer, I’m used to writing code while visualizing in my head what the outcome of running the code is going to be (ignoring all those nasty bugs of course :-) ). However, with CSS, I was never able to get the feeling that I knew exactly what was going to happen when a page rendered. All the books I read until recently did not really help me – it seemed like the authors of the books were also as confused as I was as to how things exactly worked. The tone of the books was – “if you are looking for X, here is the CSS that does it”; well if you are not looking for X, tough luck :-(

All in all, CSS was a bit of a dark art until I recently read CSS : The Missing Manual.

This is an outstanding CSS book! It really explains how things really work with CSS. After reading the book, I’ve actually been able to write CSS and have the page turn out as I visualized in my head. The book is well worth the money just for the chapter on page layouts – very well explained. Now if only I could pick some decent colors and fonts to go with all those cool layouts …

AJAX/RIA : No Clear Choice

Monday, May 21st, 2007

It seems pretty clear that AJAX/RIA as a concept is here to stay.

It represents the next natural step in the evolution of application architecture. We started with a thin client talking to a single server in the Mainframe era. We then moved to a thick client talking to a single server in the Client-Server era. With the advent of the web, we had a universal thin client (the browser) that could talk to multiple servers. Now, with AJAX/RIA, we are moving towards having thick clients hosted within a universal framework that can talk to multiple servers.

Now, if only we could all agree on what the universal framework is going to be :-)

There are really three major camps I can see:

  •  Just the modern day browser – thick clients all use JavaScript/XHTML/CSS
  • Browser augmented with Adobe’s Apollo runtime – thick clients can use JavaScript/XHTML/CSS or use MXML/ActionScript/CSS
  • Browser augmented with Microsoft’s Silverlight runtime – thick clients can use JavaScript/XHTML/CSS or use XAML/CLR/CSS

At first glance, it seems like JavaScript/XHTML/CSS would be a logical choice for anyone implementing a thick client because it is the lowest common denominator. However, there are strong motivations to use Apollo or Silverlight – the current browser is not a great environment for hosting thick clients. Security is probably the biggest hole.  Now the confusion sets in – one essentially has to bet on either Adobe or Microsoft. Be nice if there was some consensus built on how the browser as a platform needs to evolve to support running thick clients instead of having everyone pick sides …

Why JSON beats XML

Tuesday, May 15th, 2007

Last summer I had the opportunity to implement a library that serialized Java objects to JSON strings and de-serialized JSON strings to Java objects. I know I should have used one of the umpteen existing libraries – but hey, I was suffering a temporary bout of NIH :-)

When doing this work, I realized how JSON has really hit upon the sweet spot of data interchange. There are really only two data structures that matter for any sort of data interchange between applications – arrays and hash maps (I’m including any arbitrary combination of the two – for e.g. a hash map of arrays of hash maps). By focusing on these two cases alone and providing a very compact representation, JSON has really nailed the problem of simple and efficient data interchange between applications.

Wasn’t XML supposed to solve this problem ? Well, XML is neither simple nor efficient from a data interchange perspective.

Schema introduces serious complexity when using XML for representing data while not serving any really useful purpose as far as I can see. Most of the issues with dealing with data from foreign sources have to do with interpreting the semantics of the data. Schema only helps with hints about the structure of the data; this is marginally useful and definitely not worth the huge effort involved in defining Schema. Only in the rare case where a certain structure is very widely accepted and used does Schema even begin to make sense.

Now, one could argue for using XML without Schema and I am willing to bet good money that most of the use of XML in the real world is without Schema. But in this case, the other failing of XML – that of efficiency creeps in. XML is too verbose because it was designed to be very general.

JSON has another huge advantage – besides its origins in JavaScript, it has a natural affinity with dynamic languages like PHP, Ruby and Python. Arrays and hash maps are very widely used in programs written in these languages – therefore dealing with foreign data (de-serialized from JSON strings) is no different than dealing with local data. No specially convoluted and over-engineered APIs to learn or use. XML, try and beat that :-)

Java – time to move on

Monday, May 7th, 2007

On the eve of Java One 2007, I for one have decided to move on from Java. I suspect I am somewhat late to the party – there has been a growing trend for some time of developers seeking greener pastures.

I’ve been working with all the major dynamic languages (Python, PHP, Ruby and JavaScript) the past couple of years (I also developed a major Java based system during this time) and have grown to love the huge gains in productivity they offer. In a world that thrives on speed, it is easy to see why this gain in productivity will be immensely valued in the coming years.

While not all of the dynamic language environments are as mature as Java (PHP and Python are definitely very close) in terms of execution speed and availability of tools/libraries, there is a lot of attention being paid to them at this time and I am confident they will mature quickly.

After C, I for one cannot think of a language that has had more impact than Java. In addition to fueling the growth of transactional enterprise web applications, I believe that Java’s portability has really helped fuel the Linux revolution. But all good things must come to an end sooner or later and I believe that we are at that point for Java …

Silverlight – Not Impressed

Wednesday, May 2nd, 2007

Spent some time today downloading and trying out Microsoft’s Silverlight.

While the download and install was very impressive (2 MB), it seems like this thing has a very long way to go.

I was expecting to see more developer focused demos – could not find anything. Just a lot of chartware and some videos. Maybe a sign that Microsoft is trying to be a Media company more than a software company … The videos were of pretty poor quality and I had major issues with getting anything to even play without lots of long pauses. Looking at the list of tools required – seems pretty daunting. Almost everything has a fee associated with it.

I think I like Adobe’s Apollo platform much better at this point. The experience is much slicker, the development story is very clean and the desktop integration is powerful.

Ok, I dug around a bit more and I think I just found the developer site for Silverlight – there was an obscure little link from the main site. What is interesting is that this site renders broken in Firefox – oops!

First look at Plone

Monday, April 30th, 2007

Spent the day checking out Plone. It is a Python based Content Management System. It looks like a very powerful and interesting system for build portals and other web applications. What I particularly like is the ability to mix structured data with unstructured content using a very elegant, unified object-based model. Most other Content Management Systems are weak when it comes to structured data support – it appears Plone has a much stronger model.

I’m going to be trying a couple of applications using Plone and will report over the next few weeks as I make progress on how it all works out. The Plone site has some really cool video demonstrations – be sure to check them out.

I have a hammer …

Wednesday, April 25th, 2007

I’ve finally gotten around to building my first real application using Ruby on Rails – had done a quick walk through a while back, but now I’m doing it at a pace that allows me to go deep. Very impressed by the amount of experience and knowledge that has gone into the framework. Frameworks typically have a learning curve associated with them and RoR is no exception. Couple of good books I’d recommend to anyone wanting to do anything serious with Ruby/RoR are:

So what’s this got to do with the title of my post? Over my years as a programmer, I’ve seen a lot of intense debate around languages and frameworks – how one is better or worse than the other (a popular debate raging these past couple of years has been around RoR versus Java/J2EE). To me, its all about the purpose. Languages and frameworks are typically optimized for a specific set of use cases. In RoR’s case, this turns out to be database based web applications built for the web in its current state of maturity.

As a good programmer, one needs to keep abreast of what’s happening in terms of language and framework development and select the best available ones for a given task at hand. Yes, this requires an open mind and lot of extra learning and work – but we owe it to ourselves and the people who pay us and rely on us to make decisions for them. There is nothing that bothers me more than the programmer who follows the “I have a hammer, so everything looks like a nail” school of thought …