{"id":1330,"date":"2018-11-09T16:33:08","date_gmt":"2018-11-09T16:33:08","guid":{"rendered":"http:\/\/sdi.thoughtstorms.info\/?p=1330"},"modified":"2018-11-09T16:33:08","modified_gmt":"2018-11-09T16:33:08","slug":"which-language-is-better-for-creating-dsls-clojure-or-haskell","status":"publish","type":"post","link":"https:\/\/sdi.thoughtstorms.info\/?p=1330","title":{"rendered":"Which language is better for creating DSLs, Clojure or Haskell?"},"content":{"rendered":"<p>Another <a href=\"https:\/\/www.quora.com\/Which-language-is-better-for-creating-DSLs-Clojure-or-Haskell\/answer\/Phil-Jones\">Quora answer<\/a>. Part of my increasing admiration for the virtues of EDN in Clojure.<\/p>\n<p><em>Which language is better for creating DSLs, Clojure or Haskell?<\/em><\/p>\n<blockquote><p>\nClojure has a slightly different philosophy than most Lisps, I think.<br \/>\nIn Clojure you\u2019d be more likely to make your \u201cDSL\u201d in EDN (\u201cExtensible Data Notation\u201d, which is a bit like JSON but with more features). It\u2019s completely integrated with \/ interoperable with Clojure itself. You can embed EDN anywhere in a Clojure program, and embed Clojure function calls anywhere in an EDN data-structure.<br \/>\nAnd you get \u201cparsing\u201d for free.<br \/>\nThat\u2019s how languages like hiccup are built.<br \/>\nSo if you just want to make \u201ca DSL\u201d (ie. convenient high-level domain specific notation for an application) then 99% of the time, a hiccup-like EDN dialect is going to be fine, and you don\u2019t have to write anything at all.<br \/>\nIn that sense, code you don\u2019t have to write is better than code you do.<br \/>\nIf you need a specific DSL with a specific syntax which isn\u2019t EDN (or s-expressions) then you\u2019ll be back to writing your own parser.<br \/>\nHere, Clojure has its own Yacc-like and parser-combinator libraries. I\u2019m not sure they\u2019re very different from Haskell\u2019s. But you don\u2019t have Haskell\u2019s algebraic data-types, so there\u2019s no type system helping you. I guess it\u2019s a bit more effort to get a Clojure DSL right using Instaparse etc. than in Haskell.<br \/>\nThere is Spec, which does some of the job but is certainly more verbose and less elegant than Haskell\u2019s algebraic data.<br \/>\nSo yeah, Haskell probably wins for writing general DSLs but if you just want to make small, simple domain-specific notations for things in your application, and don\u2019t mind the EDN look, then Clojure is fine. That\u2019s trivially easy.\n<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Another Quora answer. Part of my increasing admiration for the virtues of EDN in Clojure. Which language is better for creating DSLs, Clojure or Haskell? Clojure has a slightly different philosophy than most Lisps, I think. In Clojure you\u2019d be more likely to make your \u201cDSL\u201d in EDN (\u201cExtensible Data Notation\u201d, which is a bit [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[67,96,122],"class_list":["post-1330","post","type-post","status-publish","format-standard","hentry","category-opinion","tag-clojurescript","tag-data","tag-edn"],"_links":{"self":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/1330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1330"}],"version-history":[{"count":0,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=\/wp\/v2\/posts\/1330\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdi.thoughtstorms.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}