off-topic

https://github.com/clojurians/community-development/blob/master/Code-of-Conduct.md Clojurians Slack Community Code of Conduct. Searchable message archives are at https://clojurians-log.clojureverse.org/
javahippie 2021-03-09T09:17:36.237300Z

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

raspasov 2021-03-09T09:20:18.237500Z

https://github.com/metabase/metabase

raspasov 2021-03-09T09:20:52.237800Z

(much bigger than a “library” though)

javahippie 2021-03-09T09:23:00.238100Z

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

2021-03-09T09:31:17.238300Z

https://www.opencrux.com/reference

👍 1
raspasov 2021-03-09T09:32:02.238500Z

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.

javahippie 2021-03-09T09:37:50.238700Z

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.

raspasov 2021-03-09T09:39:14.239Z

Perhaps expose a number of public static methods

raspasov 2021-03-09T09:40:07.239200Z

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

javahippie 2021-03-09T09:40:37.239400Z

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

raspasov 2021-03-09T09:41:17.239600Z

Gotta get that DI fix. 🙂

javahippie 2021-03-09T09:42:21.239800Z

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>

vemv 2021-03-09T09:43:03.240Z

Apache Storm

raspasov 2021-03-09T09:43:16.240200Z

Perhaps check if https://clojuredocs.org/clojure.core/bean can be helpful

raspasov 2021-03-09T09:43:46.240400Z

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

javahippie 2021-03-09T09:46:06.240600Z

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

javahippie 2021-03-09T09:46:29.240800Z

@raspasov Thanks, this will come in handy

👍 1
Ben Sless 2021-03-09T13:28:39.241100Z

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

alexmiller 2021-03-09T13:39:27.241700Z

I did an example of that here https://github.com/puredanger/clojure-from-java

souenzzo 2021-03-09T14:29:39.242Z

@javahippie #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)

2021-03-09T14:44:59.242300Z

Windows huh?

😆 3
Mno 2021-03-09T16:50:05.243300Z

Huh.. Does this mean windows is immutable?

Mno 2021-03-09T16:50:36.244200Z

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

😂 1
walterl 2021-03-09T19:21:57.244800Z

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

😂 3
emccue 2021-03-09T20:37:07.246100Z

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

emccue 2021-03-09T20:37:34.246300Z

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

emccue 2021-03-09T20:38:15.246700Z

at least without significant wrapping overhead

javahippie 2021-03-09T21:07:07.247200Z

@ben.sless That sounds like a good approach, thank you!

javahippie 2021-03-09T21:07:33.247400Z

@alexmiller Will definitely look into that!

javahippie 2021-03-09T21:08:10.247600Z

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

javahippie 2021-03-09T21:08:40.247800Z

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

emccue 2021-03-09T21:09:08.248Z

well, just justifying the overhead

emccue 2021-03-09T21:09:14.248200Z

as in

emccue 2021-03-09T21:09:46.248400Z

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

emccue 2021-03-09T21:10:13.248600Z

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

javahippie 2021-03-09T21:12:00.248900Z

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

emccue 2021-03-09T21:12:51.249100Z

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

emccue 2021-03-09T21:13:10.249300Z

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

emccue 2021-03-09T21:14:17.249700Z

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

Ben Sless 2021-03-09T21:21:50.249900Z

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

emccue 2021-03-09T22:21:57.250100Z

nope

emccue 2021-03-09T22:22:07.250300Z

lets say we had this and aot compiled it

emccue 2021-03-09T22:22:20.250500Z

(defrecord SimpleResult [stuff])

emccue 2021-03-09T22:22:30.250700Z

Java would see Object stuff()

emccue 2021-03-09T22:23:06.250900Z

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