Mix Groovy and Java? [closed]
I was looking for a scripting language for the JVM to speed up application development. I decided to take a closer look at Groovy.
My questions are:
What is your attitude towards mixed Java and Groovy projects?
Do you think it would make sense to write a whole application in Groovy only?
What is your attitude towards mixed Java and Groovy projects?
Seems to work quite well for Grails.
Do you think it would make sense to write a whole application in Groovy only?
Define "makes sense". I think it may for web applications, but not all applications. I would decide on a case-by-case bass. The safest answer is to say "it should be a mix of Java and Groovy."
Since Groovy runs in JDK 6, I'm assuming that it's no less portable than JDK 6 is.
The performance of web apps is often determined by factors such as network latency or database design (e.g. proper indexing) more than raw language speed.
I am very favorable to mix Java and Groovy code, because actually you are writing in the same language (from the JVM's point of view) and they interact quite well with one another. Groovy can solve a lot of problems with less code than Java, producing more readable and compact solutions. On the other hand, Java can be helpful when you want to take advantage of the compiler's checks in particularly critical sections of your code. Moreover, you can be in the situation where you have a lot of legacy, well-tested code that you don't want to change to interact with Groovy.
The interaction between Java and Groovy must be carefully planned. I think that would be a good approach to put a set of interfaces between Java and Groovy code. In this way, you can define a clear "communication protocol" between the two languages.
If you want to start a new project, think carefully of the technology you want to use. Depending on the size of the project, the complexity of the domain, the scheduled timeline and the budget, you have to choose the right tool to achieve your targets. If you don't take into account these (and other) parameters, well, every language is a good choice.
精彩评论