For the record, this is another post I expect to get flamed for…throw another cuke on the barbie, I suppose…

If you’re unfamiliar with Cucumber, the description on the main page is “behavior driven development with elegance and joy”. If that wasn’t clear enough, typically, you use Cucumber to develop tests and perform actions based on those tests. In that, it’s no different than a bunch of other functional test suites. The feather in Cucumber’s hat is that it is supposedly “natural language”.

What? AI? Not quite. What you actually end up doing is writing code that looks like this:

Scenario Outline: Add two numbers

Given I have entered <input_1> into the calculator

And I have entered <input_2> into the calculator

When I press <button>

Then the result should be <output> on the screen

I could write a long diatribe about why that sucks, but it would be much easier for me to cut and paste the long diatribe that I already wrote on the Reddit thread about Cucumber-Nagios here:

I’ve looked into Cucumber, and to be really, really honest, it seems like it’s a little heavy handed. Great, natural language is like English, so when we read it, we understand immediately, but I think I would hate to write it. It seems stilted and counterintuitive. Plus, it’s not really natural language. Feature: www.google.com

It should be up Who talks like that? It’s all syntax, but while it’s being syntax, it might as well be a little more tightly designed. There are enough synonyms and valid phrasologies in the english language that: It should be up reads the same to me as It should be running or Make sure it is running or Ensure it is up Don’t even get me started with Scenario: Clicking on the Videos link

When I go to http://www.google.com

And I follow “Videos”

Then I should see “Google Videos” Reading something that’s supposed to look like english tells me what it does, it doesn’t make my brain parse code. I look at “Ensure it is up” and think, “yeah, I see that this service needs to be up”, but I don’t think, “the syntax for that statement is wrong”. There are few, if any, synonyms in “normal” computer programming. if (! isRunning(servicename) ) { is pretty specific. Sure, it doesn’t do all of the nifty implied actions of “It should be up”, but that’s what the rest of the statement is for. I just find it counter-intuitive, which is exactly opposite of its goal.

(minor phrase changes edited in for blogification)

That’s pretty much how I feel. I can appreciate some of the very cool things about the language (for example, if Spanish is your first language, you can write in Spanish…or Mandarin, for that matter…), but what I perceive to be a bad form outweighs a decent function.

I don’t want to feel like I’m beating up on Cucumber here. It’s really natural language programming that I’m against. Here’s an example from the wiki page I just linked to:

If U_ is ‘smc01-control’, then do the following. Define surface weights Alpha as “[0.5, 0.5]”. Initialise matrix Phi as a ‘unit matrix’. Define J as the ‘inertia matrix’ of Spc01. Compute matrix J2 as the inverse of J . Compute position velocity error Ve and angular velocity error Oe from dynamical state X, guidance reference Xnow . Define the joint sliding surface G2 from the position velocity error Ve and angular velocity error Oe using the surface weights Alpha. Compute the smoothed sign function SG2 from the joint sliding surface G2 with sign threshold 0.01. Compute special dynamical force F from dynamical state X and surface weights Alpha. Compute control torque T and control force U from matrix J2, surface weights Alpha, special dynamical force F , smoothed sign function SG2. Finish conditional actions.

If you really, honestly, in your heart of hearts, think that’s better than the equivalent C, perl, python, or ruby, then that’s fine, but I’m definitely not in that group.

Please comment to tell me how wrong I am.