Fork me on GitHub

@noisesmith thanks for your answer earlier.

Mikko Nylén09:01:28

I'm building a Clojure wrapper for a Java library and I'm wondering how I should add a dependency on that library from my wrapper. The thing is the Java library depends on a Java Agent JAR of the same version to provide the implementation through instrumentation. The library's public api is likely to stay the same, so my wrapper should work with any version of the library, but a specific library version can work with only specific version of the java agent. What are the possible approaches here? Adding direct dependency to the Java library from my wrapper would work as long as the user goes with the same Java Agent version, but would likely break in the future when new agent versions are released. Of course, then users could exclude the library dependency and provide their own. Or I could release a new version of the wrapper for every library/agent version, but this might prove to be too much maintenance work. Currently I'm thinking of going with adding the library dependency as 'provided', i.e. when including a dependency to my wrapper, users would also need to download the Java Agent (anyway required) and then add another dependency to the library. Any other ideas - preferably ones that don't require a ton of maintenance?


@mikko273 Sounds like New Relic?


We have a wrapper for that internally, and we assume the caller provides both the library and the agent and keeps them in sync. I think that's really the only sane approach here.

Mikko Nylén10:01:10

It's actually Elastic APM. Yeah, I guess it's the sanest approach to have the user provide both.

Mikko Nylén10:01:25

Btw, have you noticed this New Relic Clojure wrapper:


I had not. Thank you. It doesn't look as sophisticated as to what we're already doing (we have tracing via annotations, a bunch of metrics stuff, support for the New Relic Agent and periodic probe/reporting, middleware, and transactions).


Maybe at some point I'll extract ours as an open source project...

Mikko Nylén14:01:13

That'd be cool 🙂 Yeah, it's not very sophisticated, but works for basic needs.

Marc O'Morain10:01:50

Can someone help me find the docs for sorted maps please? The docs at mention them, and say that they “are, well, sorted”. I want to know how they are sorted - by key, value, insertion order, etc.

Marc O'Morain10:01:16

I think the flatland ordered meal does what I need (I want to maintain insertion order). But my question is about the docs - I don’t see any mention of how a map is sorted if no comparator is supplied.

Marc O'Morain10:01:53

Nor mention of what the comparator should return. Or what args are passed to the comparator.

Mikko Nylén11:01:35

I think it's ascending order by key by default. The args are a and b - i.e. the objects to compare.


@marc-omorain comparator is a java concept. It returns -1, 0 or 1. To keep insertion order, you should use a specific lib called "orders"

Marc O'Morain11:01:05

Thanks for the help. To be clear though, I’m wondering if there are docs on this.


Clojure's default comparator, if you do not supply one explicitly, is clojure.core/compare


There is the output of (doc compare) that describes it briefly.


I haven't yet found any explicit lines in doc strings saying that, but in brief checking of source code it appears to be true.


I have written something a few years back, but not published in a well-known place, necessarily:


I am considering copying that to page on the behavior of clojure.core/compare


I should have pointed you here first -- it does explicitly document that compare is the default comparator, and has some notes on its behavior:


Continuing with my hopefully brief obsession, I have just updated the sorted-map entry on to make the answers to some of your questions hopefully quick to answer:

Mikko Nylén11:01:27

I can't find anything comprehensive. 😞 There's this: which gives tiny bit insight on the default comparator at least.


Anyone have any examples of idiomatic Clojure libraries that wrap external APIs?

Marc O'Morain13:01:32

The new cognitect AWS wrapper?


Can anyone suggest a way to take screenshots of a webpage in clojure/java? I'm looking for the simplest solution possible, preferably with no extra dependencies.


not exactly what you're asking for, but is clojurescript a possibility?


I've tried that with poor results (compared to how things actually look in a real browser).


If you're open to using an external service is quite good. We've snapshoted pages with some crazy js/svg and all sorts of constraints (timers etc) with it


@danielstockton I think the JavaFX WebView has a takeSnapshot or snapshot function you can use


Thanks, I'll take a look at that 👍

Mikko Nylén19:01:21

@danielstockton If you're open to using external paid service, I would recommend url2png. It works pretty well and has some nice features, such as it allowing you to include custom css file just for screenshotting purposes. For a DIY solution, I'd probably go with something like headless chrome to get as close to desktop/mobile rendering as possible.