5 ms·
Something I find problematic about the various implementations of Clojure is the lack of specs to determine a common ground. Clojurescript doesn't use the same
by ValentinA23 2y ago
Something I find problematic about the various implementations of Clojure is the lack of specs to determine a common ground.
Clojurescript doesn't use the same conventions in import/require statements: you're supposed to import macros using :require-macros or :refer-macros (I'm not even sure anymore). Conversely, `:refer :all` was banned in a prescriptivist attempt at fixing Clojure "mistakes", the rationale behind this decision being that with `:refer :all` it's not always obvious what namespace required symbols come from. Yet, with a REPL or a language server, it's very easy to get that info.
The point I want to make is that because of this porting Clojure code to Clojurescript implies a lot of inessential changes to the ns forms in your project. E.g: https://github.com/kachayev/muse/blob/8db4d5de82a8acccb4486cc7cb6de045a0df9328/src/muse/core.cljc https://github.com/kachayev/muse/blob/8db4d5de82a8acccb4486c..., but I've done far worse.
It doesn't need to be that way.
- deleted 2y ago[deleted]
- masijo 2y agoI agree with your criticism but those "mistakes" sadly come with inheriting implementation details of the hosted environment. As far as I understand, ClojureScript couldn't workaround some JavaScript limitations regarding macros and thus had to go with `:require-macros`. A workaround is using Reader Conditionals (https://clojure.org/reference/reader#_reader_conditionals https://clojure.org/reference/reader#_reader_conditionals) and specifying platform differences where they matter, but it's awkward to say the least. What most projects do is to separate "common" namespaces and use the `.cljc` extension to indicate they're multi platform, and keep platform specific things in namespaces with `.clj`, `.cljs`, etc.
- ValentinA23 2y ago>What most projects do is to separate "common" namespaces and use the `.cljc` extension to indicate they're multi platform, and keep platform specific things in namespaces with `.clj`, `.cljs`, etc. This is exactly what I witnessed when finding the example above. Out of frustration, I tried patching shadow-cljs one afternoon and was able to implement :refer :all as well as automatically generating :require-macros when needed to some extent, but I haven't put the time to make it work fully. I don't think this is a limitation caused by the lack of a Clojurescript compiler that can run in a Javascript runtime. In short, I don't think this is an essential limitation of the way the language is hosted within its target language, unlike things like Vars, which are not introspectable at runtime in js.
- kccqzy 2y agoOh yeah I definitely lost an hour debugging why something doesn't work in ClojureScript: it turns out I used :refer rather than :refer-macro. It's still possible to use :refer, but it requires some changes to the library such as https://github.com/Engelberg/instaparse/commit/0cd039659dc768068d47690d5afb44bc601c32b0#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R137 https://github.com/Engelberg/instaparse/commit/0cd039659dc76...
- iLemming 2y agoLegit complaint, can't really argue, yet, at the same time, using various Clojure dialects and Clojure-like Fennel requires so much less mental overhead. Even switching between Javascript and Typescript is not at the same level of unsophistication. I feel biased, but targeting JVM, Node, Browser, Bash, Lua, and now Go using a single set of idioms and patterns feels so much nicer and less frustrating. Even with all the little quirks and differences.
- j12a 2y agoInclude another Clojure-like Lisp for PHP https://phel-lang.org/ https://phel-lang.org/ that you can make e.g. WordPress plugins with, hehe.