Archive for the 'Tech' Category

REST is the assembly language of the web

Some recent REST-related traffic in the blogosphere (both pro- and anti-) has discussed the ‘challenge’ of there being only a handful of REST verbs. The discussions revolve around how to map those verbs and the resources they act upon to a wide range of application functions. So we have Stefan (Tilkov?) writing: “I force my application semantics to adhere to the common HTTP semantics …”

Ugh! This smells like assembly-language programming. Application code isn’t written with CPU instructions and registers in mind; compilers and runtimes were long ago designed to take care of that.

We are at a primitive point in the development of applications to run on this networked computer. We need automatic compilation of high-level languages into ‘REST Assembly Language’ so we can write distributed applications much nearer to their problem domains.

Talk about RISC! This distributed computer has a tiny instruction set but limitless locations into which limitless pieces of information are organised.

Writing good compilers will be very challenging, but if the REST vision is to be fulfilled, very worthwhile.

REST with JSP

I was interested to read Bill de hÓra’s question about whether servlets and JSP can be used to create a RESTful application without resorting to RPC-style URIs like:

http://www.innoq.com/blog/entry.jsp?id=java_web_frameworks

Absolutely yes! A beauty for me of the web side of Java EE is that the URI can take any format you like. So, to use a URI like:

http://www.innoq.com/blog/st/2007/08/15/java_web_frameworks.html

we could work as follows.

  1. The externally facing URI is probably mapped by a reverse proxy or content switch (or the like) to the blogging application on a Java EE application server. The internal URI might be something like:

    http://s012.innoq.com/javablog/blog/st/2007/08/15/java_web_frameworks.html

  2. The application server might interpret the URI like this:

    /javablog: Root web context of the Java blogging application.

    /blog: Part of the URI that maps to a servlet for serving all blog pages. In web.xml it may be mapped with:

    <servlet>
       <servlet-name>BloggingServlet</servlet-name>
       <servlet-class>com.innoq.blogging.web.BloggingServlet</servlet-class>
       ...
    </servlet>
    <servlet-mapping>
       <servlet-name>BloggingServlet</servlet-name>
       <url-pattern>/blog*</url-pattern>
       ...
    </servlet-mapping>
    

    Further work continues in the servlet’s doGet method.

    /st/2007/08/15/java_web_frameworks.html: This string is available to the servlet using request.getPathInfo().

  3. The servlet tokenises the string and works with the information. For example st is used to brand the blog as belonging to Stefan Tilkov, 2007, 08 and 15 are date identifiers and java_web_frameworks is the post slug, with .html to indicate that the content type of the response is text/html.
  4. The servlet uses that information to retrieve the post from the persistence store and assembles request-scope objects that will be used by the JSP.
  5. The servlet forwards to the JSP, which templates the HTML response. For example:

    request.getRequestDispatcher("/WEB-INF/jsp/blog_post.jsp").
    forward(request, response);

    The JSP is never called via a URI that maps to its directory structure. It can (as in this example) reside under the WEB-INF directory, which cannot be mapped to a URI path.

Caching? That can be done by the servlet or by the application server or somewhere in front of that. Or publishing a post may result in the creation of an HTML file on disk in a directory structure that maps directly to the URI.

OpenID delegation

Thanks to Simon Willison’s clear description of how to delegate an OpenID, I can use michaelstrasser.com as my OpenID URL.

In my previous investigations of OpenID I hadn’t discovered delegation. Brilliant!

Why no OpenID?

The latest web idea that might catch on is revyu (and it’s alpha alpha alpha alpha alpha alpha alpha alpha alpha alpha alpha alpha alpha, so don’t expect too much).

It looks like a good idea, but to use it I need to create yet another bloody net login! Aren’t we past that yet? Why no OpenID?

I almost Googlewhacked with a search for revyu openid: two pages generated by del.icio.us and one No such article from Gmane.

Scrolling into Google Maps

I just discovered that Google Maps supports zooming with scroll-wheel mice. This is fantastic and makes the browser-based Maps much easier to use.

It works in IE6 and Firefox on Windows, and in Firefox, Safari and Opera on Mac. Well done, Google!

One thing though: the scroll wheel direction in Google Maps is opposite to that in Google Earth. In Maps a forward (up) scroll zooms in and a backward (down) scroll zooms out (this feels natural to me). But in Earth (as it is in Heaven?) a forward scroll zooms out and a backward scroll zooms in.

Are there competing software development camps in Google, like in Microsoft?

News services overload

Many Australians found out about the death of Steve Irwin today around 2pm local time, about three hours after he died. Word spread quickly around my office after one person found out via a phone call.

Like very many Australians (also in offices, I guess) I jumped on the Net to find out more. After reading a quick report on ABC News Online I looked further. I was amazed that for over half an hour all of these Australian online news services were overloaded:

ABC News Online quickly put up an apology page, followed 20 minutes or so later with a Steve Irwin news page. It had a message stating that their servers were overloaded and that other features of ABC Online would be restored soon. The other services simply didn’t return pages.

