I have an interesting architectural question regarding an application that I am developing using both Clojure and Java. The application involves a lot of intensive, concurrent data processing tasks that need to be orchestrated.
Here's the rationale for mixing both Clojure and Java:
Given that I'm using both languages - what logic or principles should I apply to determine the dividing line between the two? In particular, I'm interested in how to design an API/interface that would be at the right kind of level to take advantage of the relative strengths of both languages.
Without commenting on your perception of the relative advantages of Java and Clojure, and assuming that you did at least some micro-benchmarking to validate that the assumption has some chance of being correct, then the correct approach would seem to be to leave Java only for the parts that require optimization.
The classes responsible for the numeric code and calculation should be written in Java, and everything else in Clojure. I would even take a more aggressive approach and just design the classes to be distinct so that they could be written in Java, but actually write them in Clojure and rewrite them in Java if performance proves to be a problem.
Clojure does a good job of helping developers get most of their part in simple functional style, and isolating mutational work into confined areas.
I would apply the same guidelines here: isolate java code as much as you can, as you would do as much of your clojure code in "pure functional style". So the java island would be as small as possible given your constraints, and access to the java island would go through a small set of clojure functions.
Not sure this helps much, but anyway !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With