Skip to content

Instantly share code, notes, and snippets.

@levand
Last active January 10, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levand/0b5fe859db03f63e7f1ba05718a70a6d to your computer and use it in GitHub Desktop.
Save levand/0b5fe859db03f63e7f1ba05718a70a6d to your computer and use it in GitHub Desktop.
What style of asset/cljs DSL do you find more natural?
;; Both of these code samples do exactly the same thing: define an asset pipeline
;; with a ClojureScript build that reads from "src/cljs/*" and compiles to "out/*".
;;The question is, which style of DSL is more readable/natural?
(require '[arachne.assets.dsl :as a])
(require '[arachne.cljs.dsl :as cljs])
(def opts {:output-to "js/main.js"
:output-dir "js"
:asset-path "js"
:optimizations :none
:main 'arachne.cljs.example})
;; Alternative #1: DSL forms with positional arguments. Terse and clean.
(a/input-dir :test/input "src/cljs" :watch? true)
(cljs/build :test/build :test/input opts)
(a/output-dir :test/output :test/build "out")
;; Alternative #2: Use named keyword args pervasively. The pieces are labeled.
(a/input-dir :test/input
:dir "src/cljs"
:watch? true)
(cljs/build :test/build
:input :test/input
:compiler-opts opts)
(a/output-dir :test/output
:input :test/build
:dir "out")
;; Note that in every case, the first argument is the 'ID' of the component that
;; is used to wire it together with the others.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment