Delphi 2007 Handbook




Essential Pascal




social web book








April 14, 2008

Introducing Domain Specific Languages

One of the reasons for using dynamic methods invocation is to implement an internal Domain Specific Language (DSL) in Delphi.

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.





 

3 Comments

Introducing Domain Specific Languages 

OK, getting somewhere, but this "Why" is still a "What"...

Q: Why do we want/need Dynamic Invocation?
A: So we can do DSL in Delphi.

Which then simply leads to ....


Q: Why do we want/need to be able to do DSL in Delphi?


The only answers I see so far are:

1. Because it looks like it could be fun
2. Because it looks like we can


Of course, we see again the "Business Benefit De Jour"
for "new" language developments these days....
increased "productivity", which upon closer
examination means "Jam Today", which works great for
throw away code (in which case, why not just use a
language/tool designed for creating such "disposable"
products int he first place, rather than twist and
coerce a product designed for something else entirely).

The "new" in "New Language Developments" being
enquoted because as you yourself point out, a lot of
these "new" ideas are in fact old ones that have had
their chance and "failed" in the "real world" (lots of
enquoting of colloquialisms not meant to be taken
literally) or at least been found wanting.

All that has changed in most significant respects is
that sufficient time has passed that their failings
have been forgotten and a whole new audience is able
(and/or willing) to be talked into parting with $$'s
in pursuit of another motherlode of Fool's Gold.


Unless, that is, there really is a real answer to the
"WHY" question in all of this.
Comment by Jolyon Smith [http://www.deltics.co.nz] on April 14, 23:34

Introducing Domain Specific Languages 

It seems like the term "domain specific language" is a
fairly loose definition.  If you import data from a
spreadsheet, the spreadsheet could be a domain
specific language, and one that represents data in a
way that is comfortable for users and not too foreign
to a database.  I have found that to be a very
productive and flexible interface to work with.  I
will be very interested to see how developing a
further understanding of an external domain specific
language can help me in this area.
Comment by Jack Rodenhi on April 15, 00:07

Introducing Domain Specific Languages 

For the sake of practicity about DSL:

Do you think that ABAP, the Domain Specific Language
of the almost all-mighty and succesfull ERP named SAP,
one of the greatest features is a practical joke? 

Domain Specific Languajes is a great tecnique when you
have a requirement of flexibility in your
applications, no matter the size of them. Of course,
the market you're targeting is what matters, but I
think even no-brainers could bennefit from a tool
whenever they try to customize your apps further.

I have implemented something myself, and this DSL turn
to be one of the major advantages. I even have a post
about Dynamic Method Invocation too (in spanish).

http://salvador.oversistemas.com/2007/11/llamada-dinamica-metodos_19.html

Way to go, Marco!
Comment by Salvador Gomez Retamoza [http://salvador.oversistemas.com] on April 15, 22:38


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.