dsls in javascript - · pdf file•foundations of ajax & pro ajax and java ... 51....
TRANSCRIPT
![Page 1: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/1.jpg)
DSLs in JavaScriptNathaniel T. Schutta
1
![Page 2: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/2.jpg)
Who am I?
• Nathaniel T. Schuttahttp://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
![Page 3: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/3.jpg)
The Plan• DSLs?
• JavaScript? Seriously?
• Examples
• Lessons Learned
3
![Page 4: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/4.jpg)
DS what now?
4
![Page 5: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/5.jpg)
Domain Specific Language.
5
![Page 6: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/6.jpg)
Every domain has its own language.
6
![Page 7: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/7.jpg)
“Part of the benefit of being "into" something is having an insider lexicon.”
Kathy SierraCreating Passionate Users
http://headrush.typepad.com/creating_passionate_users/2006/11/why_web_20_is_m.html
7
![Page 8: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/8.jpg)
Three quarter, knock down, soft cut.
8
![Page 9: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/9.jpg)
Scattered, smothered, covered.
9
![Page 10: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/10.jpg)
Large skim mocha, no whip no froth.
10
![Page 11: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/11.jpg)
Not general purpose.
11
![Page 12: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/12.jpg)
Simpler, more limited.
12
![Page 13: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/13.jpg)
Expressive.
13
![Page 14: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/14.jpg)
Terse.
14
![Page 15: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/15.jpg)
$$('.header').each(function(el) {el.observe("click", toggleSection)});
15
![Page 16: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/16.jpg)
Not a new idea.
16
![Page 17: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/17.jpg)
Unix.
17
![Page 18: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/18.jpg)
Little languages.
18
![Page 19: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/19.jpg)
Lisp.
19
![Page 20: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/20.jpg)
Build the language up...
20
![Page 21: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/21.jpg)
Lots of attention today.
21
![Page 22: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/22.jpg)
Rails!
22
![Page 23: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/23.jpg)
Ruby is very hospitable.
23
![Page 24: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/24.jpg)
So are other languages ;)
24
![Page 25: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/25.jpg)
Internal vs. External.
25
![Page 26: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/26.jpg)
Internal.
26
![Page 27: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/27.jpg)
Within an existing language.
27
![Page 28: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/28.jpg)
More approachable.
28
![Page 29: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/29.jpg)
Simpler.
29
![Page 30: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/30.jpg)
No grammars, parsing, etc.
30
![Page 31: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/31.jpg)
Constrained by host language.
31
![Page 32: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/32.jpg)
Flexible syntax helps!
32
![Page 33: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/33.jpg)
Ruby ;)
33
![Page 34: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/34.jpg)
Fluent interface.
34
![Page 35: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/35.jpg)
Embedded DSLs.
35
![Page 36: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/36.jpg)
External.
36
![Page 37: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/37.jpg)
Create your own language.
37
![Page 38: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/38.jpg)
Grammars.
38
![Page 39: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/39.jpg)
Need to parse.
39
![Page 40: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/40.jpg)
ANTLR, yacc, JavaCC.
40
![Page 41: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/41.jpg)
Harder.
41
![Page 42: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/42.jpg)
More flexibility.
42
![Page 43: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/43.jpg)
Language workbenches.
43
![Page 44: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/44.jpg)
Tools for creating new languages.
44
![Page 45: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/45.jpg)
Internal are more common today.
45
![Page 46: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/46.jpg)
Language workbenches - shift afoot?
46
![Page 47: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/47.jpg)
http://martinfowler.com/articles/languageWorkbench.html
http://martinfowler.com/articles/mpsAgree.html
47
![Page 48: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/48.jpg)
Meta Programming System.
http://www.jetbrains.com/mps/
48
![Page 49: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/49.jpg)
Intentional Programming - Charles Simonyi.
http://intentsoft.com/http://www.technologyreview.com/Infotech/18047/?a=f
49
![Page 50: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/50.jpg)
Oslo.
http://msdn.microsoft.com/en-us/oslo/default.aspx
50
![Page 51: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/51.jpg)
Xtext.
http://wiki.eclipse.org/Xtext
51
![Page 52: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/52.jpg)
Why are we seeing DSLs?
52
![Page 53: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/53.jpg)
Easier to read.
53
![Page 54: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/54.jpg)
Closer to the business.
54
![Page 55: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/55.jpg)
Less friction, fewer translations.
55
![Page 56: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/56.jpg)
Biz can review...
56
![Page 57: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/57.jpg)
“Yesterday, I did a code review. With a CEO... Together, we found three improvements, and a couple of outright bugs.”
Bruce TateCanaries in the Coal Mine
http://blog.rapidred.com/articles/2006/08/30/canaries-in-the-coal-mine57
![Page 58: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/58.jpg)
Don’t expect them to write it though!
58
![Page 59: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/59.jpg)
Will we all write DSLs?
59
![Page 60: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/60.jpg)
No.
60
![Page 61: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/61.jpg)
Doesn’t mean we can’t use them.
61
![Page 62: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/62.jpg)
General advice on building a DSL:
62
![Page 63: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/63.jpg)
Write it as you’d like it to be...
63
![Page 64: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/64.jpg)
Even on a napkin!
64
![Page 65: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/65.jpg)
Use valid syntax.
65
![Page 66: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/66.jpg)
Iterate, iterate, iterate.
66
![Page 67: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/67.jpg)
Work on the implementation.
67
![Page 68: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/68.jpg)
http://martinfowler.com/bliki/DslQandA.html
http://memeagora.blogspot.com/2007/11/ruby-matters-frameworks-dsls-and.html
http://martinfowler.com/dslwip/
http://weblog.jamisbuck.org/2006/4/20/writing-domain-specific-languages
68
![Page 69: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/69.jpg)
Not a toy!
69
![Page 70: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/70.jpg)
JavaScript has been around for a while.
70
![Page 71: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/71.jpg)
Many dismissed it as “toy for designers.”
71
![Page 72: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/72.jpg)
It’s not the 90s anymore.
72
![Page 73: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/73.jpg)
We have tools!
73
![Page 74: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/74.jpg)
Developers care again!
74
![Page 75: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/75.jpg)
Ajax.
75
![Page 76: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/76.jpg)
Suffers from the “EJB issue.”
76
![Page 77: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/77.jpg)
Powerful language.
77
![Page 78: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/78.jpg)
“The Next Big Language”
http://steve-yegge.blogspot.com/2007/02/next-big-language.html
78
![Page 79: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/79.jpg)
Runs on lots of platforms - including the JVM.
79
![Page 80: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/80.jpg)
Ruby like?
80
![Page 81: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/81.jpg)
“Rhino on Rails”
http://steve-yegge.blogspot.com/2007/06/rhino-on-rails.html
81
![Page 82: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/82.jpg)
Orto - JVM written in JavaScript.
http://ejohn.org/blog/running-java-in-javascript/
82
![Page 83: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/83.jpg)
JS-909.
http://www.themaninblue.com/experiment/JS-909/
83
![Page 84: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/84.jpg)
84
![Page 85: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/85.jpg)
JSSpec.
85
![Page 86: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/86.jpg)
JavaScript testing DSL.
86
![Page 87: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/87.jpg)
JSSpec? Really?
87
![Page 88: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/88.jpg)
/** * Domain Specific Languages */JSSpec.DSL = {};
88
![Page 89: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/89.jpg)
BDD for JS.
89
![Page 90: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/90.jpg)
Like RSpec.
90
![Page 91: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/91.jpg)
Not quite as elegant.
91
![Page 92: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/92.jpg)
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
![Page 93: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/93.jpg)
value_of?
93
![Page 94: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/94.jpg)
"Hello".should_be("Hello");
94
![Page 95: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/95.jpg)
Sorry.
95
![Page 96: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/96.jpg)
No method missing.
96
![Page 97: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/97.jpg)
We’d need to modify Object’s prototype.
97
![Page 98: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/98.jpg)
Generally a no-no.
98
![Page 99: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/99.jpg)
Though it’s been done.
http://json.org/json.js
99
![Page 100: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/100.jpg)
Null, undefined objects.
100
![Page 101: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/101.jpg)
Design choice - consistency.
101
![Page 102: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/102.jpg)
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); }})
102
![Page 103: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/103.jpg)
describe - global defined in JSSpec.js.
103
![Page 104: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/104.jpg)
Creates a new JSSpec.Spec()...
104
![Page 105: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/105.jpg)
And adds it to an array of specs.
105
![Page 106: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/106.jpg)
value_of - global defined in JSSpec.js.
106
![Page 107: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/107.jpg)
value_of - converts parm to JSSpec.DSL.Subject
107
![Page 108: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/108.jpg)
Handles arbitrary objects.
108
![Page 109: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/109.jpg)
JSSpec.DSL.Subject contains should_*.
109
![Page 110: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/110.jpg)
Added to prototype.
110
![Page 111: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/111.jpg)
JSSpec.DSL.Subject.prototype.should_be = function(expected) { var matcher = JSSpec.EqualityMatcher.createInstance(expected,this.target); if(!matcher.matches()) { JSSpec._assertionFailure = {message:matcher.explain()}; throw JSSpec._assertionFailure; }}
111
![Page 112: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/112.jpg)
this.target?
112
![Page 113: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/113.jpg)
JSSpec.DSL.Subject = function(target) { this.target = target;};
113
![Page 114: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/114.jpg)
this in JS is...interesting.
114
![Page 115: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/115.jpg)
Why is everything JSSpec.Foo?
115
![Page 116: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/116.jpg)
JS lacks packages or namespaces.
116
![Page 117: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/117.jpg)
Keeps it clean.
117
![Page 118: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/118.jpg)
Doesn’t collide...unless you have JSSpec too!
118
![Page 119: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/119.jpg)
Not just a DSL of course.
119
![Page 120: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/120.jpg)
Defines a number of matchers.
120
![Page 121: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/121.jpg)
Also the runner and the logger.
121
![Page 122: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/122.jpg)
122
![Page 123: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/123.jpg)
Some CSS to make it pretty.
123
![Page 124: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/124.jpg)
~1500 lines of code.
124
![Page 125: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/125.jpg)
Clean code.
125
![Page 126: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/126.jpg)
Why would you use it?
126
![Page 127: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/127.jpg)
Easier to read.
127
![Page 128: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/128.jpg)
function testStringConcat() { assertEquals("Hello World", "Hello " + "World");} function testNumericConcat() { assertEquals(4, 2 + 2);}
128
![Page 129: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/129.jpg)
var oTestCase = new YAHOO.tool.TestCase({ name: "Plus operation", testStringConcat : function () { YAHOO.util.Assert.areEqual("Hello World", "Hello " + "World", "Should be 'Hello World'"); },
testNumericConcat : function () { YAHOO.util.Assert.areEqual(4, 2 + 2, "2 + 2 should be 4"); }});
129
![Page 130: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/130.jpg)
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); }})
130
![Page 131: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/131.jpg)
Better? Worse?
131
![Page 132: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/132.jpg)
What would you rather read 6 months later?
132
![Page 133: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/133.jpg)
http://jania.pe.kr/aw/moin.cgi/JSSpec
133
![Page 134: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/134.jpg)
ActiveRecord.js
134
![Page 135: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/135.jpg)
JavaScript ORM.
135
![Page 136: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/136.jpg)
Seriously?
136
![Page 137: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/137.jpg)
Yep.
137
![Page 138: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/138.jpg)
Let’s you use a DB from JavaScript.
138
![Page 139: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/139.jpg)
Client or server ;)
139
![Page 140: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/140.jpg)
Gears, AIR, W3C HTML5 SQL spec.
140
![Page 141: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/141.jpg)
In-memory option too.
141
![Page 142: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/142.jpg)
Some free finder methods.
142
![Page 143: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/143.jpg)
Base find method.
143
![Page 144: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/144.jpg)
Migrations.
144
![Page 145: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/145.jpg)
ActiveRecord.Migrations.migrations = { 1: { up: function(schema){ schema.createTable('one',{ a: '', b: { type: 'TEXT', value: 'default' } }); }, down: function(schema){ schema.dropTable('one'); } }};
145
![Page 146: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/146.jpg)
Validations.
146
![Page 147: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/147.jpg)
User.validatesPresenceOf('password');
147
![Page 148: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/148.jpg)
More to come...
148
![Page 149: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/149.jpg)
Supports basic relationships.
149
![Page 150: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/150.jpg)
Early stages...
150
![Page 151: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/151.jpg)
On GitHub, contribute!
151
![Page 152: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/152.jpg)
http://activerecordjs.org/
152
![Page 153: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/153.jpg)
Objective-J
153
![Page 154: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/154.jpg)
Objective-C...for JS.
154
![Page 155: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/155.jpg)
JavaScript superset.
155
![Page 156: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/156.jpg)
Cheating...kind of.
156
![Page 157: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/157.jpg)
Native and Objective-J classes.
157
![Page 158: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/158.jpg)
Allows for instance methods.
158
![Page 159: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/159.jpg)
Parameters are separated by colons.
159
![Page 160: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/160.jpg)
- (void)setJobTitle: (CPString)aJobTitle company: (CPString)aCompany
160
![Page 161: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/161.jpg)
Bracket notation for method calls.
161
![Page 162: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/162.jpg)
[myPerson setJobTitle: "Founder" company: "280 North"];
162
![Page 163: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/163.jpg)
Does allow for method_missing.
http://cappuccino.org/discuss/2008/12/08/on-leaky-abstractions-and-objective-j/
163
![Page 164: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/164.jpg)
http://cappuccino.org/
164
![Page 165: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/165.jpg)
Coffee DSL.
165
![Page 166: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/166.jpg)
Lessons learned.
166
![Page 167: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/167.jpg)
Viable option.
167
![Page 168: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/168.jpg)
Widely used language.
168
![Page 169: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/169.jpg)
Not necessarily easy.
169
![Page 170: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/170.jpg)
Syntax isn’t as flexible.
170
![Page 171: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/171.jpg)
Lots of reserved words.
171
![Page 172: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/172.jpg)
Freakn ;
172
![Page 173: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/173.jpg)
Hello prototype!
173
![Page 174: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/174.jpg)
Verbs as first class citizens.
174
![Page 175: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/175.jpg)
Object literals.
175
![Page 176: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/176.jpg)
DSL vs. named parameters vs. constructor parms.
176
![Page 177: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/177.jpg)
new Ajax.Request('/DesigningForAjax/validate', { asynchronous: true, method: "get", parameters: {zip: $F('zip'), city: $F('city'), state: $F('state')}, onComplete: function(request) { showResults(request.responseText); }})
177
![Page 178: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/178.jpg)
Fail fast vs. fail silent.
178
![Page 179: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/179.jpg)
Method chaining is trivial.
179
![Page 180: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/180.jpg)
Context can be a challenge.
180
![Page 181: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/181.jpg)
Documentation key.
181
![Page 182: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/182.jpg)
PDoc, YUI Doc.
https://www.ohloh.net/p/pdoc_org
http://developer.yahoo.com/yui/yuidoc/
182
![Page 183: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/183.jpg)
JavaScript isn’t a toy.
183
![Page 184: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/184.jpg)
Not quite as flexible.
184
![Page 185: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/185.jpg)
Plenty of metaprogramming goodness!
185
![Page 186: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/186.jpg)
Questions?!?
186
![Page 187: DSLs in JavaScript - · PDF file•Foundations of Ajax & Pro Ajax and Java ... 51. Why are we seeing DSLs? 52. Easier to read. 53](https://reader031.vdocuments.net/reader031/viewer/2022022500/5aa2144b7f8b9a84398c9377/html5/thumbnails/187.jpg)
Thanks!Please complete your surveys.
187