Groovy 和 Groovy 是吗?++两种语言还是一种语言?
Groovy 1.x(来自 http://groovy.codehaus.org)和 Groovy++(来自 http://code.google.com/p/groovypptest) 两种不同的语言或它们是两个部分吗只有一种语言?为什么或为什么不呢?
Are Groovy 1.x (from http://groovy.codehaus.org) and Groovy++ (from http://code.google.com/p/groovypptest) two separate languages or are they two parts of just one language? Why or why not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Groovy++ 网站上提供了您问题的答案。这是您链接到的页面上的第二句话!
Groovy++ 是 Groovy 的扩展。它建立在 Groovy 的基础上,在某些或所有类中添加真正的静态类型。目标是性能和其他方面的改进。同样,您链接到的页面有完整的描述。
最近,Groovy 确实提高了它的性能,并且随着 Java 7 的
invokeDynamic
的添加,性能可能很快就会几乎与 Groovy++/Java 一样快(差异几乎可以忽略不计)。The answer to your question is provided on the Groovy++ website. It's the second sentence on the page you linked to!
Groovy++ is an extension to Groovy. It builds on to Groovy, adding true static typing in some or all classes. The goal is performance and other improvements. Again, the page you link to has a complete description.
Recently, Groovy has really improved it's performance, and with the addition of Java 7's
invokeDynamic
, performance may soon be almost as fast as Groovy++/Java (the difference being mostly negligible).从软件架构的角度来看,Groovy++ 可能是 Groovy 的扩展。
但如果你看一下语言级别:如果你使用动态方法调用并用
@Typed
注释该类,会发生什么?编译器会抱怨未知的方法。我认为 Groovy++ 是一种新语言,因为带有 @Typed 注释的 Groovy 类不允许像未注释的 Groovy 类那样进行动态调用。它改变了代码的语义。
Groovy++ 是 Groovy 的子集。
On a software architectual point of view Groovy++ may be an extension of Groovy.
But if you look at language level: What happens if you use dynamic method invokation and annotate that class with
@Typed
? The compiler will complain about the unkown methods.I think Groovy++ is a new language because a
@Typed
annotated Groovy Class does not allow dynamic calls like a not annotated Groovy Class. It changes the sematic of your code.Groovy++ is a subset of Groovy.
从形式上来说,Groovy++ 只是 Groovy 库。 Groovy++ 甚至没有任何特殊语法并使用 Java 注释。
但事实上 Groovy++ 是 Groovy 方言(当然不是新语言)。
@Peter Groovy++ 禁止一些 Groovy 自由(据我所知,出于良好的代码风格的原因)。
但是,Groovy++ 提供了许多语义扩展,例如非常复杂的类型推理系统、特征、扩展方法、函数式编程库等。
因此,我认为 Groovy++ 不仅仅是“Groovy 的子集”正如你所说。
Formally Groovy++ is just Groovy library. Groovy++ even have not any special syntax and uses Java-annotations.
But in fact Groovy++ is Groovy dialect (not new language of course).
@Peter Groovy++ forbids some Groovy libretys (as I have understood, by reasons of good code style).
But, Groovy++ provides many semantic extensions such as very complex types inference system, traits, extension methods, functional programming library, etc.
Because of this, I think what Groovy++ isn't just "subset of Groovy" as you have told.