Fork me on GitHub
#clojure
<
2018-04-06
>
soulflyer00:04:45

@me.lucas.sa I use monger, does everything I need, and it has a cool homepage/user-guide.

seancorfield00:04:08

@soulflyer @me.lucas.sa as the maintainer of CongoMongo, I'd heartily recommend Monger 🙂

seancorfield00:04:34

Monger is better documented, better maintained, has more features, tracks updates to the MongoDB Java driver better.

seancorfield01:04:30

CongoMongo has hardly any users left -- most of them have abandoned MongoDB completely (something we are in the process of doing, slowly migrating data out of MongoDB and into MySQL/Percona mostly).

lsantanna01:04:35

interesting, why are you guys moving away from MongoDB?

tbaldridge01:04:06

Isn’t everyone? (Only half joking)

tbaldridge01:04:40

After this, I couldn’t take mongo seriously https://aphyr.com/posts/284-jepsen-mongodb

😮 4
12
tbaldridge01:04:40

“To recap: MongoDB is neither AP nor CP. The defaults can cause significant loss of acknowledged writes. The strongest consistency offered has bugs which cause false acknowledgements, and even if they’re fixed, doesn’t prevent false failures.”

seancorfield01:04:23

@me.lucas.sa Lots of reasons. Performance at scale is expensive to maintain is probably the most straightforward one.

seancorfield01:04:23

But there are lots of problems with MongoDB. I attended a lot of MongoDB Days (one day conferences) and listened to company after company talk about what it took to keep MongoDB running, the difficulties of scaling it (and, in particular, adjusting from one architecture to another).

seancorfield01:04:11

Right now we pretty much only use it for low-traffic, deeply-structured data -- and we're planning to migrate that to MySQL/Percona too, to be honest.

seancorfield01:04:14

We've had instance corruptions, bad failovers, inexplicable performance problems (where we've called in experts and they can't figure it out either).

seancorfield01:04:18

I was very enamored with the promise of MongoDB early on... and at first it was wonderful to use... but then things get harder and harder. I would never recommend it to anyone at this point.

lsantanna01:04:05

@seancorfield this is a really good feedback, thanks. we have been using mlabs since 2016 and we don’t have any problem, but now we have a requirement that we will need to host it in our infrastructure and we are a little worried about it. In our case a document database makes total sense. what would you recommend for this scenario?

lsantanna01:04:33

@tbaldridge thank you for the link sir, i will research a little about it.

seancorfield02:04:05

@me.lucas.sa We use mLabs too -- have done for years. They're really good. Much depends on your data size and performance requirements. We had 500M documents in some collections and well over 100M in a few others. We're down to just a few millions documents spread across two databases now tho'...

seancorfield02:04:54

What sort of queries do you need to run across your documents? Is it just a few fields? Are there special operations you need to perform that MongoDB is specifically good at?

seancorfield02:04:41

Most SQL DBs have some sort of JSON document storage now. Several support JSON queries as well. I think it really depends what you actually need to do at a "document" level rather than a "field" (or column) level.

gklijs09:04:52

I recently looked as postgres in relation to json, and you can even get/set/deleted fields on a stored json.

callum07:04:18

How might I go about debugging a non-terminating Clojure instance? I’ve been experiencing an issue occasionally in my project where I run lein midje, there’s an exception during the tests, and the process just hangs once it’s done with the test suite. I don’t get this issue when running the tests via the REPL with (load-facts :all). Can I interrogate the instance somehow?

trptcolin17:04:11

jstack PID / jcmd PID Thread.print will show you stack traces of where all the threads are. i did a demo awhile back of some of these command-line jvm tools here: https://www.youtube.com/watch?v=iFSUj9i7uio

andy.fingerhut09:04:21

@callum Does it hang for more than a full minute? There is a known issue where calling future, or one of several other Clojure functions, causes a JVM daemon thread to be created, such that it causes the process to hang for about 60 seconds before it is terminated and the process then exits. For more details, see the comments in the examples here: http://clojuredocs.org/clojure.core/future

