Hacker News new | ask | show | jobs
by ssivark 1302 days ago
Here's something I don't understand: How are "little languages" different from a bunch of functionality wrapped into a library/module? Is it just that (with some convenient syntax sprinkled on top), or is there more to it?

I would imagine that most of the value comes from being able to "refactor" thought patterns to match the best way to cleave the domain into composable concepts -- and it seems like we do this all the time (and in all programming languages?).

4 comments

"How are "little languages" different from a bunch of functionality wrapped into a library/module?"

This is called a shallow embedding in the Haskell world.

Deep Embedding is more like writing a full blown interpreter.

Then there is tagless final (Oleg Kiselyov) - it feels shallow but is more flexible as simple library functions and it is optimisable like deep embedded DSLs.

http://www.cse.chalmers.se/~josefs/publications/TFP12.pdf

https://wiki.haskell.org/Embedded_domain_specific_language

With a DSL you need to learn syntax, semantics and either the API for interacting with your GP language or the tooling for external DSLs.

With a library you just need to learn the new semantics. I much prefer this to a DSL.

Plus a library has all the debug tools the language has. DSLs usually don't have any debug tools except for printing when you are lucky

I agree, they are the same! regex is an example of an eDSL that most general-purpose languages support. The king of eDSL:s is of course Haskell. I recommend looking up parser combinators for anyone who has ever struggled with an understanding way to complex regex expressions.
An “internal DSL” is a library with a a design which makes it “feel” like a language. JQuery is the classic example. An “external DSL” has its own syntax, like regexes.