On Thu, Mar 26, 2009 at 6:33 AM, AlamedaMike <limejui...@yahoo.com> wrote: > >>> It's very good question, and to be honest I don't know exact question for > it. I may imagine both cases from Clojure to Java and vise versa. > Making > first variant default I was followed by one letter I had received. It > was > about some project written in IDEA, where Clojure is used for core > funcationality whereas al UI is written in Java via UI designer. > > That may have been my email. Given that there is currently no solid > GUI forms designer for Clojure, IDEA will have a strong market niche > by developing one. The idea (no pun intended) is that each language > should do what it does best. At some point Clojure may have the tools > to be best at GUI forms, but not right now. In this scenario, Clojure > will presumably need to be compiled first, unless there is some way to > invoke the GUI from Clojure (my Java skills are very rusty).
Reading this description I become unsure of whether you want to call into Java from Clojure, or into Clojure from Java. Here's where I stand: I presume that in most Clojure programs, the majority of the business logic will be implemented in Clojure. The Java code, if any, will be used for implementing low-level stuff (ie. primitive math, mutating algorithms) and library intergration work. In this case, the wirering work will be done mostly in Clojure using the standard interop features of the language. Considering this, the Java code will know little or nothing about Clojure and is easily compiled first, whereas the Clojure code might want to have the class files from the Java code handy during compilation for things such as avoiding reflection, type hinting and what have you. In short: the Java code *should* be compiled first. The inverse case is where Java uses Clojure as a scripting language of sorts. Here, the Java code may or may not be dominant, but in either case it knows about Clojure; it may work with the data structures and it may call functions implemented in Clojure. However, because of the dynamic nature of Clojure there is seldomly any new types defined in it, with the intent of direct consumption from Java. Instead, the Java code interacts with the Clojure code through the various interfaces defined in clojure.jar. Here's an example of what I mean: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java As we see from that example, the reference to the "foo" function is, in the Java sense, resolved at run-time. Therefor, the Java code *can* be compiled first, and if the Clojure code, for some reason, knowingly interacts with the types defined in the Java code, it *should* [have the Java compiled first]. This leaves us, to the best of my knowledge, just one case where the Clojure code *must* be compiled first: When Clojure define new types through gen-class (or the embedded ASM library) that needs to be directly and knowingly interacted with in the Java code. So, my *assumption* (because I have no way of knowing for sure) is that this last case is the less common one, and therefor it makes sense to compile the Java code first. This is my reasoning anyway. -- Venlig hilsen / Kind regards, Christian Vest Hansen. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---