One of the reasons for using dynamic methods invocation (as highlighted by a few posts I made over the past few weeks) is to implement an internal Domain Specific Language (DSL) in Delphi. As this topic is quite new to the Delphi community, it could be worth exploring it. I don't have a full paper on the subject, so the only thing I can do right now is share the key points of the slides a prepared for a recent talk on the subject. This material covers the introduction, later I'll get back to Delphi specific examples.

Domain Specific Languages

  • Old technology, having a second youth
  • Popular in LISP and Smalltalk days
  • The SQL example

Borrowed from real life

  • Starbuck DSL: “Venti non-fat no-foam Latte”
  • Sport DSLs, Football/Soccer:“Striker scored with a header after an assist from a corner kick”

DSL and Myself

  • It all started attending a talk by Neal Ford
  • He works with “DSL guru” Martin Fowler
  • Very popular in Ruby (Rails DSLs)
  • Becoming popular in Java
  • “Curly-brace” languages have limited DSL support
  • What about Delphi? Before the end of his talk I had a short demo and a few ideas

Domain Specific Languages

  • A high-level language shared by developers and customers
  • Or sellers and buyers, in the real world
  • Or different groups of developers
  • One case is that of “Fluent languages”,English-like (and not only English!)

DSL are focused and limited

  • A programming language, but not a general purpose one
  • Very narrow purpose
  • Not “Turing complete”
  • Generally no loops, limited conditions

More Examples

  • LINQ
  • Textual DFM
  • XML notations

External DSL

  • Completely separate syntax and processing from the host language
  • Uses a separate compiler or interpreter

Internal DSL

  • Code written with the syntax of the host language
  • Better if a dynamic language (Ruby, LISP, Smalltalk)
  • Uses a language subset

There is a large debate between:

  • UML and/or MDA
  • DSL
  • Traditional OOP models

To DSL or not?

  • Increased productivity with DSL, investment in language creation
  • External DSL: lack of symbolic integration, language cacophony, better for non-programmers
  • Internal DSL: limited by host language syntax, harder for non-programmers

I know, I know, hard to understand... but you can find countless links on the web to get more information... and I might provide some as well. Still, my goal is to get to Delphi DSL coding ASAP.