Hacker News new | past | comments | ask | show | jobs | submit login

I did a quick Ruby version just to serve a basis for my point:


The reason I posted that was precisely because of the point where Arc shines: no inline HTML. But in practice, I want to avoid putting my presentation logic inline with my programming logic anyway.

And I fear that's the problem with the challenge; it seems to be highlighting the wrong kind of simplicity. I could add a few utility functions to make Ruby able to generate that HTML with a tiny amount of code, but I wouldn't ever actually use those functions in a real program.

Edit: Out of curiosity, I just implemented a pseudo-concision-obsessive "library" so see how a Ruby version might look:


I'll note that Rails does have things like those that are often used templates.

Another edit: Moved code samples to pastie for readability.

The other matter of style is whether the order of the code matches the order in which the user interacts with it.

The three steps in user experience order:

  first:  a form to accept input,
  second: a link to click
  third:  a printout of the input
Here are the orders used in code:

  Ruby+sinatra:   third, first, second
  arc version 1:  third, second, first (original)
  arc version 2:  second, third, first (May 2009)
  Haskell+custom: first, second, third
Interesting results, I think Haskell wins here. Though technically it fails the challenge (the arc version 2 example fails too) since the supporting library was written after the challenge was considered by the author of the example.

The Perl+Continuity solution also uses "first, second & third" style and does it nicely without sessions and adheres to challenge by being an established library: http://arclanguage.org/item?id=805

Here is a version using the HTML::AsSubs module:

    use Continuity;
    use HTML::AsSubs;
    Continuity->new->loop; # This starts the webserver

    sub main {
        my $request = shift;
        my $p = 'foo';

        $request->print( aform( $p )->as_HTML );
        my $foo = $request->next->param( $p );
        $request->print( w_link()->as_HTML );
        $request->next->print( "You said: $foo" );

    sub aform {
            input( { type => 'text', name => $_[0] } ), 
            input( { type => 'submit'} )

    sub w_link { a( { href => '.' }, 'Click Here' ) }

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact