News for hackers. Stuff that matters.
Re:The Road to Scala 3 by The_rationalist on Saturday December 21, 2019 @09:52AM (#21851406)
Interested but how much as good as with kotlin? Being compatible is one thing, being as idiomatic is another.
Re:The Road to Scala 3 by grzm on Saturday December 21, 2019 @09:54AM (#21851412)
Define idiomatic. As an example, I find myself using the java.time package quite frequently. An example:

    (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.

Re:The Road to Scala 3 by didibus on Saturday December 21, 2019 @01:25PM (#21852558)
Not sure what you mean. It is idiomatic to not rebuild things Java offers in Clojure and to instead just use interop with Java.

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.

Re:The Road to Scala 3 by dominotw on Saturday December 21, 2019 @09:55AM (#21851425)
> being as idiomatic

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.

Re:The Road to Scala 3 by Scarbutt on Saturday December 21, 2019 @12:06PM (#21852174)
Nowhere near as good or as seamless as Kotlin interop, Kotlin made interop a priority/first class feature.

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.

Re:The Road to Scala 3 by didibus on Saturday December 21, 2019 @01:29PM (#21852575)
That hasn't been my experience. I've always been able to make use of Java libraries directly from Clojure in a straightforward way. In fact, sometimes I joke it's easier to do Java in Clojure than in Java

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.

Re:The Road to Scala 3 by trmsw on Saturday December 21, 2019 @03:00PM (#21853056)
In what sort of situations have you needed to write more Java to use a Java library from Clojure? I've never felt the need to do this. It's sometimes helpful to write a Clojure wrapper for a Java library on order to use it in a more Clojure-y way.
Re:The Road to Scala 3 by Scarbutt on Saturday December 21, 2019 @04:45PM (#21853523)
Re:The Road to Scala 3 by mateuszf on Saturday December 21, 2019 @04:17PM (#21853416)
> 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.

What? Calling Java from Clojure couldn't be any easier. The same as calling JavasScript from ClojureScript

Re:The Road to Scala 3 by Scarbutt on Saturday December 21, 2019 @04:45PM (#21853522)
Re:The Road to Scala 3 by mateuszf on Sunday December 22, 2019 @01:39AM (#21855641)
Ok, that's fair enough, though one could argue this is about writing new java like code not accessing existing java code.