您的位置:首页 > 编程语言 > Ruby

Compare JRuby, Groovy and Python

2009-03-03 22:35 351 查看
If I were to rate JRuby, Jython, and Groovy in terms of integration with existing Java code, I’d have to say that Groovy is the most robust, JRuby is the next strongest, and Jython lags behind. The recent Sun hires may turn Jython around but my guess is that Jython is at least six months to a year away from being used in serious production deployments.

Jython is similar to Python. And Python is a pretty different language from most others. The sticking point for many people is the way you write the code – space actually matters. White space, ignored by almost all other programming languages, is significant in Python. Most people either love it or hate it, though I’m in the middle. It’s a characteristic that is unique to Python and that Jython picks up. In addition, there’s a bit of an impedance mismatch between Java and Python. The conversion process around basic collection classes and other primitives when integrating with Java seems to be a bit clunky. It’s just not completely smooth – it gets in the way a little more than it should.

In JRuby, conversion is considerably easier. You can convert back and forth very nicely, so you have little to fear. In my view, Groovy is even easier to use than JRuby and works more seamlessly with Java. I sometimes joke that Groovy is simply a “fancy Java.” This is because Groovy is written in Java, uses all the same classes, and has no gaps. All of these features are readily apparent in the language.

Essentially, there’s no simple answer as to which one is the “best” language. If I were to write some quick scripting task that needs to use Java in a non-trivial fashion, I’d almost certainly go with Groovy. If I were to use a lot of native facilities, such as manipulating files or directories, and needed to get a little down and dirty with the details of operating system–specific facilities, I’d go with JRuby. This is because Ruby has a deeper linkage to the platform you’re on, whereas Groovy only has Java-level tie-ins.

JRuby has recently done a lot to overcome most of its problems integrating with Java. It’s not quite 100 percent there yet but I have no doubt the core developers will be able to smooth out the process this year. I think they can get it to the point where it’s almost as good as Groovy almost all the time, but I don’t think it will ever be able to attain the same level of seamlessness as Groovy.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: