Fork me on GitHub
#off-topic
<
2021-03-09
>
javahippie09:03:36

Do you know any libraries that are written in Clojure but targeted / widely used for Java?

raspasov09:03:52

(much bigger than a “library” though)

javahippie09:03:00

More of a platform, but interesting to see, thanks!

raspasov09:03:02

Yes… I feel like most Clojure libraries would be a bad fit for Java. Hard to imagine how an idiomatic Clojure library can be conveniently used from Java… Perhaps something about managed in-process concurrency, where it can utilize the Clojure concurrency primitives behind the scenes. Immutable data structures and dynamic data transformation (which Clojure is excellent at) are quite foreign to Java.

javahippie09:03:50

That’s the point I am wondering about. Currently building a lib that could also be beneficial for Java devs, and I’m wondering about the API or a thin shim layer.

raspasov09:03:14

Perhaps expose a number of public static methods

raspasov09:03:07

Depends on the arguments though… would it take Objects? Passing in Clojure data structures from Java is a no-go as far as ease-of-use

javahippie09:03:37

Or a small wrapper object. In my experience, Java folks are cautious about stuff that they cannot inject 😅

raspasov09:03:17

Gotta get that DI fix. 🙂

javahippie09:03:21

I would not require objects, most operations use identifiers. Some dynamic data structures, that’s the tricky part. Would not like to expose Map<String, Object>

vemv09:03:03

Apache Storm

raspasov09:03:46

on your (library) side, to read the objects coming from Java

javahippie09:03:06

@U45T93RA6 Apache Storm is unfortunately moving from Cloure to Java 😞

javahippie09:03:29

@U050KSS8M Thanks, this will come in handy

👍 1
Ben Sless13:03:39

If you want to expose the library to Java developers it would be helpful for them if you define interfaces, even in Java files (although you may be able to use protocols for that) for them to work against. Then you implement those interfaces however you like on your end (reify, deftype, defrecord) while leaving it open for others

souenzzo14:03:39

@U0N9SJHCH #clara was developed by a clojure sub-team inside a java application Also, #storm was developed in clojure but it's main API was in java (now storm V2 was rewritten in java)

emccue20:03:07

Generally unless the project is large, I can't imagine it happening

emccue20:03:34

clojure does not provide all the mechanisms you would need to provide easy/comfortable/idiomatic access from java

emccue20:03:15

at least without significant wrapping overhead

javahippie21:03:07

@UK0810AQ2 That sounds like a good approach, thank you!

javahippie21:03:33

@U064X3EF3 Will definitely look into that!

javahippie21:03:10

@U2J4FRT2T thanks for the pointers to clara, was planning to look into it, anyways

javahippie21:03:40

@U3JH98J4R What don’t you see happening, adoption of a Clojure library in Java, or making it technically possible?

emccue21:03:08

well, just justifying the overhead

emccue21:03:46

you can make a java interface in clojure, but it wont have generic types

emccue21:03:13

you can return maps to java, but java users expect objects with named properties

javahippie21:03:00

Sure, you’d need to wrap all of that (if it’s not dynamic data structures)

emccue21:03:51

i guess it would matter a lot what library you are writing and where the bulk of the logic goes

emccue21:03:10

but its definitely not the same situation as with scala or kotlin where you can mostly just write it like normal and interop is relatively straightforward

emccue21:03:17

I just can't think of a good strawman library where writing it in clojure would be the right call

Ben Sless21:03:50

Returning records won't satisfy the need for objects with named properties?

emccue22:03:07

lets say we had this and aot compiled it

emccue22:03:20

(defrecord SimpleResult [stuff])

emccue22:03:30

Java would see Object stuff()

emccue22:03:06

what you want is List<String> stuff() - you can get to List stuff() with clojure typehints but that isn't great either

Stuart14:03:59

Windows huh?

😆 3
walterl19:03:57

It's extremely dangerous to delete existing files. It's sure to cause data loss.

😂 3
Mno16:03:05

Huh.. Does this mean windows is immutable?

Mno16:03:36

Oh, you may not be able to delete it, but maybe you can edit it

😂 1