Toxic Elephant

Don't bury it in your back yard!

The Arc Challenge

Posted by matijs 17/02/2008 at 21h14

Hm, so Arc is here, and Paul Graham gives the Arc challenge. The answer in Arc is short indeed. First, let’s see an answer in Rails (loading a framework is allowed according to the challenge), with said_controller.rb:

class SaidController < ApplicationController
def index; end
def click; session[:it] = params[‘what’]; end
def show; end
end

and some templates, for the first page, index.html.erb:

<% form_tag ‘/said/click’ do >
<
= text_field_tag ‘what’ >
<
= submit_tag >
<
end %>

second page, click.html.erb:

<%= link_to ‘click here’, {:action => ’show’} %>

third page, show.html.erb:

You said <%= session[:it] %>

The Rails answer may be a little longer (although by how much is hard to say due to the different syntax — is end a token?), but it not a case of the same but longer.

First, the Rails version is in temporal order, the Arc version is not. Perhaps there’s a way of reading the Arc version that makes this order natural, but right now, it looks confusing.

But the most striking difference is that it is based on a completely different philosophy of how web applications should be developed. The Arc answer is great if you want a web application based on continuations. The Rails answer is what you would use if you want to use REST.

I’m definitely in the REST camp, which makes this example meaningless as a demonstration of Arc. It shows me that Arc can be used to write a short program that does something I don’t want to do.

The ultimate question of course is whether brevity (in terms of number of tokens, not characters) is the single best metric for language power.

Update: Someone wrote a Ruby version that is about as short as the Arc version, uses the same paradigm, and is in temporal order:

def said
aform(input(“foo”), submit) {
w_link(“click here”) {
“you said: #{arg :foo}”}}
end

Tags 2 comments no trackbacks

Comments

  1. Alicia said 18/02/2008 at 12h23:

    I should try this out. I will be trying Arc. I find it much easier actually.
  2. Matijs said 18/02/2008 at 15h15:

    @Alicia: Sure you do.

Comments are disabled