To begin with, I’m a very happy Clojurian, but not when I’m working with interops. I’m using Google apis extensively for some features in my product; and so far the experience has been quite awful. I’ve been contemplating it for a while and here are my pain points.
- It is hard to look up for what method a java object supports.
- It is hard to understand the inheritance and polymorphism designs without actually looking at the java codes.
- 1,2 are amplified all the more because I’m using calva with vscode. The IDE’s java support is not as good as that of intellij.
How do you work with interops in general? I welcome any tips/advices/know-hows.
IntelliJ IDEA is definitely much better than VSCode in this regard, and it’s pretty much the only thing that’s stopping me from switching to VSCode.
But if you’re keen on keeping using VSCode, then IMO looking at the sources written in Java is your best bet. In addition, you can use Java reflection, directly or via
clojure.reflect/reflect
. In the case of thereflect
function, things like Portal would be useful since even the simplest types will have a lot of members and Portal will help you with navigating the resulting data structure.Agree with you on vscode. I’ve been using intellij for quite a while but switched to vscode for various reasons (one of them being vscode’s deps prompt when starting repl. It works well with polylith architecture).
About reflect, I made some utility functions with limitations. The thing is reflect does not show inherited methods and I have no way of knowing the full capabilities of an object. And does portal allow navigation in and out of Java object? When I tap> whatever is bound to portal it only shows a shallow data, not object, in portal screen.
Yeah, getting to inherited methods requires more work, more utility functions. But you can still get that information since you have the info on the bases of a class - you can reflect the whole base tree and build up the full set of supported methods.