DSLs vs. APIs

Ever since Joe, Neal, Zak and I started working on our DSL book, we’ve had an outstanding question that we had no good concise and simple answer for.

How is a DSL different than an API?

We’ve spent hours talking, arguing and asking others how they would answer this question. Still the answers we’ve had so far have been too complicated and didn’t feel “right”, until today.

I just got back from breakfast w/ Rob Mee, and we talked about DSLs among other things. His answer to this question is far too simple, so simple, in fact that I think we might finally have it.

Unlike an API, a DSL has it’s own grammar.

But what if it’s an internal DSL? Well, it still has an implicit grammar over and above its host language grammar.
Rob has a background in Linguistics and drew parallels between the difference between Pidgin Languages and Creole Languages

A Pidgin Language is one that forms when adults from 2 disparate languages come into contact and try to communicate. It has a minimal grammar and verb forms. It often follows subject – verb – object order and uses extra words for tenses. There are no native speakers of a Pidgin Language.

However, when adults that speak a Pidgin Language teach it to their children, a funny thing happens : their children add grammar to it. They become native speakers and the language morphs into a Creole Language.

Creole Languages are much richer than their Pidgin parents. It’s possible to more easily express complex concepts in Creole than Pidgin. They have more structure and can be more concise and exact as a result.


(if you’re interested in Pidgin & Creole, Rob recommends The Language Instinct)


Comments are closed.