Well this is a concise way to sum up what you want to do, but that could just be rewritten in any language of your choice. Then the appropriate libraries written. For example, java:
createForm("click here", new Response("you said %foo"), new InputElement("foo"), new SubmitElement());
I think there's more important things to compare in languages. speed, error handling, stability, memory management etc
Here's the critical distinction: you can use only whatever's already provided by the language+libraries you use. That's what I did. I didn't go back and add stuff to the Arc libraries to make the answer to the challenge shorter. I just used what was there already. This will be clear to anyone familiar with the source of HN; all the language features used in the Arc version of the challenge are used throughout news.arc.
But I could just write 'arc' for Java, and the above example would fall out.
The solution for arc doesn't have anything unique in it that you can't do in other languages just as concisely.
So I don't think it says anything at all about the language, it just says how well you designed the interface to helper libraries.
>> "all the language features used in the Arc version of the challenge are used throughout news.arc."
I don't see any 'language features' in the solution for Arc. It's just functions and parameters. They're not language features, they're helper libraries. They may be well designed good libraries, but that's what they are. The language used is irrelevant. You could have written arc in BASIC and the solution would be the same.
Maybe I just don't understand why arc is referred to as a 'language' rather than a framework/library, and why that distinction is important.
But I could just write 'arc' for Java, and the above example would fall out.
In terms of language design, if you were to write news.arc for Java, would you expect a solution to the challenge to just fall out? This probably says more about MzScheme+pg vs Java+you than it does about arc, however.
One language feature that's used here is lexical closures. This would be hard to implement concisely in a language without them.
If you wrote an Arc implementation in Java, then ran the program on top of that system, surely that would count as an instance of Arc winning the the challenge, not Java.
I'm not even sure if you're serious at this point, but the important distinction here is that the hypothetical library function you created to make this work in Java is (like the even shorter version proposed here: http://news.ycombinator.com/item?id=1005199) not one that anyone ever would put in a library. Its only function is this one case. Whereas the Arc version is built by combining highly orthogonal components that can be recombined to solve completely different problems. Do you really not see the difference?
Its only function is this one case. Whereas the Arc version is built by combining highly orthogonal components that can be recombined to solve completely different problems. Do you really not see the difference?
This is why the appropriate test is the ability for an average programmer to put together a DSL for a randomly-selected problem domain: it actually speaks to the power of the language. The characteristics of orthogonality and combinatorial flexibility is what DSLs are made to do. Arc doesn't have a monopoly on them. The only thing that is interesting here is your choice to include web-specific functionality in Arc. I think it's a great choice, but it just doesn't say much about the general expressiveness of the language as a whole.
We may have reached the point here where splitting hairs over DSLs versus included libraries is not going to get anybody anywhere. From what I understand, I would certainly agree that Arc programmers having such easy access to stateless web programming in a highly flexible manner is a great thing for the language.
But I would judge any language by the ability to easily add solutions to other problem domains that are highly orthogonal and flexible, not necessarily by the problem domains that are enabled by default.
Hope that makes sense. I think I finally figured out what your point was.
You've widened the scope of "language" to its libraries. And that's entirely fair. So, yes, Arc has it "built in", but Arc itself is (IMO) only marginally more mature than the libraries one might invent for (e.g.) Haskell to do the same thing (ok, I'm being a little unfair here, but not that much IMO). And one can invent those libraries for another language and can match Arc in the challenge using those invented libraries -- at least you don't seem to be denying this.
So, then, what's the point? That Arc already has the libraries available? That the Arc libraries meet the challenge? It certainly isn't that those libraries aren't possible in another language. The challenge means (almost) nothing with regards to comparing programming languages as you first implied, and is more about what tools and libraries were invented along with Arc to develop web apps.
And one can invent those libraries for another language and can match Arc in the challenge using those invented libraries -- at least you don't seem to be denying this.
Depends on the language, obviously. It seems unlikely you could in C, for example. Presumably the problems you'd encounter would gradually decrease as the language grew more powerful. That's why I phrased the problem as a challenge. I was curious to see what happened when you tried to solve this very simple problem using existing language/library options.
No, actually, I didn't. I chose the simplest stateful web app I could think of: take input on one page and print it back on the next. What about that problem is specific to Arc?
Not specific, of course you can do it without much trouble in language/framework. It's easy to do in Arc, and with web programming with continuations in general. You want an example that is representative of things you'd like to do in practice. This example isn't. I'm not saying you did that deliberately. You have been programming websites in this continuation style for a long time, so it's understandable that you'd choose an example that's simple with continuations if you try to choose a simple example instead of a representative example. Most web programming is (1) display a list of things (2) display a detail view for something in the list (3) provide a form to add something to the list. The code for such an example provides much more information about how good a language/framework is for real world programming.
By the way, why did you choose to use string names for the data in the input form? Why not use variables directly and make aform work more like let (and like Mathematica's manipulate):
(form
(name (input-string))
(age (input-number))
(pr "Hello, " name ". You are " age " years old."))
Where input-X writes HTML output and returns a function that extracts the value of the field from the HTTP request. Validation works well too.
Comments
The distinction between 'program' 'language' 'library' 'framework' is just arbitrary though.
Just another vote for 'I have no clue what the point of this is'.
The challenge seems to be:
Obviously that's possible in any language, so I don't understand how this measures languages at all.The example in Arc:
Well this is a concise way to sum up what you want to do, but that could just be rewritten in any language of your choice. Then the appropriate libraries written. For example, java:createForm("click here", new Response("you said %foo"), new InputElement("foo"), new SubmitElement());
I think there's more important things to compare in languages. speed, error handling, stability, memory management etc
Here's the critical distinction: you can use only whatever's already provided by the language+libraries you use. That's what I did. I didn't go back and add stuff to the Arc libraries to make the answer to the challenge shorter. I just used what was there already. This will be clear to anyone familiar with the source of HN; all the language features used in the Arc version of the challenge are used throughout news.arc.
Hrmmmm.
But I could just write 'arc' for Java, and the above example would fall out.
The solution for arc doesn't have anything unique in it that you can't do in other languages just as concisely.
So I don't think it says anything at all about the language, it just says how well you designed the interface to helper libraries.
>> "all the language features used in the Arc version of the challenge are used throughout news.arc."
I don't see any 'language features' in the solution for Arc. It's just functions and parameters. They're not language features, they're helper libraries. They may be well designed good libraries, but that's what they are. The language used is irrelevant. You could have written arc in BASIC and the solution would be the same.
Maybe I just don't understand why arc is referred to as a 'language' rather than a framework/library, and why that distinction is important.
But I could just write 'arc' for Java, and the above example would fall out.
In terms of language design, if you were to write news.arc for Java, would you expect a solution to the challenge to just fall out? This probably says more about MzScheme+pg vs Java+you than it does about arc, however.
One language feature that's used here is lexical closures. This would be hard to implement concisely in a language without them.
If you wrote an Arc implementation in Java, then ran the program on top of that system, surely that would count as an instance of Arc winning the the challenge, not Java.
The Java example I gave didn't use them, and is more concise. I think it's pretty readable.
I'm not even sure if you're serious at this point, but the important distinction here is that the hypothetical library function you created to make this work in Java is (like the even shorter version proposed here: http://news.ycombinator.com/item?id=1005199) not one that anyone ever would put in a library. Its only function is this one case. Whereas the Arc version is built by combining highly orthogonal components that can be recombined to solve completely different problems. Do you really not see the difference?
Its only function is this one case. Whereas the Arc version is built by combining highly orthogonal components that can be recombined to solve completely different problems. Do you really not see the difference?
This is why the appropriate test is the ability for an average programmer to put together a DSL for a randomly-selected problem domain: it actually speaks to the power of the language. The characteristics of orthogonality and combinatorial flexibility is what DSLs are made to do. Arc doesn't have a monopoly on them. The only thing that is interesting here is your choice to include web-specific functionality in Arc. I think it's a great choice, but it just doesn't say much about the general expressiveness of the language as a whole.
We may have reached the point here where splitting hairs over DSLs versus included libraries is not going to get anybody anywhere. From what I understand, I would certainly agree that Arc programmers having such easy access to stateless web programming in a highly flexible manner is a great thing for the language.
But I would judge any language by the ability to easily add solutions to other problem domains that are highly orthogonal and flexible, not necessarily by the problem domains that are enabled by default.
Hope that makes sense. I think I finally figured out what your point was.
The Java solution I pasted is "built by combining highly orthogonal components that can be recombined to solve completely different problems".
createForm("click here", new Response("you said %foo"), new InputElement("foo"), new SubmitElement());
Does this not look like a combination of highly orthogonal components that could be recombined to solve a variety of problems?
So no, I can't see any different whatsoever. I'm guessing we'll just have to agree to disagree at this point.
And it used fewer tokens.
This doesn't make sense to me.
You've widened the scope of "language" to its libraries. And that's entirely fair. So, yes, Arc has it "built in", but Arc itself is (IMO) only marginally more mature than the libraries one might invent for (e.g.) Haskell to do the same thing (ok, I'm being a little unfair here, but not that much IMO). And one can invent those libraries for another language and can match Arc in the challenge using those invented libraries -- at least you don't seem to be denying this.
So, then, what's the point? That Arc already has the libraries available? That the Arc libraries meet the challenge? It certainly isn't that those libraries aren't possible in another language. The challenge means (almost) nothing with regards to comparing programming languages as you first implied, and is more about what tools and libraries were invented along with Arc to develop web apps.
And one can invent those libraries for another language and can match Arc in the challenge using those invented libraries -- at least you don't seem to be denying this.
Depends on the language, obviously. It seems unlikely you could in C, for example. Presumably the problems you'd encounter would gradually decrease as the language grew more powerful. That's why I phrased the problem as a challenge. I was curious to see what happened when you tried to solve this very simple problem using existing language/library options.
> I didn't go back and add stuff to the Arc libraries to make the answer to the challenge shorter
Yes, instead of creating a new library for the challenge you created the challenge to suit the library.
No, actually, I didn't. I chose the simplest stateful web app I could think of: take input on one page and print it back on the next. What about that problem is specific to Arc?
Not specific, of course you can do it without much trouble in language/framework. It's easy to do in Arc, and with web programming with continuations in general. You want an example that is representative of things you'd like to do in practice. This example isn't. I'm not saying you did that deliberately. You have been programming websites in this continuation style for a long time, so it's understandable that you'd choose an example that's simple with continuations if you try to choose a simple example instead of a representative example. Most web programming is (1) display a list of things (2) display a detail view for something in the list (3) provide a form to add something to the list. The code for such an example provides much more information about how good a language/framework is for real world programming.
By the way, why did you choose to use string names for the data in the input form? Why not use variables directly and make aform work more like let (and like Mathematica's manipulate):
Where input-X writes HTML output and returns a function that extracts the value of the field from the HTTP request. Validation works well too.