This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-14
Channels
- # announcements (4)
- # babashka (32)
- # beginners (24)
- # calva (3)
- # cider (37)
- # clj-commons (8)
- # clj-kondo (6)
- # clojure (51)
- # clojure-denver (7)
- # clojure-europe (48)
- # clojure-nl (1)
- # clojure-norway (2)
- # clojure-uk (2)
- # clojurescript (12)
- # core-async (10)
- # cursive (9)
- # datomic (42)
- # hyperfiddle (25)
- # jobs (4)
- # juxt (2)
- # lsp (10)
- # malli (11)
- # off-topic (32)
- # polylith (6)
- # practicalli (1)
- # react (2)
- # releases (1)
- # remote-jobs (2)
- # spacemacs (4)
- # xtdb (4)
Has anyone tried or is there a library to generate wrappers for Java libraries like this https://github.com/henryw374/cljc.java-time/blob/master/dev/gen.clj I am thinking of creating something like this, where you can create full wrappers
Someone did this a few years ago
But you might find that a lot of this is soon made obsolete by the method thunk work we’re doing in Clojure 1.12
https://github.com/clojure-interop/java-jdk and others in that org are what I’m thinking of, but I don’t think they ever released the generator
So does it still make sense to write a generator ? But it is not much code and already working with 70 LOC, the tortilla library is doing most of the work already.
The generator would be very useful to see also. I will try to get in contact. https://github.com/potapenko wrote it?
I want to make something similar for libgdx what was done here for java-time and maybe it can be a lib which can create wrapper-libs
yes. https://github.com/emlyn/tortilla not used it directly, but I borrowed some code from it to improve the gen step of cljc.java-time
Yes I know about tortilla and want to use it as a dependency. Why is there a defwrapper in clj-time , is there any difference to tortilla ?
there was https://github.com/ngrunwald/gavagai back in the days
you end up with some twisted apis that are not very "idiomatic" to clj (for lack of a better term)
yes there are some differences ... to make the output bb compatible I think it was. probably not an issue any more
What is bb? I am not sure which code I should get to know more, clj-time.defwrapper or defwrapper lib
babashka. definitely tortilla. I remembered some more changes I made are to deal with quirks in the js version of java.time that the cljs version of the generated code uses.
like instead of getX
, some fns in the js lib are just called x
. ugly stuff. so yeah, tortilla is meant to be general purpose
Thanks very much! Just discovered cljc.java.time yesterday and really appreciate to get a reply from the author immediately
Stayed up the whole night and generated 50,000 lines of wrapper code for libgdx with 70 lines of code
I think clojure wrapper libraries are complecting the type hinting/method to function creation and the individual library design. There should be a base wrapper which takes care of the 'plumbing' parts for a Java library and then other wrappers with different design phiolospies on top of it.
So basically what java-time does. I wonder if there can be a standardised way to wrap Java libraries , would make it more simpler to interop
maybe "coffee-mug" or "thermos", since its an easier way to consume Java ☕ 😄?

I think I want to keep tortilla in the name because it's the main dependency and it makes clear it's about 'wrapping'. Also I can put a tortilla emoji on the GitHub page 🌯
a thin, flat pancake made from maize flour, eaten hot or cold, typically with a savoury filling.
Burrito
@U0ALH6R89 As a note for future discussions, can you please use threads for follow-up comments after your initial post so there aren't multiple posts in the main channel. Threads produce less "noise" for the thousands of other members here and also make sure there's a single, coherent place for responses rather than them being scattered across multiple messages or threads. Thanks.
can I have a protocol method without arguments? How would I call the method? Right now I have:
(defprotocol SecretsProvider
(provider-name [] "xx")
(run [context] "XX"))
with this:
(defrecord VaultSecretsProvider []
providers/SecretsProvider
(run [context] [])
(provider-name [] ::vault))
but I don't know how to call the provider-name functionality (babashka complains that I call it with an argument when it expects 0)The first argument should always be the object on which you call the protocol method
ok. thanks. this is not very obvious from the docs https://clojure.org/reference/protocols . I found this reference now that I was looking for it: > The implementing fn can presume first argument is instanceof AType
that seems like a valid criticism. I think you should mention that on http://ask.clojure.org
I think we can make a PR for this: https://github.com/clojure/clojure-site/blob/master/content/reference/protocols.adoc
wdyt @U064X3EF3 ? ( sorry, I don't know anyone else from clojure team )
i suggested on http://ask.clojure.org because it’ll be in his queue and you’ll get a thoughtful answer when he has time
I created a PR (have CA signed) https://github.com/clojure/clojure-site/pull/654 .