RSpec & COBOL 4

Posted by pratik
on Saturday, March 29

It’s a pretty saturday morning and I am in very jolly mood. Thought I’d share some joy ;-)

In 1959, there was COBOL

1
2
3
4
5
6
7
8
9
10
11
ADD YEARS TO AGE.
MULTIPLY PRICE BY QUANTITY GIVING COST.
SUBTRACT DISCOUNT FROM COST GIVING FINAL-COST.
MULTIPLY B BY B GIVING B-SQUARED.  
MULTIPLY 4 BY A GIVING FOUR-A.  
MULTIPLY FOUR-A BY C GIVING FOUR-A-C.  
SUBTRACT FOUR-A-C FROM B-SQUARED GIVING RESULT-1.  
COMPUTE RESULT-2 = RESULT-1 ** .5.
SUBTRACT B FROM RESULT-2 GIVING NUMERATOR.
MULTIPLY 2 BY A GIVING DENOMINATOR.
DIVIDE NUMERATOR BY DENOMINATOR GIVING X.

And almost 50 years later, it resurrected !

1
2
3
4
5
6
Scenario: savings account has insufficient funds
Given my savings account balance is $50
And my checking account balance is $10
When I transfer $60 from savings to checking
Then my savings account balance should be $50
And my checking account balance should be $10

I know history repeats itself. I just wish it wouldn’t have done it in English !

Comments

Leave a response

  1. RSLMarch 29, 2008 @ 01:08 PM

    Heh. I saw this one coming when I saw the InfoQ link to PragDave’s article. I’m just curious if you came up with the COBOL analogy on yr own or just riffing on Dafydd Rees’ comment: http://pragdave.blogs.pragprog.com/pragdave/2008/03/the-language-in.html#comment-106672576, which predates this post by over two weeks. Zing! [Wink.]

  2. Daniel TennerMarch 29, 2008 @ 02:16 PM

    Har har har ;-) Very funny.

    The big difference between the two would, of course, be that the second one isn’t a programming language, it can be set up to read exactly the way you want it – so rather than constraining you to an archaic generic syntax, it allows you to create the syntax that’s best suited to integration-testing your application.

    But it’s not like this post is serious or anything… ;-)

    Daniel

  3. leethalMarch 29, 2008 @ 07:25 PM

    CodeRay doesn’t have COBOL syntax highlighting??

  4. Joseph James FrantzJune 30, 2008 @ 10:31 PM

    Actually the COBOL code comes straight from Wikipedia. The first three lines are good code (I know I coded them). The remaining lines are code that no proper COBOL coder would write. A var should not be named A or B, and the results of a calculation should never be named Result-1..and so on.

Comment