# Different sorts of little languages

**URL:** <https://racket.discourse.group/t/different-sorts-of-little-languages/467>\
**Category:** Questions & Answers\
**Created:** [December 23, 2021, 5:45pm UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467 "2021-12-23T17:45:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [December 23, 2021, 5:45pm UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467/1 "2021-12-23T17:45:27Z")

</div>

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](http://web.eecs.umich.edu/~mjguz/uploads/Guzdial-Koli-longform.pdf) describes [Vega-lite](https://vega.github.io/vega-lite/) as a TSPL. I think that means [Sawzall](https://docs.racket-lang.org/sawzall/index.html) counts as a TSPL?  
Are there any other Racket examples?

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

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [December 24, 2021, 8:36am UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467/2 "2021-12-24T08:36:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)\
**Post date:** [December 24, 2021, 9:21am UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467/3 "2021-12-24T09:21:42Z")

</div>

Yes

For [`at-exp`](https://www.greghendershott.com/2015/08/at-expressions.html) you can write: `#lang at-exp racket` or `#lang at-exp typed/racket`

For [2d syntax](https://docs.racket-lang.org/2d/) 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

---

<div class="post-metadata">

**Author:** ![dannypsnl](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/dannypsnl/32/917_2.png) [@dannypsnl](https://racket.discourse.group/u/dannypsnl)\
**Post date:** [December 24, 2021, 9:34am UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467/4 "2021-12-24T09:34:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)\
**Post date:** [December 24, 2021, 10:29pm UTC](https://racket.discourse.group/t/different-sorts-of-little-languages/467/5 "2021-12-24T22:29:59Z")

</div>

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.
