Can you mix the JVM languages? ie: Groovy & Clojure

前端 未结 6 883
难免孤独
难免孤独 2021-02-13 21:27

I understand that you can easily mix groovy&java, clojure&java, whateverJvmLang&java.

Does this also mean I can have clojure and groovy code interact as well

6条回答
  •  感情败类
    2021-02-13 21:59

    As has been mentioned, Clojure can interact easily with Java. Although many of the examples you see show how to do it from the REPL, once you compile Clojure, or any other JVM language, to a class or jar file, it can be called from Java just like any other class.

    In my case, the difficulty (not much of one) was figuring out how to use gen-class correctly. There is a small set of statistical functions written in Clojure at http://kenai.com/projects/binomialstats that illustrates how to do it. That Clojure library is used by a Java project -- signtest. (Sorry, since I'm new, StackOverflow won't let me post multiple links.)

    What would really be nice now is if some of the IDEs could deal with different languages in the same project. The two projects mentioned above are maintained as two individual NetBeans projects for example. Assuring that the two parts are always synchronized can be a bit of extra work.

提交回复
热议问题