Best dynamic language to pair with Java on a Java project
Asked Answered
S

5

5

What is the best dynamic language to pair with Java on a large Java project?

We are considering using a dynamic language for tests, controllers, services. Some options are Groovy, JRuby or Jython. What are the pros and cons of each for this? Ideally we'd be able to call Java from the dynamic language as well as call the dynamic language from Java.

EDIT: If it helps, we're using Hibernate with PicoContainer and Webwork.

Thanks, Alex

Senhorita answered 8/10, 2010 at 21:35 Comment(0)
R
9

There are really three dynamic languages that offer a very seamless interop with Java - scala, groovy and clojure. From there, I'd ask your team which language they would rather work in or have them try a prototype in each language and see what they think.

If the team efficiency isn't important in the beginning, look to what problem each language attempts to solve:

  • Groovy is going to be very loose but natural to experienced Java developers and allows fast prototype development due to it's duck typing.
  • Scala is going to enable you to write DSLs making it a good for frameworks and tools where you want to solve the problem in a language more akin to how you would describe the problem.
  • Clojure is going to impose lisp's functional programming and immutable state concepts and could be a very natural fit for problems in AI, natural language processing, etc.

Finally, I've gone down the path of looking for the perfect language to base projects on and have found there is no perfect language. All of the languages I've mentioned above compile to native JVM byte code and are quite solid. Sometimes you just need to pick a language that might not be as cool as the others but gets you on the way to solving your problem.

Recitative answered 8/10, 2010 at 22:17 Comment(2)
Scala is not dynamic, it is a statically typed language, but offers type inference by the compiler which makes it look & feel like a dynamic language. It also has structural-typing which is "staticly checked" duck typing.Etruscan
You can use Kotlin which is relatively new: kotlinlang.org/docs/reference/java-interop.htmlSalicaceous
F
4

I recommend Groovy, principally because it interoperates seamlessly with Java, and is almost a superset of Java, so very easy for a Java developer to learn. I have absolutely no evidence to support this, but based on hearsay, guesswork, and personal experience, I suspect the Groovy community is much larger than that of either JRuby or Jython.

Incidentally, Groovy++ is way too immature to consider for production use, in my opinion.

Freely answered 11/10, 2010 at 7:44 Comment(0)
E
2

The answer is, of course, going to depend somewhat on matters of taste and flexibility. If there are folk who don't have experience with Ruby or Python then Groovy is going to have a syntax much closer to Java (in fact it is a superset of Java), and consequently be a much easier sell.

I can't really speak to JRuby as I haven't used it.

Groovy gives you probably the easiest interop with Java of the three you listed. It also has a very nice BDD library in EasyB which I like a lot. On the negative side I don't think the features or syntax of Groovy really hang together very well. It can kind of feel like a whole bunch of separate extensions to Java.

Jython is of course Python so the syntax is different, but also has all the consistency of Python. Interop is very good at the script level but at least used to be a bit awkward if you wanted to write pre-compiled classes in Jython that you call from Java. The other main pro over Groovy for me is that is that you have a real REPL to interact with the Java project.

I would also mention Clojure, the syntax is even more different but the Java interop is excellent, probably the best of all, and again you have a REPL. On the down-side if folk have trouble adjusting to Ruby or Python syntax then a Lisp is probably right out.

Experimentalism answered 8/10, 2010 at 22:3 Comment(0)
E
1

Clojure is probably the best dynamic language for controllers and services. (depending on what you mean with "services".

Scala and Groovy++ has the best java interop, but those are not dynamic (well in Groovy++ you decide for yourself what is typed.). Scala has the look and feel of a dynamic language. Scala has good testing frameworks http://www.scalatest.org/ and Specs and AKKA is very mature for services and also has Java APIs

Etruscan answered 8/10, 2010 at 21:47 Comment(0)
A
1

I'd suggest going with Jython. The syntax is clean, and you get whatever additional power/conveniences that Python gives you.

For example, if you were to go with Groovy, you are basically limited to only what Java will give you. Jython would add the powers of Python to that as well.

If it helps any, I've used Jython with Hibernate, SOAP, Corba, and EJBs and it is much easier than doing the same with just plain Java.

Andresandresen answered 11/11, 2010 at 3:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.