Arc Challenge

Thu, 07 Feb 2008

Paul Graham has issued a silly challenge to compare show how Arc compares with other languages. The idea is to

generate a page with an input field and a submit button. If the user clicks on submit, he gets a second page with a link saying "click here." If he clicks on that, he gets a third page saying "you said: ..." where ... was whatever he put in the input field. This has to happen without the value being passed in the url; it should not be possible to change the behavior of the third page by editing the url in the second.

Here's my take. Instead of using Python I used Javascript, together with the fantastic jQuery library:

1
2
3
4
5
6
$('<form><input /><input type=submit /></form>').appendTo('body').submit(function() {
    $('form input').hide().parent().append('<a href="#">continue</a>').find('a').click(function() {
        $('form').html('you said: ' + $('form input').val());
    });
    return false;
});

The code runs completely on the client-side, and uses a loose definition of "page", since the browser never reloads. After coming up with this solution I saw a couple more of Javascript solutions on the challenge page, and one of them also uses jQuery. But I was more interested in this Seaside solution from Lukas Renggli. I tried playing with Squeak/Seaside some time ago, but the documentation consisted of out-of-date tutorials spread over a dozen different websites. Maybe I should give it another try.

Roberto De Almeida