Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How well would Clojure fit into a Spring Boot centric environment?


Actually ... it works. I'm calling Clojure from Kotlin in Spring Boot and it integrated very nicely.

You have to export the code to make it callable, and I had to write some adapters on the Kotlin end. But very doable for integrating if you need to.

This code is quite specific, but you get the idea. Export symbols:

https://gitlab.com/crossref/rest_api/-/blob/main/src/cayenne...

Convert Clojure structures to Kotlin classes:

https://gitlab.com/crossref/manifold/-/blob/main/src/main/ko...


You can call into Clojure code from that code and vice versa, if you want to start that way. But best to first dev and test the code separately so you can use the normal Clojure dev workflows. Or I guess you can start a nrepl from your Clojure code and do live dev in that scenario, maybe someone has done it and can report?

Mostly, people using Clojure want. to get away from Java.


> Mostly, people using Clojure want. to get away from Java.

I understand that, but Spring Boot already offers support for Koltin (yikes) and Groovy (double-yikes). Would supporting Clojure templates that use the underlying Java classes be difficult or cumbersome? Would it yield Clojure code that's not idiomatic?

I don't mind the underlying tooling that much, but I'd love to be able to use a more elegant language for the business logic.


I don't have the experience in Java or Spring to say, sounds like it could possibly be interesting to try building as a path to Clojure.


It'll work fine, but you won't be able to gain much benefit from it. Spring Boot systems are flaky and incomprehensible because of Spring Boot, adding another language can't help with that.


Clojure can fit quite well into Spring Boot-centric environments!

I've added Clojure to several legacy Spring Boot apps, and the fact that it can be introduced as "just a library" made that portion a snap. If you're not trying to access resources related to Spring Boot's dependency injection, it's pretty straightforward to call into Clojure from Java. If you _do_ want access to DI resources, there's a small amount of code required to wire things up, though it took me a while to find out what that code was, mostly because it requires access to portions of Spring Boot that are not typically user-facing.

Since I had hooked Clojure up to the Spring apps, I also set things up so I could SSH onto application servers, then get a REPL via a socket server into the applications themselves. Being able to check and sometimes change the state of the application live at runtime was like a superpower. This proved extremely valuable, often for debugging errors in the Java portions of the code, but also for situations like final design tweaks live with a client in a development environment. Client asks to bump a font size or change a color or adjust a border or change some copy, then I make the change in my editor, send it over the socket REPL, tell the client to refresh, and repeat. When done, I would simply save, commit, and would be confident that it's what the client was after. The only downside is that I'm no longer at a shop that uses Clojure, and feedback loops for production debugging or letting clients see their decisions are measured in days or weeks when possible at all, not seconds or minutes.

I will admit that connecting to a running application is dangerous, but so is what many surgeons do, and we are certainly not going to ask them to turn in their scalpels. By being conscious of the "great power; great responsibility" bit, I was able to come out mishap-free.

On the other hand, when I had to create new projects where I thought Clojure would be a good fit, I just went all-in with the Clojure ecosystem rather than start with Spring Boot and add Clojure, and I found going all-in with Clojure to be incredibly productive. With that being said, I made the decisions with a decent understanding of both Spring Boot and Clojure, so my experience would likely vary from that of someone who is experienced with Spring Boot and knows nothing of Clojure.


Clojure w/ Spring Boot? No.

It would do fine as part of a microservices architecture where some of the other services are Java/Spring. I've done exactly that in fact - wrote a few Clojure services to rip through and ingest some data as part of a system where we had Java/Spring and Python services mixed in.

If you're looking for a Java alternative in a "Spring Boot" shop, Kotlin has excellent Spring support and is definitely more pleasant to use than Java.


clojure can be used to create a library/jar which could be called from a java app: https://stackoverflow.com/questions/2181774/calling-clojure-...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: