News for hackers. Stuff that matters.
Re:Clojure Web Development Evolved [video] by dimitar on Saturday July 30, 2022 @02:35AM (#32284807)
Clojure libraries are good but you have Java and JS interop for mundane, everyday libraries. Is there anything wrong with interop?

I think most Clojure libraries rightfully focus on things that either only possible or needed in Clojure. Things like core async, typed clojure are not even possible to implement in other languages as libraries.

When thinking of examples: the cognitect/aws-api is amazing in it's ease and fun, yet AWS Java SDK is also easy to use from clojure. I prefer the former, but there isn't anything wrong with the latter.

Re:Clojure Web Development Evolved [video] by janetacarr on Saturday July 30, 2022 @09:23AM (#32286596)
As someone alluded to, Interop can be frustrating with big frameworks.

Interop also relies heavily on reflection, and may require type hinting once it becomes a performance problem. Interop also implies the use of side-effects since we're relying on Java object. While a lot of Clojure's sequence and collection operations do work on Java sequences and Collections, it's not perfect and very easy to get bitten, requiring a Clojure.walk/postwalk and zipmap with coercion to get a good Java->Clojure container/sequence/collection.

If we used interop for everything mundane, Clojure would really just be an S-expression shaped husk over Java code. Not a very great solution imho.

Re:Clojure Web Development Evolved [video] by didibus on Saturday July 30, 2022 @04:08PM (#32289839)
I'll politely disagree. The mundane libraries I think you're talking about tend to be about IO, that's always going to be side-effectful in nature. Their APIs wouldn't be all that different even if implemented directly in Clojure.

Type hinting isn't hard or time consuming, literally you can take 10min and have everything type hinted.

Now I don't know about big frameworks, maybe I don't find a need for big frameworks? But even then, what kind of framework are you talking about? Using Spring MVC for example?

Re:Clojure Web Development Evolved [video] by regularfry on Saturday July 30, 2022 @05:12AM (#32285392)
A problem I have run into (admittedly, having not written as much clojure code as I'd like) is that some java libraries in particular can make interop distinctly unpleasant. Anything around the Spring framework, for instance, made me tear my hair out. Yes it's possible, but by the time you've compensated for the impedance mismatch you might as well have done a rewrite.
Re:Clojure Web Development Evolved [video] by didibus on Saturday July 30, 2022 @04:11PM (#32289855)
Hum, I've used Spring with Clojure a lot, never had issues.

Things that are difficult to interop are java annotations based stuff, having to implement interfaces or subclass classes, and functional interfaces.

But you can use Spring without annotations, which is my preferred way anyways, because I favor explicit over implicit.

Re:Clojure Web Development Evolved [video] by john2x on Saturday July 30, 2022 @05:10AM (#32285383)
If you're using interop for mundane, everyday things, why use Clojure then? I imagine you would end up writing non-idiomatic Clojure code to do the interop (e.g. working with mutable objects and not immutable datastructures).
Re:Clojure Web Development Evolved [video] by didibus on Saturday July 30, 2022 @04:17PM (#32289904)
The recommended design for Clojure programs is imperative shell, functional core. You use Clojure as your functional core, and it interops with mundane libraries for the imperative shell, such as database clients, http clients, logging, http server, graphics, sound, etc.

It works beautifully, and the REPL helps with all of it.