logoalt Hacker News

midnight_eclairyesterday at 1:50 PM2 repliesview on HN

> Clojure style discourages building DSLs

does it really? https://github.com/simongray/clojure-dsl-resources


Replies

geokontoday at 2:44 AM

DSLs typically involves constructing macros that are domain specific (to cobble together a domain specific programming language on top of the host). Most of the linked examples are not macro based and are the exact opposite. They specifying domain specific data layouts built directly using the Clojure-native immutable datatypes. They don't create Domain specific datatypes or function-generating wrappers. It's just rarely necessary

A good example is making GUIs in Clojure. At first there was a cool macro based system called `fn-fx` that maked a JavaFX GUI. Then vlaaad wrote `cljfx` which just used plain Clojure maps and removed the macros entirely. This increased the boilerplate a tiny amount but made the system much more flexible and extensible

embedding-shapeyesterday at 4:33 PM

I think you're talking past each other.

"DSLs" can both mean "Using the language's variant of 'arrays' to build a DSL via specific shapes" like hiccup in Clojure does, and also "A mini-language inside of a program for a specific use case" like Cucumber is its own language for acceptance testing, but it's "built in in Ruby" in reality.

Clojure favors the "DSLs made out of shapes" rather than "DSLs that don't look/work like lisp inside of our programs".

show 1 reply