Fork me on GitHub

Is there an easy way to determine how much time each namespace is contributing to a require? I have a require that is taking a long time and I suspect some transitive require has a slow top-level form

Alex Miller (Clojure team)03:08:24

you can add :verbose to a top-level require and it will print for each one it loads transitively

Alex Miller (Clojure team)03:08:33

might be able to just spot it from watching

Alex Miller (Clojure team)03:08:44

is core.async in there? if so, that's it :)


Thanks! Will try in the morning. I’m not sure if it’s in there

Silenced Ego06:08:54

How does clojure handle dynamically extending types to implement new protocols? This is impossible to do in java. Does it compile somehow to branching code that emulates the behavior, or does the JVM have dynamic type extension built in?


the first one, IIRC, but it uses a lot of perf optimizations


I do not have this process terribly well understood myself, but roughly there is a map for each protocol (and perhaps each protocol function) that you define, and this contains a cache of the correct function to call based upon the class of the first parameter. These get updated when extend-protocol and/or extend-type are called (perhaps one or two others I am forgetting). There are special (but reasonably common) cases where the Java method call lookup machinery is enough, e.g. if you define the protocol function implementations when you call deftype.

Alex Miller (Clojure team)12:08:07

That started right - a protocol is a map of types to function impls. The caching happens per call-site though, not in the protocol


what's a good way to check if something is amenable to adding metadata?

user> (instance? clojure.lang.IObj list)
user> (with-meta list {:a 1})
UnsupportedOperationException   clojure.lang.PersistentList$Primordial.withMeta (


instance? IObj is the correct way


list is the odd one out, but I mean nothing prevents you from (reify clojure.lang.IObj) aswell


no, I want to reject this, but this method doesn't work


there's no static way to go about it


so try / catch... ?


(reify clojure.lang.IObj (withMeta [_] (throw (Exception.)))


how can you figure out this throws


yeah try catch I guess

Alex Miller (Clojure team)13:08:56

in your code above, is list literally the list function? or is list bound to an actual list instance?


it's literally the list function


is there a database that works like clojure's data structures? (keeping track only of the differences)

Alex Miller (Clojure team)14:08:07

(to some degree, really more complicated than that)

Juliano Pereira Lima16:08:56

what is the best way to receive a file via stdin in a clojure console application using leininger?


Hi! Anyone here using newrelic with clojure?


@lucelios Yes, we use New Relic heavily in production with Clojure backend processes. Do you have a specific question?


Hi Sean! We are having difficulty with cross-application traces... We use aleph.http for requests and New Relic headers are not being added automatically. Did you have to experience something like that?


New Relic's support for non-mainstream HTTP clients and servers is less than stellar. We started out with http-kit as our server and after various tweaks and working with NR support for a while, we gave up and switched to Jetty instead (and, even then, we had to test a few versions to establish which ones they fully supported).


For requests, we use a mixture of clj-http and http-kit (client). Both of those seem to work fine with distributed traces and tracking external services -- but it's entirely possible NR doesn't know how to track HTTP requests made with Aleph (and so it doesn't add headers automatically).


hmmm I see.. Do you know a good way of adding X-NewRelic-App-Data header into the response?


I'd have to know quite a bit more about your app -- how the services are built and how they're called, since you're going to need to do this manually. I've never used Aleph.

Silenced Ego23:08:52

Does a Go implementation of Clojure make sense given they both use CSP, and if that's possible could that raise clojure's popularity?


@thomasskinner76 I doubt that a Go implementation would be anywhere near as widely used as the current JVM-based version...


clojure would perform very poorly with go's vm, clojure really demands a lot from the GC


Is Go's GC far behind the JVM's? I'd greatly appreciate any resources for me to learn more about this.


it's a different style of GC, and it doesn't handle the specific case of massive amounts of short lived objects the way the JVM does


for idiomatic Go code, it works very well if tuned correctly for your domain, but it doesn't really match the way idiomatic clojure code uses local immutable values that quickly leave scope


I mean, go code is usually faster than java, but that's more due to mechanical sympathy than advanced vm tech

💯 4

and clojure opts out from that kind of mechanical sympathy - trading it for the semantic guarantees of immutables


(and core.async implements "CSP" by rewriting code at the Clojure level so a "Go implementation of Clojure" wouldn't address that)


in fact if CSP was in clojure's core core.async would probably be less awkward - not that we should do that or anything

Alex Miller (Clojure team)23:08:45

We have actually talked about making the analysis parts of the compiler available in a way such that core.async could use it rather than reimplementing it in a macro, which would also make it a lot less awkward

Alex Miller (Clojure team)23:08:04

But prob not something happening soon


that would make core.async much nicer

Silenced Ego23:08:26

that's interesting. What does Go's VM lack for clojure that would be needed? It somehow has better GC?


Go has a mediocre gc, compared to the jvm - specifically in terms of performance. Clojure's usage of immutable data creates a lot of short lived garbage.


supposedly light weight threads as a vm feature are coming to the jvm, but I will believe it when I can deploy it

💯 4

go is also largely a static runtime, which makes using a language with dynamic code loading annoying

👍 4
Silenced Ego23:08:25

Oh I see. So the performance of Go which is generally supposed to be very good, is partially only that way because people use mutable state, instead of programming functionally. Is that right @noisesmith ?


(also concurrent ml's model of synchronizing on events is a super set of go's channels, and way cool)


@thomasskinner76 it might be more straightforward to say that the jvm is unique among vms (or relatively unique) in having a short term garbage collector that allows operations on immutable data structures to be performant


I have an abandoned lisp that compiled to go source code that I was working on because I was interested in go's concurrency primitives, which I stopped doing work on around when core.async was released