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
Misha Kozik
@mishadoff
developers domain
experts
developer domain
expert
Badass Guys
developers domain
experts
developer domain
expert
Badass Guys
developers domain
experts
“DSL-powered”

Badass Guys
not Turing Complete
SQL
select statement
DSL
SQL
DSL
query plan
SQL
algorithms
DSL
SQL
DSL
nested loop join
#1
#2
#1
Outer Inner
#3
#1
#2
#1
#3
#4
SQL
DSL
nested loop join
#1
#2
#1
Outer Inner
#3
#1
#2
#1
#3
#4
SQL
DSL
hash join
#1
#2
#1
Outer Inner (hashed)
#3
#1 #2 #3
#2
#1 #4
cd632f
0980eb
48b5d4
SQL
DSL
hash join
#1
#2
#1
Outer Inner (hashed)
#3
#1 #2 #3
#2
#1 #4
cd632f
0980eb
48b5d4
SQL
DSL
merge join
#106
#123
Outer (sorted) Inner (sorted)
#133
#106
#106
#117
#123
SQL
DSL
merge join
#106
#123
Outer (sorted) Inner (sorted)
#133
#106
#106
#117
#123
SQL
DSL
it’s just a join
SQL-on-Everything
LINGUAL
CASCADING
Hiccup
DSL
Hiccup
DSL
Hiccup
DSL
Hiccup
DSL
Lein
DSL
Binary Tree
Binary Tree
Internal DSL: Tree
Clojure way
head
left child right child
Internal DSL: Tree
Java way
External DSL: Tree
wow, such declarative
Do
not read
this code!
Domain Expert way
Generative DSL: Macros
excerpt macro from core.async
Instaparse
What if context-free grammars were 

as easy to use as regular expressions?
Context-Free Grammar
Context-Free Grammar
Context-Free Grammar
Context-Free Grammar
Context-Free Grammar
Balanced Parens
Example
Balanced Parens
Example
Clojure is a functional programming language better than java
English Grammar
Example
English Grammar
Example
Named Entity Recognition
Kiev is the capital of Ukraine
Entity:City Entity:Country
English Grammar
Example
Sentiment Analysis
SQL-2003 Grammar
Example
1300+ rules
http://savage.net.au/SQL/sql-2003-2.bnf
Integration Story
Grouping Metric
Grouping Metric
Grouping Metric
DSL to define formula
JVM
Why Clojure?
Lisp
Why Clojure?
Code is Data
Why Clojure?
Immutable
Why Clojure?
REPL
Why Clojure?
Practical
Why Clojure?
Community
Why Clojure?
Parser Development
insta/transform
Development
insta/transform
Development
Syntax Error
Exception Handling
Tree Tests
Testing
Expected
Actual
Starting Rule
Testing
Isolated Parsing
Performance Tests
Testing
clojure.test does not support timeouts, write by yourself
Ambiguity Tests
Testing
instaparse is able to handle ambiguity grammars
though, still good to know where we behave poorly
Use Cases Tests
Testing
Year over Year growth
Interface
Java Integration
clojure-maven-plugin
Java Integration
Demo Time
ANTLR
Alternatives
http://stackoverflow.com/questions/1931307/antlr-is-there-a-simple-example
parboiled
Alternatives
Lessons
Learned
Lessons Learned #1
Too Much Rules100+ rules, possible to reduce to 50
Lessons Learned #2
Lein and Maven
are not friends
Lessons Learned #3
Code Coverage
not integrated
Lessons Learned #4
Versioning
as a library
Lessons Learned #5
Evaluation
is not a parser responsibility
Questions?
DSL in Clojure
DSL in Clojure
DSL in Clojure
DSL in Clojure
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
Writing DSL in Clojure
Next
Upcoming SlideShare
Writing DSL in Clojure
Next
Download to read offline and view in fullscreen.

8

Share

DSL in Clojure

Download to read offline

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

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

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?
  • DamienMattei

    Apr. 11, 2020
  • FilippasSerepas

    Aug. 12, 2018
  • prahaladd

    Aug. 5, 2017
  • VictoriaUstymenko

    May. 22, 2017
  • gandhinath

    Dec. 11, 2016
  • bieli

    Jun. 21, 2016
  • TimGreene6

    Feb. 4, 2016
  • steven_liucx

    Jun. 1, 2015

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

Views

Total views

3,211

On Slideshare

0

From embeds

0

Number of embeds

1,016

Actions

Downloads

76

Shares

0

Comments

0

Likes

8

×