This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-09
Channels
- # aws (4)
- # bangalore-clj (1)
- # beginners (94)
- # boot (19)
- # cider (42)
- # cljs-dev (21)
- # cljsrn (4)
- # clojure (142)
- # clojure-austin (10)
- # clojure-greece (25)
- # clojure-italy (14)
- # clojure-russia (14)
- # clojure-serbia (13)
- # clojure-sg (6)
- # clojure-spec (74)
- # clojure-uk (69)
- # clojurescript (236)
- # consulting (1)
- # cursive (26)
- # data-science (6)
- # datascript (2)
- # datomic (31)
- # editors (5)
- # emacs (24)
- # funcool (5)
- # hoplon (8)
- # jobs-rus (1)
- # luminus (12)
- # lumo (17)
- # off-topic (90)
- # om (45)
- # onyx (5)
- # pedestal (2)
- # powderkeg (12)
- # protorepl (2)
- # re-frame (30)
- # remote-jobs (2)
- # ring-swagger (17)
- # rum (46)
- # slack-help (1)
- # test-check (2)
- # yada (62)
do protocol impls have the same problem as multimethods where recompiling doesn’t necessarily cause your new impl to be used?
Is there a way to deepcopy an IPersistentMap? (I understand that that’s pointless; but I’m benchmarking and I want to make sure no part of the benchmark is cheating with identical?
)
@Ivh, one could argue that it isn't cheating to do 'identical?'
unless you're doing something crazy like putting atoms deeply nested inside maps, and trying to diff that, which I don't recommend.
actually that doesn't make sense at all....
@Ivh why would x != x
if x is x
?
as long as it isn't floating point 😆
@tbaldridge I agree it’s a valid optimization, but it also makes my benchmarks useless, because in practice that will never be true for my inputs
Right, but wouldn't the best option be to mutate the leaves of the tree so that everything is different?
Mutate=update
When I've written diffing engines like this in the past, I've gotten the best results by crafting specific tests for what I'm trying to test. For example: going from a nil to a nested map. A nested map to a nil. Diffing two maps that are mostly the same, diffing two maps that are not the same at all, etc.
post-walk with identity as the function should effectively be a deep copy (at least for all the types that walk/post-walk destructures then reconstructs)
I don't see why we aren't able to leverage the versioned internals of persistent data structures for diffing. We'd have the fastest diffs on the market 🙂
oh, I guess that's not for an arbitrary diff. I was interested in it for incremental diffs.
how so? equality checks already shortcircuit true for identity for our collections
I basically want a copy of the last inode (or whatever it is called) in order to update a remote object, at the same time.
@noisesmith I'm pretty sure post-walk optimizes for identical? as well
my idea being that it would fill in the data, but construct new containers
if you wanted to benchmark something and not let it short circuit
actually nvm...it doesn't https://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj#L35
(if your real case would never see identical objects?)
I'm reading through the boot-new
readme (https://github.com/boot-clj/boot-new). I'm reaching the following conclusion:
a boot-template
can only be used with boot/new
, but a leiningen-template
can be used with both lein new
and boot/new
. Is this correct?
What are people using here for monitoring exceptions in their Clojure applications? (if this question belongs to another channel, please say so)
we use sentry, it’s great @borkdude
both are good options, it all depends on what resource you have to maintain your own server(s) and if that ends up costing more than the hosted plans
we pay for hosted @borkdude. the less we have to manage ourselves, the better. time is not replaceable, money is 🙂
https://github.com/sethtrain/raven-clj + https://github.com/cljsjs/packages/tree/master/raven
so, I am working on a Clojure webapp that does not control it’s own servlet container. Is it fairly common to embed nrepl in such an app (in dev environments only) to avoid the long feedback loop of redeploying into the container?
and would be interested in any gotchas people have experienced with this kind of setup…
For development, yes.
going a step further, I will probably exclude the dep from my profile when building for production. So then I will need to resolve the namespace symbol and require it at runtime if it is there
cpmcdaniel: you can use resolve, but that only finds things that have been properly required - what I find works is to check the deployment environment, and require conditionally (inside -main) if the environment matches. If you want it to strictly be based on presence or absence of the dep you could conditionally call require based on whether
finds the file for the namespace (io/resource "my/ns/core.clj")
will be nil if it isn’t on classpath.
ah, thanks
that’s better than catching ClassNotFoundException
thanks @stuartsierra - always helpful!
@cpmcdaniel I do that all the time.
Is it possible to ‘tap’ into a protocol method. I’d like to have ‘around’ wrapper for all such method calls.
e.g there is a protocol clojure.spec.Spec
which has conform*
method defined.
Some of the conform*
implementations call conform*
recursively. I’d like to wrap my logic around each such call.
well, if defprotocol would be implemented with monads and provide open for that then yes. My question is more practical than theoretical tho.
@lambder I'm not sure, but I'd first start with a simple experiment, trying to reify
some instance of clojure.spec.Spec
and override the method in question, calling back to the original -method
after doing my logic. That's just a hunch though. Haven't tried, personally. I usually just override a method.
Once you have it working with reify
you can bake it in to something more involved with deftype
or extend-type
if you want.
cloc src
17 text files.
17 unique files.
0 files ignored.
v 1.68 T=0.07 s (260.6 files/s, 25443.3 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
ClojureC 8 155 39 877
Clojure 5 96 0 354
ClojureScript 4 20 4 115
-------------------------------------------------------------------------------
SUM: 17 271 43 1346
-------------------------------------------------------------------------------
do I have way too many files? 1346 lines over 17 files seems too many fileswould combining some of your files make your code structure more legible and easy to follow?
All, I'm trying to use the Monger driver for MongoDB to connect to the MongoDB Atlas service. The service is running MDB v3.4 and requires the 3.4 version of the Java Driver. Monger hasn't been updated to use the newer Java Driver yet. I would like to change the Monger dependency to use 3.4 instead of 3.3, but don't have a clue with Leinigen and Clojure. In Node/NPM land, I would to a npm install --save <lib name> of the lib, then go the local project copy under node modules and modify it, and force it to get the new deps. How can I do this with Lein/CLJ? Thx!!!
I've never really felt like I completely groked the right way to deal with atoms and refs together in some instances. I have a state-atom for a component that holds many things. Sometimes I need to update one of those things in the atom as part of a transaction. So I put a ref inside the atom. However this feels like it is probably wrong. Any thoughts on how to properly organize something like this, since I don't really want the data in the ref to be held outside the context of the atom?
dealy: wouldn’t it be simpler to use a ref if you need to coordinate with other refs? If it’s about the extra boilerplate of needing to alter it in a transaction that’s a relatively easy function or macro to write
something like rswap!
which calls dosync with an alter inside
but having a ref inside an atom is a ripple too isn’t it? it just seems weird to nest like that
oh no it doesn’t exist, I am just saying it would be simple to write
it’s would be a one liner basically
given that alter inside dosync does what you want
it is weird, that's why I felt uneasy about doing it, by ripple effect I meant that I have these atoms and swaps in alot of places which need to be converted to dosync/alter
right, right - my suggestion was to make something that is just like swap! but for refs - also I’m surprised to hear you have so many atoms, but that’s probably a whole separate conversation
@linicks -- in leiningen
you need to specify the explicit dependency on the Java Driver above your reference to monger
that should take care of it (provided, of course, that it's source compatible with monger)
@ghadi Awsome; That worked! There was only a very small change to the driver in terms of compatibility (http://mongodb.github.io/mongo-java-driver/3.4/upgrading/). I definitely have allot to learn in the CLJ space, but I'm really liking it so far. Thanks for the help!!!
I haven't looked at clojure.tools.trace in a long time, it would come in handy today, Is it still the "cool" way to build call-graphs?
`(quote (foo bar))
will do that I thinkwait, ` would add namespaces to foo and bar
(ins)user=> (defmacro foo-bar [] '(quote (foo bar)))
#'user/foo-bar
(ins)user=> (foo-bar)
(foo bar)
@noisesmith : thanks! I was trying (list quote ... ) and that did not work
the longhand version of what I had would be (quote (quote (foo bar))) the shorthand would be ‘’(foo bar) but I think the example provided is the best balance of hte two
since there are no channels for yourkit or profiling I’ll ask here: my yourkit mongo usage profiling is showing short bursts of network usage followed by what looks like extended usage of CPU - is this normal? should I look for something in my code that is too CPU heavy, or is it a mongo thing, or an artifact of how yourkit shows tracing that the full network io timeperiod isn’t shown properly?
I should probably just go do some microbenchmarking of the nearby code…
[(count lst) (count (into #{} lst))] <-- okay, I now have duplicates; what is anelegant way of finding the duplicates ?
you can use distinct, that just uses an atom under the hood
oh, sorry, misunderstood
yeah, group-by identity
or just frequencies
then you can filter by val > 1
@qqq There's also frequencies
https://clojuredocs.org/clojure.core/frequencies <-- interesting
Bingo hehe
Oh hey guys, did you know about frequencies
?
frequencies is one of the most frequent things I see my coworkers implement from scratch not expecting it to exist in the language
nor would group-by, or distinct, or filter
on the other hand, lots of string functions in c stdlib that we don’t have in core
my suspicion is that this is intentional
I'm pushing this towards #off-topic; so I should stop now. Thanks for insight on frequencies
🙂
(def strfry (comp (partial apply str) shuffle seq))
group by returns a map of the type of result of f, mapped to vector of the input type of f
@qqq when has group-by returned a vector?
see, that’s a hash-map
btw (fn [x] x) is identity
I think I epxected there to be a function named 'id', it did not exist; then I never tried identity
Trying to understand why doall
doesn’t realize my clojure.lang.LazySeq
in this statement:
(def cr (doall (map first [[401 "Unauthorized"]
[402 "Payment Required"]
[403 "Forbidden"]
[408 "Request Timeout"]
[502 "Bad Gateway"]
[503 "Service Unavailable"]
[504 "Gateway Timeout"]])))
(type cr)
clojure.lang.LazySeq
mapv
instead works fine of course…
doall doesn’t change the type
it just guarantees the data is realized
a realized LazySeq is still a LazySeq
ah ok, so contains?
isn’t supported on that type period
no, because it’s not associative
thanks!
(ins)user=> (let [s (map inc (range 10))] (realized? s))
false
(ins)user=> (let [s (doall (map inc (range 10)))] (realized? s))
true
realized? only tells you about the head of the list of course