(ns dev.scratch.time-ex
(:import
(java.time Duration)
(java.util Date)))
(let [from (Date.)
until (-> from (.toInstant) (.plus (Duration/ofHours 12)) (Date/from))]
[from until])
Returns a 2-element vector containing two java.util.Date objects, the second twelve hours in the future of the first. Here I'm using Date, Instant, and Duration classes. It's consistent with Clojure syntax (methods being first items in a list), and remembering to use . or / (roughly for instance or static methods) for calling Java methods. Using something like the thread-first macro (->) is idiomatic Clojure, and it's not my goal to convince you that Clojure syntax and style is better, just that Java is immediately and idiomatically available (from a Clojure point of view).I find very little friction in using Java directly from Clojure code. I can't speak to comparisons with Kotlin as I have no experience using it.
yea kotlin prbly is a better choice if you mainly want to use java's libraries and write idiomatic java.
Clojure is not 'better java' like kotlin, its a completely different paradigm.
When using a Java library in Clojure, many times its just better to just write some Java for your Clojure program specifically for the purpose of calling it from Clojure.
Can you describe the kind of situations that you faced issues in?
P.S.: Also, Clojure has first class interop... It's a part of its fudamental design.
https://old.reddit.com/r/Clojure/comments/5twabp/new_clojuri...
What? Calling Java from Clojure couldn't be any easier. The same as calling JavasScript from ClojureScript
https://old.reddit.com/r/Clojure/comments/5twabp/new_clojuri...
Using Java from Clojure I'd say is as good as Kotlin. Using Clojure from Java isn't as good as Kotlin, but it is still pretty good. Only certain things get messy, like in frameworks where you need to extend a class and override methods to set some behavior. Or frameworks that make heavy use of annotations. Since Clojure isn't OO, doing those are a bit trickier.