DM820 Advanced T opics in Programming Languages Peter - - PowerPoint PPT Presentation

dm820 advanced t opics in programming languages peter
SMART_READER_LITE
LIVE PREVIEW

DM820 Advanced T opics in Programming Languages Peter - - PowerPoint PPT Presentation

DM820 Advanced T opics in Programming Languages Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/DM820/ DOMAIN SPECIFIC LANGUAGES 2 June 2009 Many Different Domains Databases: SQL, PL/SQL,


slide-1
SLIDE 1

DM820 Advanced T

  • pics in

Programming Languages Peter Schneider-Kamp

petersk@imada.sdu.dk

  • http://imada.sdu.dk/~petersk/DM820/
slide-2
SLIDE 2

DOMAIN SPECIFIC LANGUAGES

June 2009 2

slide-3
SLIDE 3

Many Different Domains

§ Databases: § SQL, PL/SQL, PL/pgSQL, … § not PL/Python, PL/Perl, PL/TCL, PL/Ruby, … § Mathematics & Science: § Maple, Matlab, Mathematica, … § not Numpy, Scipy, Sage, … § Hardware: VHDL, Verilog, … § Parsing: Yacc, SableCC, ANTLR, JavaCC, … § Graphics: POV, SVG, … § Graphs: Graphviz, … § Sound: Csound, …

June 2009 3

slide-4
SLIDE 4

Characteristics

§ No common features § Usually expressed in plain text § Special parsers and compilers / interpreters needed § Available language constructs depending on domain § Often embedded into host application or as application input § Often NOT turing-complete

June 2009 4

slide-5
SLIDE 5

Applicability

§ Cost-benefit analysis § Often needed when users are NOT programmers § Also make sense when expressivity very high § Make only sense for recurring tasks

June 2009 5

slide-6
SLIDE 6

Example: PL/pgSQL

§ Domain specific language for database interaction § Procedural programming mixed with queries and updates § Extends possibilities of SQL § Advantages w.r.t. SQL: § Modularity, identifiers, loops, error handling, … § Advantages w.r.t. traditional database adapters: § Improved performance (executed on server, no communication overhead with repeated SQL statements) § Code reuse (stored procedures available to all clients) § Portable (no dependence on client platform) § Disadvantages: § No user interaction possible

June 2009 6

slide-7
SLIDE 7

Hands-On

§ Using regular expressions to check text § Generating data § Aggregating data § Memoizing function values

June 2009 7

slide-8
SLIDE 8

Example: Csound

§ Domain specific language for sound generation & processing § Works on audio streams as “variables” § Basic units are instruments and tables § Contains many sources and sinks: § Oscillators § Sound card input / output § Sound file input / output § FFT

  • based convolution

§ … § Used as backend of many software synthesizers

June 2009 8

slide-9
SLIDE 9

Hands-On

§ Single Oscillator for sine wave § Attack-Decay envelope § Chorusing § Soundin § Room “correction”

June 2009 9