Fork me on GitHub

I'm reading Web Development with Clojure by yogthos and I've noticed that the book is using metosin/ring-http-response. Has that been superseded by ring.util.response since the writing of the book?


If not, why would one use metosin/ring-http-response instead of ring.util.response? The github page of the former says that it's a "a drop-in-place replacement for ring.util.response", but I'm not sure what that means.


@nikoszp the metosin-version maps all http-status code and with their own names like ok (200), found (302) and see-other (303). Ring has only few most used and have custom names for response (200), redirect (302) and redirect-after-post (303).


Got it, thank you!


@nikoszp Clojure is not very opinionated about libraries but instead takes a mix'n'match approach. Both metosin/ring-http-response and ring.util.response were last updated in the tail end of 2017 so they're both stable and (reasonably) well-maintained. So pick whichever you prefer.


A lot of Clojure libraries are very small and focused and therefore often "complete" and rarely in need of maintenance. This is very different to a lot of other technologies, so folks often ask "Is this library dead?"


Thanks for the insight!


In the end, both just generate Ring maps: (ok "kikka") => {:status 200, :body "kikka", :headers {}}

👍 8

It's all data, all the way down 🙂


(sometimes it's better to learn to use the data than to learn the DSLs in these libraries)


I think that Web Development book pushes Luminus, doesn't it? I'd recommend starting with Ring basics and learning how it works at a lower level -- Luminus has a fair bit of "magic" in it...


Where I work, everything is built with Ring + either Compojure or Bidi + Selmer (sometimes). No frameworks.


Thanks, that's great advice! I'm reading the Ring documentation too in parallel. Btw, the first chapter of the book starts off with a luminus app but then the next chapter goes on to explore the elements of the Luminus stack, including Ring.


The story I like to tell about this... I wrote one of the most popular MVC frameworks in Language X. I decided to port it to Clojure. We started to convert our Language X Framework Y apps over to Clojure Framework Y. We fairly quickly discovered that Framework Y didn't really add anything in Clojure so we decided to sunset it and just use the raw libraries instead.


When you come from Language X, the lack of Framework Y can be a little unsettling... But it's normally because Clojure does not need an equivalent of Framework Y 🙂

👌 4

Anyone here using re-natal? Would anyone recommend it to someone who has not used react-native before?


I checked some example in the hope of quickly transforming a re-frame project to react native. Had it running fast, but the templating is a lot different, and has no real use, so gave up.


@duminda Yes. And there are users of re-natal in #cljsrn


Hi does anyone know if mount merges settings found in profiles.clj?


ahhhhhhhhh how do people remember how contains? works? I have to look up the docs every time I want to know if 2 is in [0 1 2]


wait, do I mean some? same question either way


(some #{2} (range 0 10)) ;;=> 2 --- this is the same line i find every time i look up contains?, remember some, reread the "set as a function" trick


(#{} x) is equivalent to (get #{} x), like ({} x) is equivalent to (get {} x). contains? checks for the presence of a key (index) in an associative collection - in the case of sets, this is set membership some runs the function passed on every element of a collection, and if the return value is truthy, returns that return value, else nil


riiiiight, and a set is 'really' the map {:x :x, 1 1, "item" "item"} so running it as a function gets the value associated with the key which happens to be the key. Thank you, I think this helps


i do wish there was a member function


I almost never use contains? -- and when I do, it's only ever on a hash map where I specifically need to support nil values. Even there I mostly prefer either (the-key the-map ::not-found) or (get the-map the-key ::not-found)

👍 4

Hmm, interesting, I have just twelve occurrences of contains? in my code but my colleague uses it a lot -- about 80 occurrences in their code. And that's in a total of about 80,000 lines of Clojure.


What SQL lib do you guys use? HugSQL, Toucan, Korma?


Datomic troll

💯 12



Start with plain old, and specialize if necessary.


@U3G3MBL9H Korma has gone unmaintained for a while (although I believe it is being updated now) but it is a bit too ORM-like for most Clojurians tastes I think.


I think I’m going to stick with jdbc then transition to HuqSQL and Walkable when I need to. Thanks for the advice guys.


HugSQL is great if you like keeping your SQL outside your code. HoneySQL is a great Clojure DSL for composable queries in code -- we use it very heavily.


And we use org.clojure/java.jdbc very, very heavily (at World Singles). Also, I maintain that.


(we run a hundred dating sites on top of java.jdbc and Percona!)


Stupid question, how do I unit test SQL queries? I’m using HugSQL and would like to test my query is correct given different database states.


You could use a test DB, and then use clojure.test fixtures to set up the DB state in a transaction that rolls-back after each test? Then you can just use the query functions.


Can someone tell me the difference between clojure.lang.Cons and PersistentList?


Clojurist newb help in need! Interop troubles me. So I have this beauty piece of Java

AccessToken token = new AccessToken.Builder(twilioAccountSid, twilioApiKey, twilioApiSecret)

So I tried this beautier Cloj:
(doto (AccessToken$Builder. "twilioAccountSid" "twilioApiKey" "twilioApiSecret")
                      (.identity    "indentity")
                        (doto (ChatGrant.)
                          (.setServiceSid   "ServiceId")))
BUT! How do I solve the .toJwt() part? I still keep getting CompilerException java.lang.IllegalArgumentException: No matching field found: toJwt for class java.lang.String, compiling reading the error I understand I cant call .toJwt to a string. And here I stop don’t knowing where to go 😞


@overde how are you trying to call .toJwt? also note that doto returns the first argument, so it'll be the AccessToken$Builder instance, not the return value of .build.


was placing this doto to a def and calling like (.-toJwt token)


but looks my doto is already wrong?


the syntax for a method call is (.method obj); (.-toJwt token) would be a field access


Something like this @sundarj?


right, although you can use the -> macro to clean that up


doto is intended to be used when you want to do something to an object, but return that same object, like with setters


No luck CompilerException java.lang.IllegalArgumentException: No matching field found: toJwt for class com.twilio.jwt.accesstoken.AccessToken, compiling


that should be (.toJwt token), since `toJwt is a method


I missread your explanation of field access


Now everything is fine @sundarj, so many thanks!


hurrah! glad i could help 🙂


anybody integrated nvim with vim-fireplace + piggieback to develop in cljs?


works fine with clj, but not with cljs 😞


feel like i'm missing something . Do I need to run a :Piggieback command in nvim to get things going?