Fork me on GitHub

I found it surprisingly hard to translate a Leiningen deps vector to a tools-deps map. Specifically ran into troubles with getting too much help with printing name-spaced maps. (I think my tooling might play a role here, but anyway. Since this strange hack did the job for me, I let it. But I also can't stop figuring about what a proper way would be...

(into {}
      (->> lein-deps
           (map (fn [[d v]]
                  [(if (re-find #"/" (str d))
                     (symbol (str d "/" d)))
           (sort-by first)
           (map (fn [[d v]]
                  (binding [*print-namespace-maps* false]
                    (prn d {:mvn/version v}))))))
Some of the Leiningen deps tuples have :scope which I don't really know what it is about so I'll try with just skipping that. 😃

Alex Miller (Clojure team)12:03:44

Deps doesn't support scopes (I would encourage you instead to make aliases corresponding to different classpath scenarios)

Alex Miller (Clojure team)12:03:33

In Maven, scopes are modifiers that say whether a dep should be included in different classpath scenarios (compile time, run time, test time, and dep publishing time, roughly)

Alex Miller (Clojure team)12:03:00

I would have to look at that code for a long while to understand it but it doesn't seem to understand how deps deals with classifiers either


Thanks! There were no classifiers in the vector I was converting.

Cora (she/her)14:03:26

@U0ETXRFEW I'm not sure if you've looked yet but clj-new can convert leiningen templates to deps.edn and it might have an already fleshed out version of this


The project is created with clj-new, from a Leiningen template, but I didn't see an option to convert it.

Cora (she/her)15:03:00

I thought it automatically converted it


It is quite hard to do, given all the things that can be going on in a Leiningen project.


I have some questions about java inter-op, specifically with ‘builders’. I’m working with the java SDK for a well known business application. In some cases, this works fine:


(builder/to-java MyJavaObject {:quantity 1})


But in others, I get errors like this:


Caused by java.lang.NoSuchMethodException$Builder.<init>()


And then I switch to:


(.build (MyJavaObject$Builder. 1))


and it works fine.


I jump into the jar and poke around, and the Builder looks fine to me (I’m not a Java guy at all) and the whole SDK seems autogenerated, so the Builder classes all look very similar.


I would prefer to use just one approach, preferably the most flexible. Along with that, I’d like to understand what’s going on to cause this error.


@jmckitrick What is build/to-java ? And please consider making a thread, instead of posting many messages into the main channel 🙂.


Sorry, poor Slack etiquette, lol.


I didn’t know that also applied to the OP.



> I would prefer to use just one approach, preferably the most flexible You should stick to interop then, it's the most flexible one. has a bunch of assumptions that must hold true for it to work on a particular builder class. In the case of the error above it assumes that there's a no-arg constructor of the nested class Builder. And seems like it's not the case since you get NoSuchMethodException$Builder.<init>().


@jmckitrick Per the README: > :builder-props -- properties used to construct and initialize an instance of the builder class; defaults to an empty hash map; may have as metadata to provide constructor arguments for the builder instance,

👍 1

Oh wow… I might give that a try.


LMK if you have problems with it (I'm the maintainer). The :builder-props stuff could do with more extensive tests. The metadata approach has more tests around it.


I’ve not done much with metadata… so I need to attach metadata to the :builder-props map?


:builder-props (with-meta {} { [the ctr args]}) is what I think it's suggesting. It's been a while since I last messed with builders.


The value -- the hash map -- lists the properties to be added to the builder (once it is created). The metadata provides a vector of values that are passed to the builder's constructor.


I remember having a hard time finding good examples of builders with constructors in the Java standard library to write tests based on! 🙂

😂 1

I’m glad I asked… I was going to start with the ^ operator/special char/whatever lol


:builder-props ^{ [the ctr args]} {} would work too. I just find with-meta a bit easier to read for constructing values at runtime.


It looks like I need an instance now, so is it safe to say TheClass$Builder is what I need?


Given that’s the pattern I’m seeing throughout the SDK, of course.


I think that worked!~


And no, I did not need a builder. Now I have to make sure I got back what I expect 😉


Are this SDK's docs publicly accessible?


If the pattern is always an inner class Builder then you specify the outer class and let b/to-java figure it out (modulo constructor args above).


See -- it can figure out things for java.util.Locale without any options (first test), if you want to construct the builder object yourself and pass that in that's like test #3 (again, no options). Then tests #2 and #4 are for those two cases but with the options specified explicitly (they just happen to be the defaults).


Hope that clarifies things @jmckitrick?


My code is about half and half right now… some pure java interop, the rest using to-java with a builder successfully.


And yes, thanks for the help! I’ll tinker around with both approaches and pick one


Oh that is one nasty, nasty Java class -- yikes!


Glad I’m not the only one that feels that way, lol.


I am currently getting 3D models from a repository (via git-lfs) through a combination of GitHub’s APIs. I would like to temporarily cache these on the backend (max a couple of days), for frontend and other uses. Have been surveying the landscape for options but it’s been pretty hard to decide on a strategy. I would like to do this on hardware I own rather than use something like AWS. Does anyone have any suggestions for some Clojure-centric strategies to look at? This would be tool-centric and low traffic usecase, I mostly want to avoid having to wait for GitHub API responses.

Ben Sless17:03:16

You can run minio on your own hardware and use the s3 api with cognitect's aws api


And if you already have an endpoint and a function that returns you the models by making a GitHub API request, you can just wrap it with an LRU or any other cache with a TTL (assuming you don't restart your server often).


@UK0810AQ2 Thanks for the recommendation any suggestions on something with a smaller footprint?


@U2FRKM4TW Thanks! Do you know a good way to store 80 - 300 megabyte responses with this strategy? It would have to be on disk I think, as RAM is quite limited at the moment.


There's but I haven't used it myself. There can be other libraries like that - your web search is as good as mine. ;)


Thanks! I have been searching around quite a bit the past week. A lot of resources use some very outdated tools and dependencies, making it harder to evaluate. And sadly I don’t have the capacity to take over and maintain. Mostly wondering if someone has had some explicit opinions about this by chance.


> very outdated tools and dependencies How do you determine whether something is outdated?


I’m sorry but that feels like a needlessly loaded question, not sure if that was your intent.


People often say that something is outdated because that something hasn't been updated in years. In the Clojure world, that often means that the library is stable and perfectly covers its scope - there's simply no more work to be done. That may or may not be the case with fort-knox that I linked above.


I totally understand. Have been using Clojure for eight years : ) Developed a little bit of an eye for figuring out which projects are in what category.


Thanks for your suggestions

Ivan Fedorov17:03:56

Anyone knows projects similar to AirBnB in Clojure? I’m in a project that wants to organise housing for the Ukrainian refugees


Oh great


I am ukrainian


How can I help you?

Ivan Fedorov19:03:35

thanks! are you on github?


Might be worth gathering folks in #clojure-ukraine for this? I don't know if that channel is intended to be multi-lingual (some geo channels here try hard to remain native language only).


Dear Clojurians. I have a question on stackoverflow pertaining reading-off (and then setting back) variables inside of a macro. The question relates to core.async implementation and possibly also to the "fn" form implementation (as they both do tricks with context). If somebody has any insigthys into those areas, I would really appreciate some answers:


Once Java gets virtual threads from Project Loom, none of the code-rewriting macros will be necessary.

🤞 3
Ben Sless20:03:33

@U053XQP4S has a few criticisms of how they're implemented. Revolving mostly around not being able to fork continuations, iirc




first class continuation support is a non-goal


virtual threads are also not serializable, which is required to solve @U4EMCR2BG’s problem IIUC


> first class continuation support is a non-goal it was an explicit goal in the first place, they removed it from scope afterwards


async/await style programming is "first generation" technology


(not a direct answer to your question)


isn't callback hell first generation?


@ghadi async/await is solved in Clojure through core.async. My problem is different, as I want to persist all the variables declared in scope in the database for deferred execution.


have you considered using an explicit state machine?


I am using it now


And it is a mess


This is an effort to reduce bugs and intellectual load on the project


I need the state machine to be hidden so that my devs can focus on implementing features


well writing your own code rewriting macro will crush your spirit


My spirit can be crushed as long as the final outcome is working well.

👀 1

need to make a model of the control flow in the lexical scope, then determine suspension points


I am prepared to bang my head against the wall a few times.


Is this what core.async invokation of the analyser does?


before we used the tools.analyzer library, we had a mini-clojure compiler within the macro


suspending and resuming across jvm invocations is not a thing that core.async does


I would consider an explicit state machine, with clear data contract


a la AWS Step Functions, or whatever the state machine library du jour is