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 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.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 {
form(
input( { type => 'text', name => $_[0] } ),
input( { type => 'submit'} )
);
}
sub w_link { a( { href => '.' }, 'Click Here' ) }
I honestly didn't think any of the things I did in the original Arc challenge required features that wouldn't already have existed in a language that had been used for web programming. All it does is ask the user to input something, then show it on another page. It's practically the hello world of stateful web apps. It seemed reasonable to expect any language that had been used for web apps would already have had convenient libraries for doing such basic things.