Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Defining DSL (Domain Specific Language) using Ruby

1,431 views

Published on

Slides by Jakub Naliwajek, Ruby on Rails developer at @netguru for SPARKcamp#5 meet-up.

Published in: Technology
  • Be the first to comment

Defining DSL (Domain Specific Language) using Ruby

  1. 1. DSLdomain-specific language @ SPARKcamp #5 (in Ruby)
  2. 2. jakub naliwajek
  3. 3. netguru.co
  4. 4. DSLdomain-specific language
  5. 5. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain.
  6. 6. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL
  7. 7. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL
  8. 8. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL
  9. 9. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL
  10. 10. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL
  11. 11. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL Simpler DSLs, particularly ones used by a single application, are sometimes informally called mini-languages.
  12. 12. DSLdomain-specific language A domain-specific language (DSL) is a computer language specialized to a particular application domain. •Perl •HTML •MATLAB •VHDL •SQL Simpler DSLs, particularly ones used by a single application, are sometimes informally called mini-languages INTERNAL.
  13. 13. LISP
  14. 14. LISP 1958
  15. 15. LISP 1958
  16. 16. “On Lisp” – Paul Graham Add “for” loop to LISP
  17. 17. RUBY
  18. 18. RUBYon rails
  19. 19. Rails “Migrations” DSL
  20. 20. RSpec DSL (testing framework)
  21. 21. DSLis not for COMPUTERS
  22. 22. describe == context == it (for computers)
  23. 23. PROBLEM
  24. 24. survey(name, &block)
  25. 25. survey(name, &block)
  26. 26. survey(name, &block)
  27. 27. survey(name, &block)
  28. 28. survey(name, &block) question(content, **params, &block)
  29. 29. survey(name, &block) question(content, **params, &block)
  30. 30. survey(name, &block) question(content, **params, &block)
  31. 31. survey(name, &block) question(content, **params, &block)
  32. 32. survey(name, &block) question(content, **params, &block)
  33. 33. survey(name, &block) question(content, **params, &block) answer(content)
  34. 34. survey(name, &block) question(content, **params, &block) answer(content)
  35. 35. WHAT HELPS?
  36. 36. META PROGRAMMING
  37. 37. BLOCKS
  38. 38. 0 20 40 60 80 no DSL DSL use uselearn learn How DIFFICULT?
  39. 39. 0 20 40 60 80 no DSL DSL use uselearn learn How DIFFICULT?
  40. 40. Which one is more readable? MiniTest RSpec
  41. 41. NOT ALWAYS COOL
  42. 42. developers […] who cannot survive without frameworks. – Adam Hawkins http://hawkins.io/2015/05/the-ruby-community-the-next-version/
  43. 43. simplicity over convenience = good for long-term
  44. 44. how many lines will that DSL save?
  45. 45. thoughtbot/factory_girl (kinda nice example)
  46. 46. thanks netguru.co/signup/sparkcamp

×