Fork me on GitHub

is there a good library for http path substitution? Something like /some/:id/:thing or ["some" :id :thing] with args {:id 123 :thing "foo"} and results in /some/123/foo? Seems easy enough to do by hand, but though there might be a lib out there…all the routing libs seems to do it, couldn’t find a common underlying thing though… thanks!


a lot of routing libraries do this. e.g. reitit


Hi, I'm doing:

(defn update-task [db id-to-find fn]
  (->> db 
       (map-indexed (fn [idx item]
                      [idx (= id-to-find (:id item))]))))   
and getting
Use of undeclared Var planning.core/idx

  76  (defn update-task [db id-to-find fn]
  77    (->> db 
  78         :tasks
  79         (map-indexed (fn [idx item]
  80                        [idx (= id-to-find (:id item))]))))   
Any idea what's wrong with that? (cljs 1.10.339) Seems I'm missing something obvious :thinking_face:


@mateusz.fiolka Your update-task function has fn as a parameter, and thus (fn ...) no longer has its usual meaning. A shorter repro is

(defn f [fn] (fn [a] a))


In that case you have the option to re-name the parameter, or instead, if you want the usual fn, use cljs.core/fn instead.


Damn, that was tricky coincident. I'll rename it. Thanks @mfikes 🙂


Wow I'm surprised that fn isn't a special form


Although now thinking of all the destructuring there's no way it would be


And multiple arities


So, I'm pretty much brand new to Clojure as a whole but I'm super interested


Coming from a Python background as a sysadmin who also occasionally writes utilities/apps, can ClojureScript provide the same utility?


Obviously I could use Clojure itself but I'm thinking for script level stuff, pulling from npm would be great and id never have to touch js (thank god)


both Clojure and ClojureScript can be used for small scripts


I've been writing a small utility in clojure just to whet my whistle / wear out my parens


But wondered if clojurescript might have a better time for this kinda thing generally being based on node (right?). I also saw some complaints about JVM startup time but I have some flags to test that apparently speed that up. The whole JVM thing is something I'm aware of but I'm not java guy


Clojure is easier now IMO - all you need is a call to the clojure command, and to construct a deps map if you need some libraries. But some people don’t like the startup time, esp. when you start adding lots of deps


yeah, JS has capture quite a bit more of the ops mind share so you might find more libraries for more complex needs. but you never know


for CLJS scripting, lumo is probably better than creating a CLJS built app


but lumo (being self-hosted) comes with some of it’s own idiosyncracies


It's a bit daunting with all the different options


Lumo, planck, joker for clojure


if what you want is to leverage NPM and write CLI scripts, then lumo is the way to go


I'll take a look, thanks


Perhaps a dumb question - what is the current use case for clojurescript?


imo: most of the same reasons you’d choose clojure (immutability, powerful stdlib, selective use of state, syntactic abstraction, good libraries, low ceremony host interop) + clojurescript specific things like: a more data-driven take on react, great bundle optimization with closure advanced treeshaking, less impedance mismatch if using a clojure backend.


I mean what kind of implementation is the most popular?


Like server side js, front end, etc?


I don't really do js :woman-shrugging:


oh. mostly browser stuff. some do clojurescript on mobile, a few server side with node but I think most people in the clojure community would just use clojure at that point


On cool, makes sense


And the end user would never know right? Because it compiles to pure js?


in the browser? yes compiles to js.


though they might notice how fast and well built it is troll


@james662 ClojureScript was created basically to run Clojure where you don't have access to the JVM for whatever reason


browser, mobile apps being the most popular for obvious reasons


Right, makes sense


pretty much all the points in the original ClojureScript presentation are still true wrt. rationale


@james662 I'm in the midst of writing a clojurescript library for use in a js frontend, and which can also be run as a web service on its own (so I can use complex business logic in both places without re-writing it). For this, I've found shadow-cljs the best option (after trying lumo and cljsbuild), since it has really good support for various targets, including tests with hot reloading. This mostly takes care of the jvm startup time required to build a cljs project without lumo, while also providing libraries from both js and clj ecosystems. A (more traditional) alternative would be .cljc files included in a clojure project for the web service, and a cljs build for the javascript side, but I opted for pure cljs since I'm more familiar with js than java. To be perfectly honest, getting started has been a huge pain, so feel free to DM me if you'd like any pointers. Clojure is worth it though 🙂