Tuesday, April 9, 2013

domain specific languages

The very first time I've hear about DSLs was after the Thoughtworks Boot Camp in March/2012.

I've read some articles after that, but I just really understood it after I started using Capybara.

Capybara is a framework for testing user interaction in rails applications.

A Capybara test will have statements like these:

visit "/"
click_link "My account"

fill_in "Your email", with: "john@example.org"

fill_in "Your password", with: "test"
click_button "Login"

Those statements are part of the Capybara framework. They are part of a language that was created specifically for the purpose of testing web applications. This is the Capybara DSL. A small language created for this specific purpose, or domain.

I've read that DSLs are not a new topic, but with the popularity of dynamic languages like Ruby, they are easy to create and incredibly useful. I'll try to create my own in the near future.

No comments:

Post a Comment