Different sorts of little languages

I'm trying to get my head around languages in general and I've come across some jargon around DSL's that I'm not clear on. So I have questions and hopefully you have answers and perhaps examples?

external DSL
I think LaTeX, AWK or the graphviz dot language are examples.
I'm guessing Scribble too: scribble --markdown myrtle.scrbl. I suppose any #lang DSL counts as an external DSL because you can run it with racket <<mlangprogfilename>>? I think this would mean you could use '#lang datalog` as an external DSL.

embedded DSL
I'm relying on wikipedia and web pundits; these are described as being built on the host language and usually adopting host language syntax. React is given as a Javascript example.

Is racket/class an embedded DSL that uses the host language syntax?

What about regular expressions?
Do the #rx or #px values count as a programs in their respective DSL's?
Do they not count as most(?) general purpose languages include regular expressions?
The Racket reference refers to compiling them; 'it is faster to compile the string once to a regexp value' so I've (possibly incorrectly) concluded that regular expressions are a widespread embedded DSL, along with string interpolation like format?

Is #lang 2d a DSL that only changes the syntax? with the host language is not extended with additional functionality like classes and objects?
(I may be wrongly assuming that 2d reader passes cond, match and friends to Racket, and you can't use it with host languages that lack the set of forms it emits)

TSPL / 'Task Specific' PL - this paper describes Vega-lite as a TSPL. I think that means Sawzall counts as a TSPL?
Are there any other Racket examples?

Have I missed anything?
Are there good resources to look at?

3 Likes

but for #lang xxx is compatible with #lang racket?

Yes

For at-exp you can write: #lang at-exp racket or #lang at-exp typed/racket

For 2d syntax you can write: #lang 2d racket

I don’t know if you can do both? #lang 2d at-exp racket
Or if the order is significant? #lang at-exp 2d racket

(I should try by I can’t right now)

Best wishes
Stephen

Yes, you can do both, if them don't have internal conflict

1 Like

Here's my take

  • External DSL: Any DSL you can't use directly in the program. If you're string-concatenating programs, it's probably an external DSL. So, this is highly dependent on perspective. A racket program generating LaTeX, Awk, etc., is using them as external DSLs.

  • Embedded: "Non-string" DSLs. Regexes, classes, qi, syntax/parse, etc., all count to me. (A regex is a program that decides membership to a class of strings, from my perspective; even though most regex dialects are more powerful than regular languages, they still describe a class of strings.)

  • TSPL: this sounds like a DSL and thus pointless distinction to me, but I'm no expert.

4 Likes