Thursday, October 30, 2008

Web services

Tim O'Reilly has written another great essay explaining the three types of cloud computing: Utility Computing, Platform as a Service, and cloud-based end-user applications.

For now let's focus on just one consequence: "Web Services" finally get real. Let's go through the various services that are already emerging. Remember, these are not only services for consumers, but also a platform for developers.

Most obviously, identity. This includes authorisation, authentication, presence, and basic user data e.g. email address. OpenID and OAuth are the emerging standards in this space, with support already from Google, MySpace, Microsoft, and Yahoo.

Secondly, social networking basics : Friends & the Activity Stream. OpenSocial is the emerging standard here.

Third, basic content: Images, Videos, Audio, Blogs. The emerging standard here is Atom. However services will likely get enhancements; for example, the ability to manipulate the underlying files e.g. removing red-eye on photos or enhancing audio treble.

Fourth, various additional services:

  • Location-based services e.g. Maps / GPS
  • Time-based services e.g. calendars / tasklists / clocks
  • Messaging (email, instant messaging, phone)
  • Financial services (payments, credit checking, etc)

Finally, professional content:

  • News
  • Sport
  • Financial

All of these services already exist on the web, but they are in silos and can't easily be accessed by developers. Finally now, web application providers are rushing to become platforms for developers, opening up their data using standard patterns like REST and OAuth.

For example, Paypal could offer to track your payments in Google Calendar. Or you could ask the BBC to enter any news items within 20 miles of your house into your Myspace Activity stream. Or you could put your phonecall history there. Or your project management system at work could put events into your personal calendar or task list.

From the consumer perspective, the web will become a lot more connected and personalised. From the developer perspective, there will be a huge number of web services making user data available securely (photos, videos, friend list). Writing a web application will involve plugging in to these standard services. Finally, the vision of web services will become real.

Web Office suites are a dead end

So, Microsoft have finally confirmed that a web-based version of Office is due soon.

That's good news. It means that Microsoft are responding to competition from Google and Zoho; hopefully in turn Google and Zoho will improve their products, which can only benefit the end consumer. It also means that the web has finally broached the biggest consumer software market in the world, the office suite. Web 2.0 has won!

However, while Web 2.0 might have won, I don't think the office suite will survive much longer. Microsoft, Google and Zoho may have faithfully reproduced the troika (word processor, spreadsheet, presentation) on the web, but its time has passed.

We've been stuck with these three applications for so long that it's difficult to see past them. But they've only survived due to network effects: everyone has them, because everyone else has them. It's time to re-examine their purpose.

First, the rise of the long tail. Because the browser is a general purpose platform, all sorts of special-purpose applications can be used instead of an office suite. Why use Microsoft Word to manage your CV, if you can use instead, which gives you CV advice and links you to employers? Why use Excel to manage your personal finances, if you can use, which automatically downloads, categorises and charts your bank accounts for you? Why use Powerpoint to explain your business, if you have a business website that does the same and is accessible to millions?

Second, the rise of the widget. Ever seen a video embedded in a spreadsheet, or an interactive calendar embedded in a presentation? I thought not! But because the browser is a general purpose platform, it's possible on the web. Many widgets like these that defy categorisation will spring up. Is it really a spreadsheet if you use it to post photos? Is it really a word processor if there is a table with formulas embedded? The spreadsheet, word processor and presentation will merge together into a single platform with many different widgets.

Finally, of course, the rise of collaboration. To an elder generation, something you did with the Nazis. To the younger generation, the whole point of content. If you can't see your friends, and make your content available to them, then they won't want it. That applies at work even more than outside work. The web office will be embedded inside a social network. It'll look more like Facebook than Powerpoint.

Microsoft's screenshots of the web version of Office look like they've faithfully reproduced Office in the browser. I think this approach will lead to a dead end. The all-powerful office suite is fading fast, and even the web can't save it.

Separating code from content and presentation

Most web designers nowadays know that content and presentation should be separated. There are still a few examples of HTML <table> and <br> elements used for layout, instead of CSS, but this is diminishing.

The same can't be said of separating code (i.e. javascript) and presentation. I still see lots of examples of layout being set via javascript. It's even built into most javascript frameworks - for example, jQuery has a set of css methods to allow the likes of $('#div1').css("color: red").

That's just wrong. You can't hope to maintain your website's style if you set CSS via javascript - it's difficult enough organising CSS files without having to wade through javascript as well to figure out why a certain style is set. Re-designing your site will require you to change all your code too!

The best solution is to remove all javascript and simply use CSS, with pseudo-classes like :hover and :active to get more control. However, if you're responding to a more complicated event, then you should use classes. Just do $('#div1').addClass('highlighted') instead. You can maintain the actual style in your CSS file, in this case div.highlighted {color: red}.

Similarly, I always try to remove all HTML from my code. It's very easy to get caught up creating and inserting whole DOM trees via javascript alone. But this is inaccessible to search engines, and creates content management nightmares. Now you have to search all your javascript to find where the image came from, as well as the HTML files!

The best solution to this is to remove all javascript and simply use HTML and CSS. However, if you're responding to a more complicated event, then you should have the additional markup already present in the HTML file, perhaps hidden using CSS display:none. You can simply turn it on in your code, without having to create it.