Groovy优于Jython或Jruby? [英] Groovy advantages over Jython or Jruby?

查看:215
本文介绍了Groovy优于Jython或Jruby?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我会选择在使用Jython或Jruby时使用Groovy?该语言是否提供了任何固有的优点,以弥补Jython和Jruby技能适用于JVM之外的其父语言的事实?



请记住,我故意保留这个问题的通用性,但是如果在某个特定领域存在任何优势,请不要犹豫,描述它们。 p>

编辑

澄清,如果我在Jruby中编写一些代码,现在可以在某些情况下移动该代码如果需要的话,可以在JVM之外,或者至少我已经对Ruby有了更好的理解。而Groovy技能仅适用于使用JVM内部存在的语言。 Jython和Jruby具有这种内在优势,Groovy必须弥补这一缺点吗?



如果Groovy没有您找到的任何优势,并且你会建议使用Jython或Jruby,让我知道。



编辑2

感谢所有人的回答,其中大多数人都表达了同样的观点,Groovy与Java,Jython或Jruby的集成稍好。


$ b

跟进

使用Netbeans 6.5作为我的IDE我发现Groovy能更好地与Java项目集成,然后Jruby。我不确定是否缺乏整合是Jruby或Netbeans的失败。但在使用Groovy之后,Groovy似乎确实有了一些优势。

解决方案

我在Ruby中做了相当广泛的开发, Groovy(以及一个使用Grinder作为负载测试工具的小Jython)。

3中,我最喜欢Groovy。我喜欢最好的闭包语法,我认为它与JVM上其他Java类的工作方式有最紧密的集成。自从我上次使用JRuby以来,已经有一段时间了,但在JRuby中导入Java类和使用类加载器对我来说并没有那么干净。



Groovy基本上也是Java的超集,这意味着大量的Java程序员在采用Groovy比Ruby / JRuby更快的接受时间。他们可以开始编程,就像它是Java一样,并慢慢开始插入习惯性的groovy,因为他们拿起它。



更重要的是,你在问什么,我认为另一个Groovy的优势在于,当你想要优化某些东西时,你所使用的语言几乎是完全相同的语法,就是Java。如果你在Ruby或Python世界工作,你将不得不去C这是一个重大转变或Java,这也是与这些语言完全不同的。 Groovy中的编程往往有助于保持Java技能的清晰度。



如果您有特别的权限访问Ruby或Python基础结构或熟悉这些基础结构的团队那么我可以看到选择其中一种语言。

真的,他们三个都是非常好的语言,你选择的应该更多地依赖于你正在尝试修复的问题以及你可用的资源您。一旦你熟练掌握了一种动态语言,拿起第二或第三种语言就容易多了。

Why would I choose to use Groovy when I could use Jython or Jruby? Does the language provide any inherent advantages to make up for the fact that Jython and Jruby skills are applicable to their parent languages outside of the JVM?

Keep in mind that I purposely keeping this question generic, but if there are any advantages that exist in a particular domain, please don't hesitate to describe them.

EDIT
To clarify, If I write some code in Jruby, I can now, in some cases, move that code outside of the JVM if need be, or at the very least I have gained a better understanding of Ruby. Whereas Groovy skills are applicable only when using a language that just exists inside the JVM. Jython and Jruby have this built in advantage, what does Groovy have to make up for this disadvantage?

If Groovy doesn't have any advantages that you've found, and you would suggest just using Jython or Jruby, let me know.

Edit 2
Thanks everyone for all the answers, most of them make the same point, Groovy integrates slightly better with Java then Jython or Jruby.

Follow up
Using Netbeans 6.5 as my IDE I have found that Groovy to integrates better with Java projects then Jruby. I am not sure if lack of integration is a failing of Jruby or Netbeans. But after using it for alittle Groovy definitely seems to have a leg up.

解决方案

I've done pretty extensive development in Ruby and Groovy (as well as a little Jython using Grinder as a load testing tool).

Of the 3, I prefer Groovy the most. I like the closure syntax the best and I think that it has the tightest integration in how it works with other java classes on the JVM. It's been a little while since I last used JRuby, but importing Java classes and working with the classloader in JRuby didn't feel as clean to me.

The fact that Groovy is also essentially a superset of Java means that the huge population of Java programmers out there will have a quicker uptake time in picking Groovy up over Ruby/JRuby. They can start programming it like it's Java and slowly start inserting idomatic groovy as they pick it up.

More to the point of what you're asking, I think that another advantage of Groovy is that the language that you go to when you want to optimize something is almost the exact same syntax, it's Java. If you're working in the Ruby or Python worlds, you're going to have to go to either C which is a big shift or Java, which is also quite different than those languages. Programming in Groovy tends to help keep your Java skills somewhat sharp as well.

If you have particular access to a Ruby or Python infrastructure, or a team that has familiarity with those kind of environments, then I could see choosing one of those other languages.

Really, all 3 of them are very nice languages and what you pick should depend more on the problem that you're trying to fix and the resources that you have available to you. Once you've become proficient in one dynamic language, picking up a second or a third is much easier.

这篇关于Groovy优于Jython或Jruby?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