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.

DSL in Clojure

3,013 views

Published on

Talk about DSL, How to write DSL in Clojure, How to use Instaparse (simplest library for parsing grammars) and how we use Clojure and Instaparse in Zoomdata

Published in: Software
  • Be the first to comment

DSL in Clojure

  1. 1. DSL in Clojure Misha Kozik @mishadoff
  2. 2. developers domain experts
  3. 3. developer domain expert Badass Guys developers domain experts
  4. 4. developer domain expert Badass Guys developers domain experts “DSL-powered”
 Badass Guys
  5. 5. not Turing Complete
  6. 6. SQL select statement DSL
  7. 7. SQL DSL query plan
  8. 8. SQL algorithms DSL
  9. 9. SQL DSL nested loop join #1 #2 #1 Outer Inner #3 #1 #2 #1 #3 #4
  10. 10. SQL DSL nested loop join #1 #2 #1 Outer Inner #3 #1 #2 #1 #3 #4
  11. 11. SQL DSL hash join #1 #2 #1 Outer Inner (hashed) #3 #1 #2 #3 #2 #1 #4 cd632f 0980eb 48b5d4
  12. 12. SQL DSL hash join #1 #2 #1 Outer Inner (hashed) #3 #1 #2 #3 #2 #1 #4 cd632f 0980eb 48b5d4
  13. 13. SQL DSL merge join #106 #123 Outer (sorted) Inner (sorted) #133 #106 #106 #117 #123
  14. 14. SQL DSL merge join #106 #123 Outer (sorted) Inner (sorted) #133 #106 #106 #117 #123
  15. 15. SQL DSL it’s just a join
  16. 16. SQL-on-Everything LINGUAL CASCADING
  17. 17. Hiccup DSL
  18. 18. Hiccup DSL
  19. 19. Hiccup DSL
  20. 20. Hiccup DSL
  21. 21. Lein DSL
  22. 22. Binary Tree
  23. 23. Binary Tree
  24. 24. Internal DSL: Tree Clojure way head left child right child
  25. 25. Internal DSL: Tree Java way
  26. 26. External DSL: Tree wow, such declarative Do not read this code! Domain Expert way
  27. 27. Generative DSL: Macros excerpt macro from core.async
  28. 28. Instaparse What if context-free grammars were 
 as easy to use as regular expressions?
  29. 29. Context-Free Grammar
  30. 30. Context-Free Grammar
  31. 31. Context-Free Grammar
  32. 32. Context-Free Grammar
  33. 33. Context-Free Grammar
  34. 34. Balanced Parens Example
  35. 35. Balanced Parens Example
  36. 36. Clojure is a functional programming language better than java English Grammar Example
  37. 37. English Grammar Example Named Entity Recognition Kiev is the capital of Ukraine Entity:City Entity:Country
  38. 38. English Grammar Example Sentiment Analysis
  39. 39. SQL-2003 Grammar Example 1300+ rules http://savage.net.au/SQL/sql-2003-2.bnf
  40. 40. Integration Story
  41. 41. Grouping Metric
  42. 42. Grouping Metric
  43. 43. Grouping Metric DSL to define formula
  44. 44. JVM Why Clojure?
  45. 45. Lisp Why Clojure?
  46. 46. Code is Data Why Clojure?
  47. 47. Immutable Why Clojure?
  48. 48. REPL Why Clojure?
  49. 49. Practical Why Clojure?
  50. 50. Community Why Clojure?
  51. 51. Parser Development
  52. 52. insta/transform Development
  53. 53. insta/transform Development
  54. 54. Syntax Error Exception Handling
  55. 55. Tree Tests Testing Expected Actual
  56. 56. Starting Rule Testing Isolated Parsing
  57. 57. Performance Tests Testing clojure.test does not support timeouts, write by yourself
  58. 58. Ambiguity Tests Testing instaparse is able to handle ambiguity grammars though, still good to know where we behave poorly
  59. 59. Use Cases Tests Testing Year over Year growth
  60. 60. Interface Java Integration
  61. 61. clojure-maven-plugin Java Integration
  62. 62. Demo Time
  63. 63. ANTLR Alternatives http://stackoverflow.com/questions/1931307/antlr-is-there-a-simple-example
  64. 64. parboiled Alternatives
  65. 65. Lessons Learned
  66. 66. Lessons Learned #1 Too Much Rules100+ rules, possible to reduce to 50
  67. 67. Lessons Learned #2 Lein and Maven are not friends
  68. 68. Lessons Learned #3 Code Coverage not integrated
  69. 69. Lessons Learned #4 Versioning as a library
  70. 70. Lessons Learned #5 Evaluation is not a parser responsibility
  71. 71. Questions?

×