dsls in javascript
play

DSLs in JavaScript Nathaniel T. Schutta 1 Who am I? Nathaniel T. - PowerPoint PPT Presentation

DSLs in JavaScript Nathaniel T. Schutta 1 Who am I? Nathaniel T. Schutta http://www.ntschutta.com/jat/ Foundations of Ajax & Pro Ajax and Java Frameworks UI guy Author, speaker, teacher More than a couple of web apps 2


  1. DSLs in JavaScript Nathaniel T. Schutta 1

  2. Who am I? • Nathaniel T. Schutta http://www.ntschutta.com/jat/ • Foundations of Ajax & Pro Ajax and Java Frameworks • UI guy • Author, speaker, teacher • More than a couple of web apps 2

  3. The Plan • DSLs? • JavaScript? Seriously? • Examples • Lessons Learned 3

  4. DS what now? 4

  5. Domain Specific Language. 5

  6. Every domain has its own language. 6

  7. “Part of the benefit of being "into" something is having an insider lexicon.” Kathy Sierra Creating Passionate Users http://headrush.typepad.com/creating_passionate_users/2006/11/why_web_20_is_m.html 7

  8. Three quarter, knock down, soft cut. 8

  9. Scattered, smothered, covered. 9

  10. Large skim mocha, no whip no froth. 10

  11. Not general purpose. 11

  12. Simpler, more limited. 12

  13. Expressive. 13

  14. Terse. 14

  15. $$('.header').each(function(el) {el.observe("click", toggleSection)}); 15

  16. Not a new idea. 16

  17. Unix. 17

  18. Little languages. 18

  19. Lisp. 19

  20. Build the language up... 20

  21. Lots of attention today. 21

  22. Rails! 22

  23. Ruby is very hospitable. 23

  24. So are other languages ;) 24

  25. Internal vs. External. 25

  26. Internal. 26

  27. Within an existing language. 27

  28. More approachable. 28

  29. Simpler. 29

  30. No grammars, parsing, etc. 30

  31. Constrained by host language. 31

  32. Flexible syntax helps! 32

  33. Ruby ;) 33

  34. Fluent interface. 34

  35. Embedded DSLs. 35

  36. External. 36

  37. Create your own language. 37

  38. Grammars. 38

  39. Need to parse. 39

  40. ANTLR, yacc, JavaCC. 40

  41. Harder. 41

  42. More flexibility. 42

  43. Language workbenches. 43

  44. Tools for creating new languages. 44

  45. Internal are more common today. 45

  46. Language workbenches - shift afoot? 46

  47. http://martinfowler.com/articles/mpsAgree.html http://martinfowler.com/articles/languageWorkbench.html 47

  48. Meta Programming System. http://www.jetbrains.com/mps/ 48

  49. Intentional Programming - Charles Simonyi. http://intentsoft.com/ http://www.technologyreview.com/Infotech/18047/?a=f 49

  50. Oslo. http://msdn.microsoft.com/en-us/oslo/default.aspx 50

  51. Xtext. http://wiki.eclipse.org/Xtext 51

  52. Why are we seeing DSLs? 52

  53. Easier to read. 53

  54. Closer to the business. 54

  55. Less friction, fewer translations. 55

  56. Biz can review... 56

  57. “Yesterday, I did a code review. With a CEO... Together, we found three improvements, and a couple of outright bugs.” Bruce Tate Canaries in the Coal Mine http://blog.rapidred.com/articles/2006/08/30/canaries-in-the-coal-mine 57

  58. Don’t expect them to write it though! 58

  59. Will we all write DSLs? 59

  60. No. 60

  61. Doesn’t mean we can’t use them. 61

  62. General advice on building a DSL: 62

  63. Write it as you’d like it to be... 63

  64. Even on a napkin! 64

  65. Use valid syntax. 65

  66. Iterate, iterate, iterate. 66

  67. Work on the implementation. 67

  68. http://martinfowler.com/dslwip/ http://weblog.jamisbuck.org/2006/4/20/ writing-domain-specific-languages http://memeagora.blogspot.com/2007/11/ ruby-matters-frameworks-dsls-and.html http://martinfowler.com/bliki/DslQandA.html 68

  69. Not a toy! 69

  70. JavaScript has been around for a while. 70

  71. Many dismissed it as “toy for designers.” 71

  72. It’s not the 90s anymore. 72

  73. We have tools! 73

  74. Developers care again! 74

  75. Ajax. 75

  76. Suffers from the “EJB issue.” 76

  77. Powerful language. 77

  78. “The Next Big Language” http://steve-yegge.blogspot.com/ 2007/02/next-big-language.html 78

  79. Runs on lots of platforms - including the JVM. 79

  80. Ruby like? 80

  81. “Rhino on Rails” http://steve-yegge.blogspot.com/ 2007/06/rhino-on-rails.html 81

  82. Orto - JVM written in JavaScript. http://ejohn.org/blog/running-java-in-javascript/ 82

  83. JS-909. http://www.themaninblue.com/experiment/JS-909/ 83

  84. 84

  85. JSSpec. 85

  86. JavaScript testing DSL. 86

  87. JSSpec? Really? 87

  88. /** * Domain Specific Languages */ JSSpec.DSL = {}; 88

  89. BDD for JS. 89

  90. Like RSpec. 90

  91. Not quite as elegant. 91

  92. describe('Plus operation', { 'should concatenate two strings': function() { value_of("Hello " + "World").should_be("Hello World"); }, 'should add two numbers': function() { value_of(2 + 2).should_be(4); } }) 92

  93. value_of? 93

  94. "Hello".should_be("Hello"); 94

  95. Sorry. 95

  96. No method missing. 96

  97. We’d need to modify Object’s prototype. 97

  98. Generally a no-no. 98

  99. Though it’s been done. http://json.org/json.js 99

  100. Null, undefined objects. 100

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend