My problem with cucumber is not the idea of a high-level DSL for tests. Au contraire--I think this is a perfect place for a little language. I could easily see a similar tool being useful for Haskell.
Rather, my issue is with the syntax. Not gherkin in particular but rather languages that try to look like English in general. For one, these languages tend to hit the uncanny valley--they're somewhat natural, but not entirely. Perhaps the code reads like poorly written prose, but you certainly can't write it in a natural fashion!
More importantly, I do not think prose is a good format for this sort of thing at all. It's good for reading code, but I almost never read code directly. Instead, I usually look over large parts of code at a time. I want code where I can get the structure at a glance and easily separate the parts that are specific to the current application from ones that aren't. With prose-like syntax, this is very difficult because everything is made of words. That programming language syntax you dismiss as line noise? It's actually the structure of the code, which makes it much *faster* to read!
There's a reason mathematicians user equations and diagrams so much. A single equation can replace literally pages of text, and you can have a pretty good idea of what's going on without having to look too closely at all the details. Think about an integral, for example: from the equation, you can easily see what sort of equation it is (trigonometric, polynomial, exponential...), what domain you're integrating over, what the limits are and, very importantly, that it *is* an integral rather than something completely different. All just from what the equation looks like, before you've had to expend much attention on it.
One way to think about it is that the notation factors out the repeated parts of an integral so that it's easy to visually separate from the "meat"--the function you're actually integrating. A good DSL uses symbols to do the same thing.
The main cost, of course, is that you have to learn the notation. But this is really a one-time cost; if you're going to be seeing a lot of integrals, it's more than worth doing, especially because there's so much shared structure between them. Similarly, it's worth doing for tests, for the same reasons. There's a lot of shared structure--just look at how many relatively long phrases got repeated even in the simple examples given here--and you want to look over that structure without actually reading it. Much easier with actual syntax than prose. In any real app, you will have hundreds of tests, and learning to deal with the "line noise" gets amortized over all of them, whereas the benefits (shorter code that's easier to scan) scale at least linearly.
So I think we should really avoid the faux-natural-language syntax as much as possible.
Have you tried AppleScript? I wouldn't say it's pleasant to use, but it's easy to read.
On Thursday, September 12, 2013, David Thomas wrote:I've long been interested in a scripting language designed to be spoken. Not interested enough to go about making it happen... but the idea is fascinating and possibly useful.On Thu, Sep 12, 2013 at 2:57 PM, Andreas Abel <andreas.abel@ifi.lmu.de> wrote:
+1
Cucumber seems to be great if you mainly want to read your code over the telephone, distribute it via national radio broadcast, or dictate it to your secretary or your voice recognition software. You can program thus without having to use you fingers. You can lie on your back on your sofa, close your eyes, and utter your programs...
We could have blind Haskell/Cucumber programming contests...
Tons of new possiblilities...
Strongly support this proposal. ;-)
Andreas
On 2013-09-10 22:57, Artyom Kazak wrote:
On Wed, 11 Sep 2013 00:20:26 +0400, Thiago Negri <evohunz@gmail.com> wrote:I hope these jokes do not cause people to be afraid to post new ideas.Agreed. I would also like to clarify that my message was much more a joke on the incomprehensibility of legal acts than on the original proposal. By the way, I am pretty impressed with this piece of Cucumber description/code: Scenario: Mislav creates a valid task with an upload When I go to the "Awesome Ruby Yahh" task list page of the "Ruby Rockstars" project When I follow "+ Add Task" And I fill in "Task title" with "Ohhh upload" And I follow "Attachment" When I attach the file "features/support/sample_files/dragon.jpg" to "upload_file" And I press "Add Task" And I wait for 1 second And I should see "Ohhh upload" as a task name I was much more sceptical when I had only seen the example in Niklas’s message. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Andreas Abel <>< Du bist der geliebte Mensch. Theoretical Computer Science, University of Munich http://www.tcs.informatik.uni-muenchen.de/~abel/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe