Fork me on GitHub

Hi all, I'm looking to contribute to some beginner friendly open source clojure projects, I've gone through the brave clojure list and though there are some beginner friendly issues, I don't know where to start


Is it required that I read much of the source code and understand it before contributing?

Alexander Heldt08:11:01

well, it depends. but in general you probably should have a good grasp on what the project does to be able to make a good contribution.


find a beginner-friendly issue, reproduce it, debug it, fix it, put up a pr


Hi, everyone How can I have a drop in repl (like browse in R lang) for debug in clojure?


@U6CE37RK6 sounds like you're looking for a Socket Repl?


Thanks @seancorfield Do you have a link or code example on how to do it?


I wanna make it part of my workflow (I use spacemacs + cider) (Should I use clojure.core.server/start-server?)


Thanks again


You can start a socket repl with just a JVM option when you start your application. You can then connect to it via telnet or netcat. Our use unravel / unrepl for a better experience.


Cider requires NREPL


When you talk about spacemacs/CIDER, that sounds like a regular development workflow which is always REPL-based in Clojure


So maybe I'm confused about what you're asking?


maybe the key thing with "browse" is that it drops you into the context of the error, with the locals and stack frames available? that's not really how things work in clojure normally but there was at least once a debug-repl for this sort of functionality


@U6CE37RK6 maybe to move up a level, what we usually do instead is isolate state and mutation, so that as much as possible can be debugged standalone


Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.


Thanks a lot @noisesmith, the debug-repl you mentioned by @U0GN0S72R appears to be exactly what I was looking for.


Also thanks for your advice. But I have a question about it. I do try to isolate state and mutation yet I still find such functionality useful ... to use it when you’re probing the system for sth or ... e.g. when a generative test fails and it’s not able to shrink it properly. What’s the best way to debug then ? Thanks again @noisesmith


glad I could assist, mutation in order to track local data is actually useful (and isn't neccessarily subject to the same problems that mixing side effects with app logic can be) - eg. you can add (def debug (atom [])) at the top level and something like (swap! debug conj {:context ::some-context :args [arg1 arg2] :locals {:a a :b b}}) inside the function you are debugging - it's like println debugging except you can actually play with the data, even if the issue comes up every Nth invocation


but the more principled you are about isolating side effects and logic, the more likely something like that is actually useful (eg. not relying on state of some fd or resource that is closed on error or exit)


Any better way of associating a variable using update-in than using constantly? The reason I don't use assoc-in instead is because it's intended to be used with lein update-in. Here's what I got:

(update-in {} [:local-repo] (constantly ".m2"))


Actually scratch that, using constantly doesn't work, so a better question would be, how to change lein :local-repo using the command line? This doesn't work:

lein update-in :local-repo '(constantly ".m2")' -- deps


Well, is there a lein assoc-in?


hi there


I am using chime to heartbeat via async-http request like documented here:


now I need to find a way to return the channel so that I can close it when needed. the example just runs and I cannot stop it gracefully. any ideas?


my first idea is that you return a function closed on it when you create it so you can call that when you want to close it

(let [chimes (chime-ch ,,,)]
  (<!! ,,,)
  (fn stop-chiming []
    (close! chimes)))


if you use mount state then

(defstate chimer
  (let [chimes (chime-ch ,,,)]
    (<!! ,,,)
  (close! chimer))

👍 4

thing is, <!! is blocking


but one can just leave it away


is there a preferred method to open a file at a given byte? I don't know Java well.


that might be correct, I only need to read the file. Is this a use Java interop situation?


amazing. thanks both!

Luke Schubert14:11:11

is there a way to prevent backtick quoting from adding the namespace?

Luke Schubert14:11:12


(ns test-ns)
(defn get-vec `[?foo ?bar])
=> [test-ns/?foo test-ns/?bar]
;;I want that to return
;;=> [?foo ?bar]


user=> `[~'?foo ~'?bar]
[?foo ?bar]

Luke Schubert14:11:06

ah gotcha, that makes sense albeit not the most clean looking thing. Thanks

👍 4

What does everyone use instead of async-await in cljs? Need to make a few calls to js libraries and want to avoid callback hell. I don't seem to be able to find tutorials


and mentioned at the bottom of that blogpost is cljs-promises which make a promise more like an async channel


The problem with that tutorial is that it seems out of date. Promesa doesn't have p/await


you could try asking in #clojurescript


I know what I am going to ask below is very vague question, sorry for that. But if you have any points for me to check will greatly help. I get the below exception: clojure.lang.ArityException: Wrong number of args (3) passed to: core$not This started coming after I added new argument for the existing function in both Java class and also in clojure reify where ever it is used. Any suggestions/ideas to fix this issue will be helpful. Thank you!


Do you know how to show stack traces for exceptions?


I tried the below in my .clj file. But it doesn't print stacktrace in the log file. (catch Exception e (logger/error (str "failure " ) e) (clojure.stacktrace/print-cause-trace e)) could you please tell me how I can enable full stack trace in clojure?


They can be long, and contain things you can safely ignore, and it takes some practice to read them, but they can give valuable clues.


@sreerama.naga Sounds like you have code that calls not like this: (not a b c) instead of (not a) (single argument). Perhaps when editing the code to add a new argument, you ended up moving a )?

Camilo Jorquera19:11:26

Hello! What is the best book to learn Clojure? I work with Java and I have experience with Scala, but i want to learn a pure functional lang. Thanks!


Hard to say what is the best. I like "Clojure Programming" by Emerick, Grand, and Carper, but published in 2012 so while much of it still works just fine, you may want something more recent like "Programming Clojure" by Miller, Halloway, and Bedra, 2018.

😄 4

Joy of Clojure. Heard it’s good and enjoying it

😄 4

Gets behind the why, not just how

Camilo Jorquera19:11:17

Joy of Clojure Manning? @U1RCQD0UE

Dave Goodchild22:11:40

Clojure For The Brave And True

👌 4

hey everyone. what exactly is the difference between jetty and ring?


Ring is an abstraction


It describes how http requests can be mapped to functions that take maps in one format and return maps in another format


got it. so in theory you could plug a different implementation into it


Not in theory there are many ring adapters for different webservers


The best kind of theory -- the one that works in practice.

🙏 4

Jetty is a webserver for which the ring project ships an adapter for (most other adapters are maintained outside of the ring project)


so it sounds like if i wanted to learn about how to tune a jetty server for production load, it would be more of a jvm question than clj


It depends, as an abstraction ring has some costs, and depending on your analysis you might decide things will perform better without the adapter and speaking to jetty directly from clojure


I think it would start as more of a jetty question (jetty has pretty extensive docs), and then maybe move to the jvm, then maybe looking at the costs of ring


sounds like a plan. thank you


Thanks @seancorfield , yeah I already use the repl all the time, and what I was looking for was exactly what @noisesmith mentioned : to be dropped into the context and be able to access locals and stack frames.