Paul Graham has developed his own language, called Arc, a dialect of Lisp. He writes about Arc:
I didn't decide what problems to work on based on how hard they were. Instead I used what might seem a rather mundane test: I worked on things that would make programs shorter.
To demonstrate the powerful brevity of Arc, he has offered a challenge.
I'm going to propose a simple problem as a challenge. We'll collect solutions in each of the popular languages, and compare their lengths. Here it is:Write a program that causes the url said (e.g. http://localhost:port/said) to produce a page with an input field and a submit button. When the submit button is pressed, that should produce a second page with a single link saying "click here." When that is clicked it should lead to a third page that says "you said: ..." where ... is whatever the user typed in the original input field. The third page must only show what the user actually typed. I.e. the value entered in the input field must not be passed in the url, or it would be possible to change the behavior of the final page by editing the url.Though simple, as such tests have to be, this is not a contrived example. Web apps have to do this sort of thing all the time. Nor does it depend on some sort of esoteric libraries that Arc has and other languages don't; this is all stuff that any language used to write Web apps would have to have already.
Here's the answer in Arc:
(defop said req (aform [w/link (pr "you said: " (arg _ "foo")) (pr "click here")] (input "foo") (submit)))I think The example from Arc is short enough that there really can't be any meaningful competition. Suppose there is a shorter solution somewhere. It can't be much shorter, so that's not much of a win. If it is a lot shorter, it's probably incomprehensible.
I found the replies interesting. There's one using Catalyst that's shorter than I expected (but I don't know much about Catalyst). Another uses Continuity.
My own personal opinion is that brevity and power often go together, but it's not hard to get too much of a good thing. Have a look at APL, for instance (but don't look too long). Rarely do "golfing" and "getting your work done" go together.
In reply to Take the Arc Challenge by kyle
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data! Titles consisting of a single word are discouraged, and in most cases are disallowed outright. Read Where should I post X? if you're not absolutely sure you're posting in the right place. Please read these before you post! — Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
For: Use: & & < < > > [ [ ] ] Link using PerlMonks shortcuts! What shortcuts can I use for linking? See Writeup Formatting Tips and other pages linked from there for more info.