When I look at the recent advancements in Behaviour Driven Development in Rails, I tend to think that programming has really evolved. Not in terms of advanced data structures and superior algorithms, but as a focus shift of intention.
Earlier the focus was the machine. Days are gone when we thought so much about saving an extra byte, trading code simplicity for speed. A compromise here, a saving there, ad infinitum.
The focus has definitely shifted to human understandability. Beauty of code now lies in its simplicity (some folks would argue that it always did, and they're right, but its more so apparent now).
First it was Ruby, then Rails, and now BDD frameworks like rSpec and Cucumber prove the point. Just have a look at these executable code examples.
Rubyanimals = [ "Tiger", "Cow", "Python", "Horse" ]
animals.each do |animal|
puts animal + "is cool!"
end
#=> Tiger is cool! Cow is cool! ...
Does a C for loop or C++ iterator look more elegant?
Railsclass Project
belongs_to :portfolio
has_one :project_manager
has_many :milestones
has_and_belongs_to_many :categories
end
Code that you can just read, isn't it?
rSpeclambda {
employee.develop_great_new_social_networking_app
}.should change(employee, :title).from("Mail Clerk").to("CEO")
Yes, that's a real executable example.
And now, CucumberScenario: Search by topic
Given there are 240 courses where neither has the topic "biology"
And there are 3 courses A,B,C that each have "biology" as one of the topics
When I search for "biology"
Then I should see a the following courses:
| title |
| A |
| B |
| C |
More beautiful, more succinct, more concise. That's what programming has evolved to be.