It’s quite concerning that when this story broke, not one of the major Australian online news channels could cope with the load. What would happen if some really serious news broke during the day? Something like an Iranian nuclear attack on Israel?

Or wouldn’t as many Australians clamour to find out more as quickly?

New cycling monkey

Last year I created a Greasemonkey script for highlighting results from the Tour de France on cyclingnews.com. I’ve continued to use the script since then for other races. I’ve also updated the team colours and improved how it works.

Recently I added keyboard shortcuts to make it easy to jump between pages:

Key Function
n Go to the page at the link ‘Next Photo’ or ‘Next News.
p Go to the page at the link ‘Previous Photo’ or ‘Previous News.
r Go to the page at the link ‘Related Story’.
h Go to cyclingnews.com home page.
f Go to the named anchor ‘focus’ on the current page. Another part of the script writes this named anchor next to the <img> tag. This is useful to scroll down to a portrait-orientation photo that is partly obscured in the browser window.

Here is the script for your enjoyment. It replaces the old hightlighttdf2005.user.js. Let me know if you have new ideas, better team colours (or other styles) etc.

Geek onion

Fun with layers! I am sitting with my computer at home, connected to a server at work like this:

  1. My computer is a MacBook Pro running OS X.
  2. It is running a virtual machine in Parallels Desktop.
  3. The virtual machine is running Windows XP.
  4. Windows has a VPN client connected to my work.
  5. I am controlling my Windows 2000 PC at work using PC Anywhere.
  6. My PC at work is connected to the server at work using a Microsoft Remote Desktop connection.
  7. The server is a VMWare virtual guest running Windows Server 2003.

That’s three computers, five operating systems (counting VMWare ESX) and a couple of network layers (VPN to the network at work over virtual Ethernet on Parallels connected to WiFi and cable broadband).

Yes, I know that I can remote to the server direct from Windows XP in Parallels (after connecting via the VPN) but that would spoil the fun, wouldn’t it?

No new switch for me yet

Mark Pilgrim’s recent announcement that he is switching away from Mac OS X to Ubuntu Linux after very many years using Apple’s products has caused a few waves. John Gruber reacted back at length and Mark replied spelling out his gripes in more detail. Tim Bray thinks he will switch soon too. With the weight of these eminent thinkers on my head, I thought more about why I switched to Mac 18 months ago and whether I would switch again. (Leaving aside the matter that I have just bought a new MacBook Pro and won’t be changing for a couple of years at least.)

My overriding feeling is that I switched because Windows really annoys me. I had used and programmed Macs and PCs on and off over 15 years and was sick of the whole Windows thing. I still use Windows at work (I have no choice) but wanted a different experience at home. I’m getting into digital photography and felt the Mac would be a better match to my ‘creative side’. I also like the geeky side of Mac: it’s a Unix box under the hood and has a real scripting language built-in.

Perhaps the tipping point for me was about presentation. For example, I care about the way language looks: not only spelling and punctuation, but typography as well. (Evidence: I own a copy of Robert Bringhurst’s The Elements of Typographic Style — a beautiful book.) So I want to be able to type the correct quotes, dashes etc. in any application, not just Word and those with some kind of auto-correction. On a PC, it is a pain: at work I bother to type Alt+0145 and Alt+0146 (with leading zeros, on the numeric keypad) when I want open and close single quotes. (And it’s an extra challenge on a laptop without a numeric keypad.) On a Mac it is much easier (although not always intuitive): Option+] and Option+} (respectively) – a single, combined keystroke, not four. The folks at Apple thought of that in 1984.

I agree with a lot of Mark’s concerns about format lock-in and, luckily, have avoided them. I have stuck with cross-platform, standard apps that I used on Windows: notably Firefox and Thunderbird. I also use OpenOffice for the small amount of office-type stuff I have to do.

Could I give up what I have now and switch to Linux? A quick look at Ubuntu today (running under Parallels Desktop on my MacBook) reveals the best Linux desktop experience I have had so far. Perhaps 70% of the functionality I want is there. (Adobe Lightroom for Linux? Not likely, I fear.)

But not enough to switch yet. (How do you enter a RIGHT SINGLE QUOTATION MARK in Ubuntu?)

XY and EA

The XY Problem has been recognised among Perl Monks and perfectly describes a problem we often encounter in Enterprise Architecture (EA). The XY Problem is succinctly stated as:

Someone has a need to do X and believes Y is the best solution. So they ask about Y instead of asking about X.

In the planning phase of a project, architects work with business people to help them find the best solution for their requirements, in the context of the enterprise in which they work. But many people don’t understand EA yet, so customers often come to us with a solution firmly fixed in their minds: “I want one of those. Help me implement it.”

‘XY Problem’ describes the problem perfectly, but it needs a better name. It isn’t about Cartesian geometry. It isn’t about sex chromosomes and transgender issues. Has anyone seen a better name for it?

Next Page »