Maris10:04:55

what is the best clojure library for writing hadoop tasks?

sveri12:04:20

Hi, how do people manage namespace collision between .clj .cljc and .cljs files in a project that uses all three? Is there an idiomatic solution?

andre.stylianos13:04:59

namespace collision in what way?

sveri15:04:13

Let's say I have a namespace foo.bar in both the cljs and cljc source folder and want to include the cljc one in one of my cljs sources. How does the clojurescript compiler decide which namespace to include. It's the same question for clojure.

andre.stylianos15:04:48

Ah, I see. Never had that issue as we usually only have one of the cases, either clj + cljs or only cljc.

andy.fingerhut22:04:58

@U0677JTQX I do not consider myself the final authority on this question, but I believe that the design decision when cljc was added to Clojure/JVM was that if there is a .clj file for a namespace, anywhere in your Java classpath, and also a .cljc file for the same namespace anywhere in your classpath, the .clj file will be found and loaded in preference to the .cljc file.

andy.fingerhut22:04:42

If that is still the case (and I believe it is), then I don't see a very good way for a .cljc file to use a .clj file for the same namespace. For different namespaces, no problem.

andy.fingerhut22:04:46

If that design decision was also used in cljs, then there is likely no way to do what you are asking, and you should probably avoid trying to do that.

sveri06:04:03

Thank you very much, that's basically what I assumed. My solution is to add a cljc package to the cljc namespace.

sveri06:04:15

It's just good to know.

qqq12:04:48

I have a legacy Java app. I have started a tools.nrepl from it. I can connect to this nrepl from Emacs. Now, I also need a way to handle dependencies. Is there a wa yto load boot as a LIBRARY in this nrepl, so I can use boot to handle my dependencies ?

nha13:04:12

@qqq maybe ask in #boot as well

sveri15:04:13

Let's say I have a namespace foo.bar in both the cljs and cljc source folder and want to include the cljc one in one of my cljs sources. How does the clojurescript compiler decide which namespace to include. It's the same question for clojure.

theeternalpulse15:04:13

Is specter the most scalable way to handle manipulating nested objects. For example in quil my state for now has one entity, and this is how the update looks like.

(defn update-scene [state]
  (let [star (:star state)
        moved-star (move-star star)]
    (if (hit-bounds? moved-star field-size)
      (let [star-reversed (update moved-star :vec (partial map -))]
        (assoc state :star star-reversed))
      (assoc state :star moved-star))))
It looks very messy after all is said and done and eventually there's going to be different types and multiple manipulations/checks/etc. Is there something more scalable than doing it like this? I've only heard of specter but wondering if there is something else (tool or strategy) more suited for this kind of task

pesterhazy15:04:40

You can rewrite that to be more readable:

(defn update-scene [state]
  (update state :star
          (fn [star]
            (let [s (move-star star)]
              (if (hit-bounds? s field-size)
                (update s :vec (partial map -))
                s)))))

pesterhazy15:04:05

or even

(defn update-scene [state]
  (update state :star
          (fn [star]
            (let [s (move-star star)]
              (cond-> s
                (hit-bounds? s field-size)
                (update :vec (partial map -)))))))

pesterhazy15:04:53

or even

(defn check-hit [s]
  (cond-> s
    (hit-bounds? s field-size)
    (update :vec (partial map -))))

(defn update-scene [state]
  (update state :star (comp check-hit move-star)))

pesterhazy15:04:10

sky's the limit 🙂

🎆 4
curlyfry15:04:59

@theeternalpulse Your update-scene function could then become something like this when you have more entities:

