How to create a POJO in Clojure

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com

The premise sounds interesting:

Those times you need to have Java APIs.. Some of these APIs need to return data. In Clojure it is usually a map:

{:q “What is..?” :a 42}

In Java it is not that simple for several reasons.. Java maps are mutable, there are no idiomatic tools to inspect, destructure them, Java (programmers) like different types for different POJOs, etc..

I would have appreciated an actual example. The great thing about Clojure is how it makes data access easy. But when would I need a Java object, simply to read its data? I can not think of a case where I would use this.

This final line is confusing:

Of course there are records, but POCOs are just more fun :)

An issue that comes up a lot in the Clojure community is the influence of Java programmers who feel that Java is more natural than Clojure. This might be an example. Given years of exposure to Java, it probably seems more natural than Clojure. Of course, if a person gets a few years of experience with Clojure, they might feel differently.

Clojure records are idiomatic Clojure, whereas POCOs are not. As near as I can see, POCOs should be avoided.

Source