Posted by matijs
Sun, 17 Feb 2008 21:14:00 GMT
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
Posted in software | Tags arc, continuations, design, language, rest, ruby | 2 comments | no trackbacks
Posted by matijs
Thu, 14 Feb 2008 21:35:00 GMT
I’m upset. I’m so upset that I was originally going to call this entry “Fuck you, Python”. Now, I realize that’s not a very nice thing to say, and actually, Python can’t really help it anyway. Except by not existing1.
Why, why, why must every other new language created these days have significant indenting? You see a new language, like Cobra, you read the overview of features, and you go, cool, great runtime performance, static and dynamic typing, and contracts, too. So you browse on to the hello world example, and boom! the absence of end-of-block tokens hits you in the face like an iron fist.
Now, in Python’s case you can tell from the reasoning2 and the implementation that somebody actually thought this through, but Cobra has the following rationale for using this method of block structuring:
Cobra uses indentation to denote code structure since adept programmers do this anyway in languages that don’t even require it (C#, Java, C++, etc.)
Wow. I’m going to make a language that uses the comma-space token to separate function arguments, since adept programmers put a space after the comma in languages that don’t even require it.
Look, if you use indenting for block structure because you like Python, just say so already.
Oh wait, there’s more:
In Cobra, one INDENT is accomplished by one TAB or four SPACES.
Huh? Because adept programmers indent four characters anyway even in languages that don’t require it? Because adept programmers use one tab per four spaces anyway even in editors that don’t require it?
Sheesh.
I feel much calmer now.
1 See how reasonable I am. I’m not actually calling for the non-existance of Python.
2 I don’t agree with that reasoning either, but at least it’s, you know, reasonable.
Posted in software | Tags cobra, indent, madness, python | 3 comments | no trackbacks