2010/JIT-Compiling Domain Specific Languages
During this talk, we will survey real-world implementations of JIT-compiled embedded DSLs and their applications.
Speaker: Jeremy Voorhis
Return to this session's details
Contributed notesDomain-Specific Languages (DSLs) as jargon for shared use by domain experts, programmers. c.f. Landin's "The Next 700 Programming Languages," where he creates a "you know what I mean" meta-DSL.
In a DSL, your model should represent domain concepts. You should use the language of the experts.
Interpreted DSLs are easy to build / maintain. Good choice "in the absence of performance requirements," he says cheekily. ;-)
Compiled DSLs have an initial overhead. But they can generate code in another target language, or even (through JIT) machine code.
External vs. embedded DSL: is your DSL a language or a library?
Examples: 3 musical DSLs
- Csound: list of musical events in a score
- ChucK: more programming-like
- Faust: wire up DSP steps in a graphical block diagram
- Suite of compiler backend tools
- Generate intermediate representation (IR)
- Uses single-assignment style, types, modules, metadata
- Think of it as a target-independent, type-safe assembly language
- Transform IR and generate machine code
- Backends for many languages
- Ruby example that builds up the IR in a Builder-like syntax
- I put a DSL in your DSL, so you can ...
- JITtable music DSL
- Can process audio in realtime
Q. "How would you slur notes?" A. "Maybe I'll have an answer for that, but not today."
- Sound as function from Time (Real) to Amplitude (Real)
- Programmer can create a new kind of sound by defining needed parameters + "render" function to return amplitude at a particular relative time
- A programming language = lambda calculus + handy constants
- Siren generates and walks an AST from Ruby code, generating IR through the builder-like syntax
- c.f. Hutton's "Fold and Unfold for Denotational Semantics"
- Generates some IR, some C (for easy calls to portaudio)
- Easy to pass generated code to the runtime
- Demo of Siren playing Satie's Gymnopaedie
For more, see http://github.com/jvoorhis