Fantastic DSLs and where to find them
I used to be fervent embedded DSL fan many years ago (particularly in college with Scheme&#x2F;Racket) but since then I have grown to hate them particularly Scala, Groovy and Ruby DSLs.<p>External DSLs (that is a DSL independent of the host language)... I love them. An external DSL is like a protocol or the ultimate formal API (an example would be HTTP).<p>Why do I dislike embedded DSLs: I guess the crux could be that you are essentially mixing two languages when the reality it is just one so you are doing non canonical things in the host to make the guest language look pretty (eg going to town with implicits, extension functions, and operator overloading (scala)). Basically a whole bunch of confusing stuff to normal developers just to make the DSL look pretty.<p>With Scheme&#x2F;Lisp&#x2F;Clojure it is OK because embedded DSLs using sexp look like lisp.
In Haskell it is sort of OK because Monads and various other things Haskell provides (laziness).<p>With Scala its the absolute worse with operator overloading, implicits, and various other gotchas.<p>In my experience it also gets really confusing trying to figure what is going on when a embedded DSL breakk as well as extremely difficult to secure an embedded DSL. `ie System.exit(1)` is just one call away.<p>There are exceptions of course. DSLs that mimic external DSLs one-to-one. One example being jOOQ as it aims to be one to one with an external DSL ... SQL.