8 ms·
Very nice work, and the code is clear and beautiful to a Haskell illiterate such as myself. But I have a problem. If your solution involves writing a library an
by gruseom 17y ago
Very nice work, and the code is clear and beautiful to a Haskell illiterate such as myself. But I have a problem. If your solution involves writing a library and importing it, have you really written a program with "only 13 nodes total"? If the answer is yes, then why can't I just put that program into a library, call it from a new program with only 1 or 2 nodes, and say "look at the size of this!"?
It's not obvious what counts as "the language" and what as "a library". Is printf part of C?
I suppose one could argue that if a library is general enough to make an entire class of programs shorter, as opposed to a few specific programs, then it gets to count as "the language". But that doesn't resolve the question so much as reword it.
Anyway, this is probably more of an objection to the original challenge than it is to this lovely Haskell code.
- wheels 17y agoYes, I had the same problem with the initial challenge. I could patch virtually and programming language implementation such that it would be possible to write a 5 line web app, but that doesn't really say much about the language.
- jrockway 17y agoBut Arc itself is is exactly this "patch of a programming language implementation". Also, everything in programming could be much less concise if you wanted it to be. Consider addition. It's an operator in your language. Then it's a CPU instruction. Then it's bits going through logic gates. Since it's a common thing to use, the complexity is abstracted away in many places. If you are writing web apps, it makes sense for your web app libraries to abstract the web stuff away like this too.
- DanielBMarkham 17y agoI have had the same problem with the challenge as the gp ever since I read it. I'm a bit perplexed at what exactly Paul's point was. So I write a templating module for OCaml that lets me beat or tie the Arc challenge. I compile it and never have to look at it again. It becomes part of my toolkit. What do I have to do in order to win the challenge? Get my module accepted into some standard library? Why would what some language committee decides be important in terms of how expressive the language is? It doesn't make sense to me. All it shows is that Paul controls Arc and has configured it to deliver small answers to questions that he finds important. I'm not sure it says anything about Arc or any other language for that matter. It might say something about functional versus imperative languages, but perhaps we already knew that?
- pg 17y agoI'm a bit perplexed at what exactly Paul's point was. What do I have to do in order to win the challenge? I think the source of your perplexity may be that you're misunderstanding who (or rather what) is being challenged. It's not a contest between people, but between languages. So you don't win it; a language does. The way a language wins is if you can write the program shorter using it plus some standard libraries. The definition of "standard" doesn't have to be exacting; anything short of a library written specifically to win this contest would be ok; so e.g. any library that existed prior to the challenge obviously would be.
- axod 17y agoThe 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: * Write a library with helper functions. Like the Arc library. * Now you can write a short program that uses that library to do things. Obviously that's possible in any language, so I don't understand how this measures languages at all. The example in Arc: (defop said req (aform [onlink "click here" (pr "you said: " (arg _ "foo"))] (input "foo") (submit))) 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
- floodyberry 17y agoIt wasn't supposed to measure anything, it was supposed to impress you with how awesome Arc is.
- pg 17y agoHere'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.
- pg 17y agoThe criterion for tests like this is whether you're relying on stuff you'd expect any language already to have, or not. Features fall on a continuum in that respect. You'd expect any language to be able to add two numbers; you couldn't expect a language to have a library for parsing some format you'd just invented; other features fall somewhere between these extremes. 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.
- wheels 17y agoI did a quick Ruby version just to serve a basis for my point: http://pastie.org/750268 http://pastie.org/750268 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: http://pastie.org/750269 http://pastie.org/750269 I'll note that Rails does have things like those that are often used templates. Another edit: Moved code samples to pastie for readability.
- DougBTX 17y agoThe 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.
- lg 17y agoI thought the point of the arc challenge was to say to ruby/rails, smalltalk/seaside, python/django, etc., "hey, look what my language/libraries can do, can yours do this? or better than this?" If the answer is "no, I need to write a new library to do that sort of thing, or rewrite my existing one," then arc beat your language/library at the challenge.