Fork me on GitHub

Hi everyone i'm somewhat of a newbie and wondering about database migrations. I have been spoiled with migrations using django which if you aren't familiar are pretty nice. I don't expect there to be as rich an option in clojure but can I get some opinions of some of the options like ragtime/joplin/migratus or other options?


@dfcarpenter I’m a fan of Migratus. The dude that wrote and maintains it, Yogthos, just builds incredibly good stuff. He’s also fairly active on Slack if you ever need any help. It’s the default for the Luminus framework (, another one of Yogtho’s creations. It works well. It’s efficient. It’s stable. And most importantly, it’s well documented.


It also comes with a Leiningen plug in, which is nice


I never got into Joplin or Ragtime because I found and stuck with Migratus via the Luminus template, so I can’t say anything about them.


However, their creators (Juxt for Joplin, Weavejester for Ragtime) are also very reliable, well known, and make great stuff!


Hi I would like to use this as a library locally. Is there any clear information online on how to do it.


Basically want to create the package and then add it as a depenency


hey guys, what is your favorite clojure(script) IDE? I've been playing around mostly with IntelliJ + Cursive and it is quite nice, but heavy. any other things I should check out? One thing i feel like is quite necessary is the IDE doing all the indenting and parenthess/bracket management for you, which feels like it speeds up coding by an order of magnitude


I use VS Code with two plugins: “Clojure” - Andrey Lisin - for repl, autocomplete, docs, and evaluation, and “Parinfer” - shaunlebron - for automatically managing my indentation/closing parens.


@noman I really like atom with these plugins: - proto-repl - let's you evaluate code in your IDE, awesome for interactive development -parainfer: Automatically infer closing parens based on indentation. An essential tool for writing Lisp code. proto-repl allows you to run a repl as a split tab, and loads your entire project, allowing you to access all your methods in all your defined namespaces. Links:


are clojure people all using emacs or something?


no, lots of people use other stuff. I use Vim, for instance.


I can’t imagine writing clojure without it these day, and it is available for many editors


clojure is the best thing that's ever happened to me


I've used lein install but it's not ended up in my local Maven repository. How do I make sure it ends up there and require it as a dependency into my project


You want to use a modified version of that lib in another project?


lein install is the most reliable method - make sure you ar e looking for the right project name and version - checkouts don’t even work without running a proper lein install first


@noman Clojure people are using all kinds of things. Emacs, Vim, Intellij+Cursive, Lighttable, Atom…


nice thing about Clojure is that you can pretty easily do rudimentary support for it into any editor since it’s a Lisp and Lisps are trivial to parse. Also, due to nREPL and socket REPL it’s really easy to integrate all that to a functional REPL and when you have that you already have a pretty good development environment


paredit is easy to implement on top of S-expressions and since everything is so easy to parse it’s not that hard to implement stuff like automatic require inclusion and so forth


I seem to have forgotten how do you get the offending source file, when you get a java.lang.RuntimeException: EOF while reading without any of your sources showing


Hello everyone, using pprint to pretty print a json, I'm getting this:

when it suppose to indent as this:
is there any formatting control to turn it into the correct formatting?


it’s interesting you say that the first one would be incorrect since I find that much more readable


I know this is a matter of interpretation. First one is correct for clojure, not for json as we see around


that's why I'm looking for a modifier


to avoid creating my own pprint method


I think the latter isn’t correct either if you look at the “JSON out there”


    “A”: {
      “B”: “0001”,
      “C”: “0002”


that would be more what I would expect to see from a random pretty printed JSON example


but this just proves the point that there is no such thing as “correct” JSON pretty printing


well, you have a point. Even so, I need to print the same output of command jq which does as you described(I did something wrong on my second example, it suppose to be like yours)


do you know how?


I might be under/over-thinking something. I'd like to make a mount state that, when started, makes a GET request every five seconds. This works:

(defn get-loop []
  (loop []
    (future (Thread/sleep 5000)
            (-> (http-request-for-blah)
but I don't know how to write a mount/stop for this, i.e. kill a looping future. What's the idiomatic way to do a task every period-of-time, and be able to stop that task with another function?


@mfm I don’t know if this is considered idiomatic but here’s one way to do it:

(defn get-loop []
  (let [running (atom true)
        stop-fn (fn [] (reset! running false))]
      (loop []
        (when @running
          (Thread/sleep 1000)
          (println "doing stuff")

(defstate foo
  :start (get-loop)
  :stop (foo))


looks good to me, @schmee! thanks. makes sense.


FWIW the java.util.concurrent.ScheduledExecutorService is probably the most efficient and precise way to do this


I am interested, @donaldball! thanks. i'm not familiar with the effect on the JVM of having (future (loop (Thread/sleep ...))), so i am also interested in an efficient implementation.


You’re dedicating a thread that’s idle much of the time, and, particularly if your “doing stuff” takes meaningful time, your actual period is going to be longer than stated period. None of this may matter even a little bit for your use case, of course 🙂


stopping single threads from the outside within the jvm is error prone, but future-cancel uses the most reliable method available - it can cancel paused io or sleeping threads at least


if you care about thread count and overhead of sleeping threads, you could use a go block with async/timeout and launching the side effecting thing in async/thread


waiting on N timeouts only requires the small number of threads core.async allocates on startup (nproc*4+2 iirc)


with something like

(go-loop []
 (<! (timeout 5000))
 (println "stuff)
how do i stop the go-loop?


there’s also ScheduledThreadPoolExecutorService which is wrapped by at-at and is meant for periodically running tasks and has a straightforward api for stopping individual tasks


@mfm the usual idiom in core.async is to use a channel that gets closed when you want the loop to exit


also you need to put your stuff (whatever replaces the println) in async/thread if it uses any noticeable execution time (<! (async/thread …)) - because otherwise you can easily starve core.async and halt all async code


so we end up with

(go-loop []
  (let  [[_ continue?] (alts! [(timeout time) cancel-chan)]
     (when-not (= continue? cancel-chan)
        (<! (async/thread (do-stuff)))


if cancel-chan is not closed, it does the thing, if cancel chan is closed it returns nil before the timeout completes, and is passed as the channel returned by alts! which is then detected etc.


but returning a future and then calling future-cancel later is fine if you are OK with the overhead of a sleeping thread per recurring thing


wow. that is interesting to look at.


future-cancel will stop things that sleep


thanks. i'll try this


you can leave the <! off of the async/thread call if blowing up in that call shouldn’t stop the loop and you don’t want to add execution time to the timeout time (but consider what happens if you repeatedly do the call and it throws exceptions every time, or if the call does something that accidentally takes longer than the timeout time leading to snowballing resource usage)


core.async makes async easier but parallelism and async are intrinsically complex


here’s a situation i’m in, and some code i’ve written - is there a better way to express this?


i’ve got a grid, which is a 2d vector of integer-or-nils


and a move, which is a set that looks like this


#{[[5 7] 4] [[7 7] 5] [[8 7] 2]}


it’s a series of [[x y] value] pairs


and so i’d like to apply each of the parts of the move to the grid


and i’ve just got this straightforward reduce:

(reduce (fn [grid [[x y] value]]
                                 (assoc-in grid [x y] value))


is that reduce the best way of expressing this, or is there some obvious better / more natural way that’s eluding me?


that reduce looks fine to me - you don’t need to destructure [x y] btw - you could change it to [grid [coords value] (assoc-in grid coords value)


oh good call


cool, thanks for the sanity check + advice!


you could change that function definition to (partial apply assoc-in)


(reduce (partial apply assoc-in) grid move) looks great to me 😄


niiice, i’ll try that


that’s exactly the sort of thing i was looking for


i’ve somehow temporarily bricked my intellij since asking the question, but once i get things working again i’ll try that out and i’m sure it’ll be perfect - thanks again! 🙂


(it works!)


Hey, spec/namespace question. I have a bunch of specs defined in a file /src/foo/specs.clj but can’t figure out how to reference them in /src/foo/resolvers.clj


What am I missing?


Never miiiind … 😄