(defn update-scene [state]
  (-> state
      (update :star (comp check-hit move-star))
      (update :some-other-thing other-thing-fn)
      (update :yet-another-thing .....

👍 8
ajs15:04:29

am I imaging this or is clojure 1.9 significantly faster, both in startup and runtime, than 1.8? I just upgraded and things feel quite different

nathanmarz15:04:26

@theeternalpulse with specter that's:

(multi-transform
 [:star
  (multi-path
    (terminal move-star)
    [#(hit-bounds? % field-size) :vec ALL (terminal -)])
  ]
 state)

👍 8
theeternalpulse15:04:45

oh thanks for the suggestions.

nathanmarz15:04:51

also doesn't convert that field :vec into a lazy sequence

theeternalpulse15:04:08

does specter handle conditional updates or you have to do that before you initiate a transform?

nathanmarz15:04:43

yes, that code is doing a conditional update

nathanmarz15:04:19

a function inside a path stops navigation unless it resolves to truthy

pesterhazy15:04:57

that specter snippet is nice!

pesterhazy15:04:05

impressive stuff

theeternalpulse15:04:08

Interesting, I have to look over the specter api. Also I just realized you're the creator lol.

nathanmarz15:04:30

there's a handy cheat sheet now so you can see the different kinds of navigators that come with specter https://github.com/nathanmarz/specter/wiki/Cheat-Sheet

theeternalpulse15:04:46

sweet, thanks for the suggestions @nathan @curlyfry @pesterhazy

chouser19:04:17

The doc string for alts! says "ports is a vector of channel endpoints, which can be ... a vector of [channel-to-put-to val-to-put]" and "Returns [val port] of the completed operation", but in the case of a [ch val-to-put] it appears provide only the channel as port, not the [ch val-to-put] pair. It seems to be the doc string is incorrect or at least misleading. Thoughts?

hiredman19:04:38

what version of core.async? I've some code that does alts! with puts and takes and immediately destructures the results as [val ch], and it has never thrown an error because it couldn't destructure the value

hiredman19:04:49

Clojure 1.9.0
user=> (require '[clojure.core.async :as async])
nil
user=> (async/<!! (async/go (async/alts! [[(async/chan 1) 1]])))
[true #object[clojure.core.async.impl.channels.ManyToManyChannel 0x45ac973 "clojure.core.async.impl.channels.ManyToManyChannel@45ac973"]]
user=> 

chouser19:04:23

yeah, that's not the bit I'm talking about. I'm sorry, it's subtle and confusing. I'm referring to the port bit of the return pair -- is it a port or a channel?

hiredman19:04:50

looks like the channel to me, and the code I have after the destructure does a cond comparing the returned channel with the passed in channel using =

chouser19:04:11

right, that matches my experience. So I would expect the docstring to say "Returns [val chan] ..." but it actually says "Returns [val port] ...". So that's incorrect, right?

hiredman19:04:51

well a channel is a port

hiredman19:04:26

the docstrings for >! and <! also refer to ports

chouser19:04:25

so what is [channel-to-put-to val-to-put]? From earlier in the docstring, I thought that was a port.

hiredman19:04:27

uh, it is a pair of the channel(port) you want to maybe put to, and the value you maybe want to put to it

chouser19:04:43

right, so is that pair a "port" or a "channel"?

hiredman19:04:57

a channel is a port

chouser19:04:14

ok, so that pair is neither of those things and yet is supposed to be supplied as an item in the parameter named ports

hiredman19:04:47

there are two protocols ReadPort and WritePort, and channels implement both

quadron19:04:56

how can I inspect an existing clojure type? say I want a list of all functions that can work on a type?

hiredman19:04:30

so a channel is both a read port and write port, I think the docstrings refer to ports when they mean it only uses the channel as either a read port or a write port (confusingly without specifying which)

hiredman19:04:35

I usually just completely ignore the notion of "ports" because while it is sort of a thing, I think it is far more of a thing in the heads of the authors of the library than it is in the actual library

hiredman19:04:56

so every channel satisfies both ReadPort and WritePort (so it is a port), it is possible that a "port" if you ever come across one only satisfies one of those, so they are not entirely synonyms, but in practice they are

hiredman19:04:38

there is a #core-async channel too btw

noisesmith19:04:17

@veix.q5: you can use clojure.reflect to see all of a thing's methods, or supers to see everything it implements

noisesmith19:04:18

that said, many clojure functions accept anything that seq works on (which includes things like String where nothing about String itself would tell you seq would work)