Domain Specific Language Dr. Weerasak Witthawaskul “ Mr. SweetCorn” (weerasak@hotmail.com) Narisa.com’s NJUG Meeting #3 22...
Who am I? <ul><li>oop guy (Pantip)  </li></ul><ul><li>SweetCorn (narisa.com) </li></ul><ul><li>Wee (weerasak.com) </li></u...
Graduate Life
Programming Paradigm Shifts <ul><li>Domain Specific Languages </li></ul><ul><li>Generative Programming </li></ul><ul><li>M...
What is DSL? <ul><li>“ วันนี้มีประชุมนริสาดอทคอม ” </li></ul><ul><li>ภาษาไทย </li></ul><ul><li>“ ทำตัวติสตดีนักถูกแมวีนมาย...
What is DSL? <ul><li>Mini-language to solve specific “domain” problem </li></ul><ul><li>Why is it important? </li></ul><ul...
Mini Game <ul><li>“ What languages are they?” </li></ul><ul><li>Are they languages for specific domains? </li></ul><ul><li...
What Languages are they? <ul><li>#include <stdio.h>  </li></ul><ul><li>main() {  </li></ul><ul><li>printf(&quot;Hello Worl...
What Languages are they? <ul><li>.MODEL tiny </li></ul><ul><li>.CODE  </li></ul><ul><li>ORG 100h  </li></ul><ul><li>HELLO ...
What Languages are they? <ul><li><?php  </li></ul><ul><li>echo &quot;Hello World
&quot;;  </li></ul><ul><li>?>  </li></ul>...
What Languages are they? <ul><li>public class HelloWorld {  </li></ul><ul><li>public static void main(String[] args) </li>...
What Languages are they? <ul><li>PROGRAM HelloWorld;  </li></ul><ul><li>BEGIN  </li></ul><ul><li>WRITELN('Hello World');  ...
What Languages are they? <ul><li>print &quot;Hello World&quot;  </li></ul><ul><li>PRINT “Hello World” </li></ul><ul><li>Ba...
What Languages are they? <ul><li>SELECT 'Hello World'  </li></ul><ul><li>SQL </li></ul>
What Languages are they? <ul><li>BEGIN  </li></ul><ul><li>DBMS_OUTPUT.put_line('Hello World'); </li></ul><ul><li>END;   </...
What Languages are they? <ul><li>Report Hello_World. </li></ul><ul><li>Write: &quot;Hello World&quot;. </li></ul>ABAP
What Languages are they? <ul><li>io:fwrite(&quot;Hello World~n&quot;).  </li></ul>Erlang
What Languages are they? <ul><li>IDENTIFICATION DIVISION.  </li></ul><ul><li>PROGRAM-ID. HelloWorld.  </li></ul><ul><li>AU...
What Languages are they? <ul><li>% Hello World  </li></ul><ul><li>/Courier findfont  </li></ul><ul><li>28 scalefont  </li>...
What Languages are they? <ul><li>/(?ms)&quot;((?>[^amp;quot;]+)?(?>[^amp;quot;]*)*)/   </li></ul><ul><li>Regex – Regular E...
What Languages are they? <ul><li>describe ArticlesController, &quot; GET index&quot; do </li></ul><ul><li>it &quot;should ...
What Languages are they? <ul><li>>gi|2501594|sp|Q57997|Y577_METJA PROTEIN MJ0577MSVMYKKILYPTDFSETAEIALKHVKAFKTLKAEEVILLHVI...
What Languages are they? <ul><li>aspect VisitAspect {  </li></ul><ul><ul><li>void Point.acceptVisitor(Visitor v) {  </li><...
What Languages are they? <ul><li><!--ADVISOR--> </li></ul><ul><li><bean id=&quot; theCuckoosEggAdvisor &quot; class=&quot;...
What Languages are they? <ul><li><html>  </li></ul><ul><li><head> </li></ul><ul><li><title>Hello World</title>  </li></ul>...
What is DSL? <ul><li>No standard definition </li></ul><ul><ul><li>Specific vs General depends on point of view </li></ul><...
DSL Examples Telecom Adhersion Business Natural Language BNL Pattern Matching Regex Object Relational Mapping Hibernate Pu...
DSL – Telecom App Framework Adhearsion (open source telecom application framework)  +  Asterisk (open source telephony pla...
LEL – Layout Expression Language <ul><li>layout = &quot;  [ label_1 | label3 ]  </li></ul><ul><li>[ (300,300)*text1 | (150...
When to justify DSL  <ul><li>Repeated need of solutions to particular problems </li></ul><ul><li>You have a good understan...
Example - Coffee Order DSL <ul><li>Starbucks Coffee Order  (*) </li></ul><ul><li>“ Venti half-caf, non-fat, no foam, no wh...
Problems with the example <ul><li>Depends on APIs </li></ul><ul><li>Code does not match the way the domain is described </...
 
DSL style <ul><li>Reveal intention better </li></ul><ul><li>Take advantage of Ruby features </li></ul><ul><ul><li>Untyped ...
Coffee Order DSL in Java <ul><li>API approach </li></ul><ul><li>CoffeeOrder order = new Latte(VENTI, HALF_CAF, NONFAT_MILK...
How about other representations? <ul><li>XML </li></ul><ul><li><Order type=“Latte”> </li></ul><ul><li><caffeine>half</caff...
Types of DSL <ul><li>Internal DSL </li></ul><ul><ul><li>Use an existing “host” programming language to describe DSL </li><...
External DSL <ul><li>Business Natural Language (BNL) </li></ul><ul><li>“ exclude offer 30 percent cli if d score is less t...
DSL Design <ul><li>DSL is not just API </li></ul><ul><li>show us-state field when country select box is &quot;United State...
DSL Tools <ul><li>Martin Fowler coined the term “Language Workbench” </li></ul><ul><li>Provide GUI frontend, metamodeling ...
MS DSL Tool for VS Studio Tutorial: Applying Domain-Specific Modeling to Game Development with the Microsoft DSL Tools. An...
Metacase’s MetaEdit+ http://www.metacase.com/fs.asp?vasen=vasen.html&paa=cases/dsm_examples.html
Jetbrains Meta Programming System (MPS)
Summary <ul><li>DSL is one way to increase a level of abstraction </li></ul><ul><ul><li>DSL developers define syntax and s...
Summary <ul><li>Types of DSL </li></ul><ul><ul><li>Internal DSL </li></ul></ul><ul><ul><ul><li>People start to use dynamic...
Further Information <ul><li>Wikipedia’s DSL http://en.wikipedia.org/wiki/Domain-specific_programming_language </li></ul><u...
Q&A Thai’s resources Narisa.com’s Design & Analysis forum  ThaiDev.org
Backup slides
LEL Sample – JRuby <ul><li>require 'profligacy/swing‘ </li></ul><ul><li>require 'profligacy/lel‘ </li></ul><ul><li>module ...
What Languages are they? <ul><li>view layout [  </li></ul><ul><li>title “Sample GUI”  </li></ul><ul><li>a: area  </li></ul...
What Languages are they? <ul><li>indexing  </li></ul><ul><li>title: &quot;Hello World&quot;;  </li></ul><ul><li>author: &q...
What Languages are they? <ul><li>module HelloWorld (main) where  </li></ul><ul><li>main = putStr &quot;Hello World
&quot; ...
What Languages are they? <ul><li>'Hello World' out.  </li></ul><ul><li>Smalltalk </li></ul>
What Languages are they? <ul><li>(print &quot;Hello World&quot;)   </li></ul><ul><li>LISP </li></ul>
What Languages are they? <ul><li>?- write('Hello World'), nl.  </li></ul><ul><li>Prolog </li></ul>
What Languages are they? <ul><li><%@ language=&quot;javascript&quot; %>  </li></ul><ul><li><html><body>  </li></ul><ul><li...
What Languages are they? <ul><li>using System;  </li></ul><ul><li>class HelloWorld {  </li></ul><ul><li>static void Main()...
What Languages are they? <ul><li>puts &quot;Hello World&quot;  </li></ul><ul><li>Tcl, Ruby </li></ul>
What Languages are they? <ul><li>documentclass[a4paper]{report}  </li></ul><ul><li>	itle{Hello World}  </li></ul><ul><li>...
Upcoming SlideShare
Loading in...5
×

Domain Specific Languages

5,231

Published on

Domain Specific Languages presentation to NJUG3 on 22 July 2007

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,231
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
248
Comments
0
Likes
9
Embeds 0
No embeds

No notes for slide

Domain Specific Languages

  1. 1. Domain Specific Language Dr. Weerasak Witthawaskul “ Mr. SweetCorn” (weerasak@hotmail.com) Narisa.com’s NJUG Meeting #3 22 July 2007
  2. 2. Who am I? <ul><li>oop guy (Pantip) </li></ul><ul><li>SweetCorn (narisa.com) </li></ul><ul><li>Wee (weerasak.com) </li></ul><ul><li>UIUC – Home of Illiac, Transistor, Superconductivity, Mosaic, Paypal, YouTube, Design Patterns, Refactoring </li></ul><ul><li>Motorola Labs, Schuamburg IL </li></ul><ul><li>ThoughtWorks Inc., Chicago IL </li></ul>
  3. 3. Graduate Life
  4. 4. Programming Paradigm Shifts <ul><li>Domain Specific Languages </li></ul><ul><li>Generative Programming </li></ul><ul><li>Model Driven Architecture (MDA) - OMG </li></ul><ul><li>Intentional Programming – Charles Simonyi, ex-Microsoft </li></ul><ul><li>Language Oriented Programming – Sergey Dmitriev, JetBrains (Home of IntelliJ IDEA) </li></ul><ul><li>Software Factories – Jack Greenfield, Microsoft </li></ul>
  5. 5. What is DSL? <ul><li>“ วันนี้มีประชุมนริสาดอทคอม ” </li></ul><ul><li>ภาษาไทย </li></ul><ul><li>“ ทำตัวติสตดีนักถูกแมวีนมายังทำตัวชิวชิวอยู่อีก ...” </li></ul><ul><li>ภาษาไทยเด็กแนว (domain specific) </li></ul>
  6. 6. What is DSL? <ul><li>Mini-language to solve specific “domain” problem </li></ul><ul><li>Why is it important? </li></ul><ul><ul><li>SQL – Relational Database Manipulation Language </li></ul></ul><ul><li>Domain specific vs General purpose </li></ul><ul><li>What constitutes “domain specific” in programming languages? </li></ul>
  7. 7. Mini Game <ul><li>“ What languages are they?” </li></ul><ul><li>Are they languages for specific domains? </li></ul><ul><li>From http://www.ntecs.de/old-hp/uu9r/lang/html/lang.en.html </li></ul>
  8. 8. What Languages are they? <ul><li>#include <stdio.h> </li></ul><ul><li>main() { </li></ul><ul><li>printf(&quot;Hello World &quot;); </li></ul><ul><li>} </li></ul><ul><li>C </li></ul>
  9. 9. What Languages are they? <ul><li>.MODEL tiny </li></ul><ul><li>.CODE </li></ul><ul><li>ORG 100h </li></ul><ul><li>HELLO PROC </li></ul><ul><li>MOV AH,09h </li></ul><ul><li>LEA DX,msg </li></ul><ul><li>INT 21h ;Display Hello World </li></ul><ul><li>MOV AX,4C00h ;Exit to DOS </li></ul><ul><li>INT 21h </li></ul><ul><li>HELLO ENDP </li></ul><ul><li>msg DB 'Hello World$' </li></ul><ul><li>END HELLO </li></ul><ul><li>Assembly Language Intel 80x86 (DOS/MASM) </li></ul>
  10. 10. What Languages are they? <ul><li><?php </li></ul><ul><li>echo &quot;Hello World &quot;; </li></ul><ul><li>?> </li></ul><ul><li>PHP </li></ul>
  11. 11. What Languages are they? <ul><li>public class HelloWorld { </li></ul><ul><li>public static void main(String[] args) </li></ul><ul><li>System.out.println(&quot;Hello World&quot;); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>Java </li></ul><ul><li>How about JME? JEE? </li></ul>
  12. 12. What Languages are they? <ul><li>PROGRAM HelloWorld; </li></ul><ul><li>BEGIN </li></ul><ul><li>WRITELN('Hello World'); </li></ul><ul><li>END. </li></ul><ul><li>PASCAL </li></ul>
  13. 13. What Languages are they? <ul><li>print &quot;Hello World&quot; </li></ul><ul><li>PRINT “Hello World” </li></ul><ul><li>Basic, Python, Ruby, Perl </li></ul>
  14. 14. What Languages are they? <ul><li>SELECT 'Hello World' </li></ul><ul><li>SQL </li></ul>
  15. 15. What Languages are they? <ul><li>BEGIN </li></ul><ul><li>DBMS_OUTPUT.put_line('Hello World'); </li></ul><ul><li>END; </li></ul><ul><li>PL/SQL </li></ul>
  16. 16. What Languages are they? <ul><li>Report Hello_World. </li></ul><ul><li>Write: &quot;Hello World&quot;. </li></ul>ABAP
  17. 17. What Languages are they? <ul><li>io:fwrite(&quot;Hello World~n&quot;). </li></ul>Erlang
  18. 18. What Languages are they? <ul><li>IDENTIFICATION DIVISION. </li></ul><ul><li>PROGRAM-ID. HelloWorld. </li></ul><ul><li>AUTHOR. Fabritius. </li></ul><ul><li>ENVIRONMENT DIVISION. </li></ul><ul><li>CONFIGURATION SECTION. </li></ul><ul><li>INPUT-OUTPUT SECTION. </li></ul><ul><li>DATA DIVISION. </li></ul><ul><li>FILE SECTION. </li></ul><ul><li>WORKING-STORAGE SECTION. </li></ul><ul><li>LINKAGE SECTION. </li></ul><ul><li>PROCEDURE DIVISION. DISPLAY &quot;Hello World&quot;. STOP RUN. </li></ul>COBOL
  19. 19. What Languages are they? <ul><li>% Hello World </li></ul><ul><li>/Courier findfont </li></ul><ul><li>28 scalefont </li></ul><ul><li>setfont </li></ul><ul><li>0 0 moveto </li></ul><ul><li>(Hello World) show </li></ul><ul><li>showpage </li></ul><ul><li>Postscript </li></ul>
  20. 20. What Languages are they? <ul><li>/(?ms)&quot;((?>[^amp;quot;]+)?(?>[^amp;quot;]*)*)/ </li></ul><ul><li>Regex – Regular Expression </li></ul>
  21. 21. What Languages are they? <ul><li>describe ArticlesController, &quot; GET index&quot; do </li></ul><ul><li>it &quot;should be successful&quot; do </li></ul><ul><li>get &quot;index&quot; </li></ul><ul><li>response.should be_success </li></ul><ul><li>end </li></ul><ul><li>if &quot;should set @articles&quot; do </li></ul><ul><li>Article.should_receive(:find).and_return(mock('articles')) </li></ul><ul><li>get &quot;index&quot; </li></ul><ul><li>assigns[:articles].should_not be_nil </li></ul><ul><li>end </li></ul><ul><li>RSpec on Ruby - Language of testing from TDD to BDD </li></ul>
  22. 22. What Languages are they? <ul><li>>gi|2501594|sp|Q57997|Y577_METJA PROTEIN MJ0577MSVMYKKILYPTDFSETAEIALKHVKAFKTLKAEEVILLHVIDEREIKKRDIFSLLLGVAGLNKSVEEFENELKNKLTEEAKNKMENIKKELEDVGFKVKDIIVVGIPHEEIVKIAEDEGVDIIIMGSHGKTNLKEILLGSVTENVIKKSNKPVLVVKRKNS </li></ul><ul><li>BLAST query </li></ul>
  23. 23. What Languages are they? <ul><li>aspect VisitAspect { </li></ul><ul><ul><li>void Point.acceptVisitor(Visitor v) { </li></ul></ul><ul><ul><ul><li>v.visit(this); </li></ul></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>} </li></ul><ul><li>AspectJ </li></ul>
  24. 24. What Languages are they? <ul><li><!--ADVISOR--> </li></ul><ul><li><bean id=&quot; theCuckoosEggAdvisor &quot; class=&quot;org.springframework.aop.support.RegexpMethodPointcutAdvisor&quot;> </li></ul><ul><li><property name=&quot;advice&quot;> </li></ul><ul><li><ref local=&quot; theReplacementFeaturePart1Advice &quot;/> </property> </li></ul><ul><li><property name=&quot;pattern&quot;> <value> IBusinessLogic.* </value> </li></ul><ul><li></property> </li></ul><ul><li></bean> </li></ul><ul><li><!--ADVICE--> </li></ul><ul><li><bean id=&quot; theReplacementFeaturePart1Advice &quot; class=&quot; CuckoosEgg &quot;/> </li></ul><ul><li>SpringAOP </li></ul>
  25. 25. What Languages are they? <ul><li><html> </li></ul><ul><li><head> </li></ul><ul><li><title>Hello World</title> </li></ul><ul><li></head> </li></ul><ul><li><body> </li></ul><ul><li>Hello World </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul><ul><li>Of course – HTML! </li></ul>
  26. 26. What is DSL? <ul><li>No standard definition </li></ul><ul><ul><li>Specific vs General depends on point of view </li></ul></ul><ul><ul><li>VB vs VBA </li></ul></ul><ul><li>It helps revealing intentions </li></ul><ul><ul><li>Language that domain experts understand </li></ul></ul><ul><li>It becomes more and more popular because of tooling support </li></ul><ul><ul><li>You can apply DSLs to solve your problems </li></ul></ul><ul><ul><li>You can even create your own DSL! </li></ul></ul>
  27. 27. DSL Examples Telecom Adhersion Business Natural Language BNL Pattern Matching Regex Object Relational Mapping Hibernate Publishing Postscript Database Manipulation SQL Domain DSL
  28. 28. DSL – Telecom App Framework Adhearsion (open source telecom application framework) + Asterisk (open source telephony platform)
  29. 29. LEL – Layout Expression Language <ul><li>layout = &quot; [ label_1 | label3 ] </li></ul><ul><li>[ (300,300)*text1 | (150)people ] </li></ul><ul><li>[ <label2 | _ ] </li></ul><ul><li>[ message | buttons ] &quot; </li></ul>Source: http://pphetra.blogspot.com/2007/07/lel.html
  30. 30. When to justify DSL <ul><li>Repeated need of solutions to particular problems </li></ul><ul><li>You have a good understanding of problem domain </li></ul><ul><li>There is a ready-to-use DSL in that domain </li></ul><ul><li>Or if you have to invent one… </li></ul><ul><ul><li>What should it look like? </li></ul></ul>
  31. 31. Example - Coffee Order DSL <ul><li>Starbucks Coffee Order (*) </li></ul><ul><li>“ Venti half-caf, non-fat, no foam, no whip latte” </li></ul><ul><li>Traditional Implementation </li></ul>(*) Agile DSL Development in Ruby – Obie Fernandez (http://obiefernandez.com)
  32. 32. Problems with the example <ul><li>Depends on APIs </li></ul><ul><li>Code does not match the way the domain is described </li></ul><ul><li>Still difficult to read and verify </li></ul>
  33. 34. DSL style <ul><li>Reveal intention better </li></ul><ul><li>Take advantage of Ruby features </li></ul><ul><ul><li>Untyped declaration </li></ul></ul><ul><ul><li>No parenthesis parameter </li></ul></ul><ul><ul><li>Metaprogramming support i.e. create class methods on the fly etc. </li></ul></ul>
  34. 35. Coffee Order DSL in Java <ul><li>API approach </li></ul><ul><li>CoffeeOrder order = new Latte(VENTI, HALF_CAF, NONFAT_MILK); </li></ul><ul><li>CoffeeOrder coffee = order.prepare(false); </li></ul><ul><li>DSL approach </li></ul><ul><li>CoffeeOrder order = new Latte().size(VENTI).caffeine(HALF).milk(NONFAT).foam(FALSE); </li></ul><ul><li>CoffeeOrder coffee = order.prepare(); </li></ul>
  35. 36. How about other representations? <ul><li>XML </li></ul><ul><li><Order type=“Latte”> </li></ul><ul><li><caffeine>half</caffeine> </li></ul><ul><li><milk>nonfat</milk> </li></ul><ul><li><foam>false</form> </li></ul><ul><li><whip>false</whip> </li></ul><ul><li></Order> </li></ul><ul><li>English </li></ul><ul><li>“ Venti half-caf, non-fat, no foam, no whip latte” </li></ul><ul><li>“ Venti latte with no whip cream, no foam, non-fat milk, half-caffeine” </li></ul>
  36. 37. Types of DSL <ul><li>Internal DSL </li></ul><ul><ul><li>Use an existing “host” programming language to describe DSL </li></ul></ul><ul><ul><li>Leverage host compiler/interpreter </li></ul></ul><ul><ul><li>Some programming languages are better for describing DSL e.g. dynamic languages; some use metaprogramming / annotations </li></ul></ul><ul><li>External DSL </li></ul><ul><ul><li>Define your own format of the language </li></ul></ul><ul><ul><li>Use XML along with XSD or DTD </li></ul></ul><ul><ul><li>Must create your own parser/interpreter </li></ul></ul><ul><ul><li>Or use DSL tools </li></ul></ul>
  37. 38. External DSL <ul><li>Business Natural Language (BNL) </li></ul><ul><li>“ exclude offer 30 percent cli if d score is less than or equal to 2” </li></ul><ul><li>Custom DSL </li></ul><ul><li>show us-state field when country select box is &quot;United States&quot; </li></ul><ul><li>show province field when country select box is &quot;Canada&quot; </li></ul><ul><li>show brutus when us-state select box is &quot;Ohio&quot; or &quot;Michigan&quot; </li></ul>
  38. 39. DSL Design <ul><li>DSL is not just API </li></ul><ul><li>show us-state field when country select box is &quot;United States&quot; </li></ul><ul><li>show province field when country select box is &quot;Canada&quot; </li></ul><ul><li>show brutus when us-state select box is &quot;Ohio&quot; or &quot;Michigan&quot; </li></ul><ul><li>JavaScript Solution #1 </li></ul><ul><li>create_dynamic_field(&quot;show&quot;, &quot;us-state-field&quot;, &quot;country&quot;, &quot;United States&quot;); </li></ul><ul><li>create_dynamic_field(&quot;show&quot;, &quot;province-field&quot;, &quot;country&quot;, &quot;Canada&quot;); </li></ul><ul><li>create_dynamic_field(&quot;show&quot;, &quot;brutus&quot;, &quot;state&quot;, [&quot;Ohio&quot;, &quot;Michigan&quot;]); </li></ul><ul><li>JavaScript Solution #2 </li></ul><ul><li>show(&quot;us-state-field&quot;).when(&quot;country&quot;).is(&quot;United States&quot;); </li></ul><ul><li>show(&quot;province-field&quot;).when(&quot;country&quot;).is(&quot;Canada&quot;); </li></ul><ul><li>show(&quot;brutus&quot;).when(&quot;us-state&quot;).is(&quot;Ohio, Michigan&quot;); </li></ul>
  39. 40. DSL Tools <ul><li>Martin Fowler coined the term “Language Workbench” </li></ul><ul><li>Provide GUI frontend, metamodeling and/or code generation to define and use DSL </li></ul><ul><ul><li>Microsoft DSL tool for Visual Studio </li></ul></ul><ul><ul><li>Intentional Software </li></ul></ul><ul><ul><li>Eclipse EMF </li></ul></ul><ul><ul><li>JetBrains Meta Programing System </li></ul></ul>
  40. 41. MS DSL Tool for VS Studio Tutorial: Applying Domain-Specific Modeling to Game Development with the Microsoft DSL Tools. André W. B. Furtado, André L. de M. Santos
  41. 42. Metacase’s MetaEdit+ http://www.metacase.com/fs.asp?vasen=vasen.html&paa=cases/dsm_examples.html
  42. 43. Jetbrains Meta Programming System (MPS)
  43. 44. Summary <ul><li>DSL is one way to increase a level of abstraction </li></ul><ul><ul><li>DSL developers define syntax and semantics to express solutions closer to the domain problem </li></ul></ul><ul><ul><ul><li>Using DSL tools </li></ul></ul></ul><ul><ul><ul><li>Creating parser/interpreter </li></ul></ul></ul><ul><ul><ul><li>Embedding to host languages </li></ul></ul></ul><ul><ul><li>DSL users can be either programmers or domain experts </li></ul></ul>
  44. 45. Summary <ul><li>Types of DSL </li></ul><ul><ul><li>Internal DSL </li></ul></ul><ul><ul><ul><li>People start to use dynamic languages to create DSL </li></ul></ul></ul><ul><ul><ul><ul><li>Ruby on Rails/Grails, Rake (Make on Ruby) </li></ul></ul></ul></ul><ul><ul><li>External DSL </li></ul></ul><ul><li>Design is important </li></ul><ul><ul><li>Consult with domain experts </li></ul></ul>
  45. 46. Further Information <ul><li>Wikipedia’s DSL http://en.wikipedia.org/wiki/Domain-specific_programming_language </li></ul><ul><li>Martin Fowler’s Bliki on DSL http://martinfowler.com/bliki/dsl.html </li></ul><ul><li>Language Workbenches: The Killer-App for Domain Specific Languages? http://martinfowler.com/articles/languageWorkbench.html </li></ul><ul><li>Obie Fernandez’s Agile DSL Development in Ruby (http://obiefernandez.com/presentations/obie_fernandez-agile_dsl_development_in_ruby.pdf) </li></ul><ul><li>Sergey Dmitriev’s Language Oriented Programming: The Next Programming Paradigm (www.onboard.jetbrains.com/is1/articles/04/10/lop/mps.pdf) </li></ul>
  46. 47. Q&A Thai’s resources Narisa.com’s Design & Analysis forum ThaiDev.org
  47. 48. Backup slides
  48. 49. LEL Sample – JRuby <ul><li>require 'profligacy/swing‘ </li></ul><ul><li>require 'profligacy/lel‘ </li></ul><ul><li>module Test </li></ul><ul><li>include_package 'javax.swing' </li></ul><ul><li>include Profligacy </li></ul><ul><li>layout = &quot; [ label_1 | label3 ] </li></ul><ul><li>[ (300,300)*text1 | (150)people ] </li></ul><ul><li>[ <label2 | _ ] </li></ul><ul><li>[ message | buttons ] &quot; </li></ul><ul><li>ui = Swing::LEL.new(JFrame,layout) do |c,i| </li></ul><ul><li>c.label_1 = JLabel.new &quot;The chat:&quot; </li></ul><ul><li>c.label2 = JLabel.new &quot;What you're saying:&quot; </li></ul><ul><li>c.label3 = JLabel.new &quot;The people:&quot; </li></ul><ul><li>c.text1 = JTextArea.new </li></ul><ul><li>c.people = JComboBox.new </li></ul><ul><li>c.message = JTextArea.new </li></ul><ul><li>c.buttons = Swing::LEL.new(JPanel, &quot;[send|hate|quit]&quot;) do |c,i| </li></ul><ul><li>c.send = JButton.new &quot;Send&quot; </li></ul><ul><li>c.hate = JButton.new &quot;Hate&quot; </li></ul><ul><li>c.quit = JButton.new &quot;Quit&quot; </li></ul><ul><li>end.build :auto_create_container_gaps => false </li></ul><ul><li>end </li></ul><ul><li>ui.build(:args => &quot;Simple LEL Example“) </li></ul><ul><li>end </li></ul>
  49. 50. What Languages are they? <ul><li>view layout [ </li></ul><ul><li>title “Sample GUI” </li></ul><ul><li>a: area </li></ul><ul><li>b: button “Fetch URL” </li></ul><ul><li>[ r: read http://www.bofh.org.uk </li></ul><ul><li>a/text: r </li></ul><ul><li>show a </li></ul><ul><li>] </li></ul><ul><li>button “Close” [unview] </li></ul><ul><li>] </li></ul><ul><li>Rebol </li></ul>DDJ Article on Rebol - http://www.ddj.com/184404172
  50. 51. What Languages are they? <ul><li>indexing </li></ul><ul><li>title: &quot;Hello World&quot;; </li></ul><ul><li>author: &quot;Michael Neumann&quot;; </li></ul><ul><li>class MAIN creation </li></ul><ul><li>make </li></ul><ul><li>feature </li></ul><ul><li>make is </li></ul><ul><li>do </li></ul><ul><li>io.put_string(&quot;Hello World&quot;); </li></ul><ul><li>io.new_line </li></ul><ul><li>end -- make </li></ul><ul><li>end -- class MAIN </li></ul><ul><li>Eiffel </li></ul>
  51. 52. What Languages are they? <ul><li>module HelloWorld (main) where </li></ul><ul><li>main = putStr &quot;Hello World &quot; </li></ul><ul><li>Haskell </li></ul>
  52. 53. What Languages are they? <ul><li>'Hello World' out. </li></ul><ul><li>Smalltalk </li></ul>
  53. 54. What Languages are they? <ul><li>(print &quot;Hello World&quot;) </li></ul><ul><li>LISP </li></ul>
  54. 55. What Languages are they? <ul><li>?- write('Hello World'), nl. </li></ul><ul><li>Prolog </li></ul>
  55. 56. What Languages are they? <ul><li><%@ language=&quot;javascript&quot; %> </li></ul><ul><li><html><body> </li></ul><ul><li><% </li></ul><ul><li>Response.Write('Hello World!'); </li></ul><ul><li>%> </li></ul><ul><li></body></html> </li></ul><ul><li>JavaScript </li></ul>
  56. 57. What Languages are they? <ul><li>using System; </li></ul><ul><li>class HelloWorld { </li></ul><ul><li>static void Main() { </li></ul><ul><li>Console.WriteLine(&quot;Hello World&quot;); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>C# </li></ul>
  57. 58. What Languages are they? <ul><li>puts &quot;Hello World&quot; </li></ul><ul><li>Tcl, Ruby </li></ul>
  58. 59. What Languages are they? <ul><li>documentclass[a4paper]{report} </li></ul><ul><li> itle{Hello World} </li></ul><ul><li>egin{document} </li></ul><ul><li>Hello World </li></ul><ul><li>end{document} </li></ul><ul><li>LaTeX </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×