Domain Specific Language In Ruby
After Object Oriented Programming leveraged the power of coders and programmers to do more ; a bunch of programmers started wondering about exploring the boundaries more where they can define their own language on top a language which does the same stuff with much higher flexibility which is when the term – domain-specific languages (abbreviated DSL) came up.
Assume you are writing a Coffee Placing Order Machine in Ruby and lets see how you would have liked to express it.
CoffeeMachine.orders do |place_order| place_order.mega.coffee place_order.strong.expresso place_order.extraLarge.cappuccino.sugarless.halfCup end
Wow, I bet if you could express that way to write a program you would have realized how powerful it would be! Why DSLs?
- Expressive (True Nature of High Level Language)
- DRY (Don’t Repeat Yourself)
- Lesser Code More Flexibility
- Scalability in terms of Functionality
- Highly Modular