this post was submitted on 20 Oct 2023
1 points (100.0% liked)

Lisp

53 readers
3 users here now

founded 1 year ago
MODERATORS
 

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.

  1. It is hard to look up for what method a java object supports.
  2. It is hard to understand the inheritance and polymorphism designs without actually looking at the java codes.
  3. 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.

you are viewing a single comment's thread
view the rest of the comments
[–] serpix@alien.top 1 points 1 year ago (4 children)
  1. IntelliJ plus type hinting code gives method lookup popups:

(defn foo [^^GoogleFactoryProxy factory-proxy] (doto (.fooMethod factory-proxy) (.addStuff (stuff))))

doto is great for functions returning void. You can still use threading macro if the Java object returns self.

Method hints pop up after the first dot.

If you need to implement interfaces or extend objects then I would write wrappers which do the reify work and pass function arguments to those wrappers. Otherwise the code becomes noisy and has less signal.

[–] OkAssociation9896@alien.top 1 points 1 year ago (2 children)

So it is intellij after all. Is it your primary IDE?

[–] serpix@alien.top 1 points 1 year ago

IntelliJ is primary along with Vim plugin, clj-kondo and paredit for retaining some sanity while editing. There is some jankiness with clj-kondo but all in all I would say the REPL integration is on par with emacs. Never had the patience to set up vim or dabble with neovim when IntelliJ has it all out of the box.

IntelliJ even supports prefix key bindings now which allow binding repl functions and custom keybindings behind a prefix key.

For example as `ctrl-x` follow by `e` sends the last expression to the repl.

load more comments (1 replies)
load more comments (2 replies)