Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

scala - Scala vs. Groovy vs. Clojure [已结束](Scala vs. Groovy vs. Clojure [closed])

Can someone please explain the major differences between Scala, Groovy and Clojure. (有人可以解释Scala,Groovy和Clojure之间的主要区别。) I know each of these compiles to run on the JVM but I'd like a simple comparison between them. (我知道这些编译中的每一个都在JVM上运行,但我想在它们之间进行简单的比较。)

  ask by James Fassett translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Groovy is a dynamically typed language, whose syntax is very close to Java, with a number of syntax improvements that allow for lighter code and less boilerplate. (Groovy是一种动态类型语言,其语法非常接近Java,具有许多语法改进,允许更轻的代码和更少的样板。) It can run through an interpreter as well as being compiled, which makes it good for fast prototyping, scripts, and learning dynamic languages without having to learn a new syntax (assuming you know Java). (它可以通过解释器运行并进行编译,这使得快速原型设计,脚本和学习动态语言非常有用,而无需学习新语法(假设您了解Java)。) As of Groovy 2.0, it also has growing support for static compilation . (从Groovy 2.0开始,它对静态编译也有越来越多的支持。) Groovy supports closures and has support for programming in a somewhat functional style, although it's still fairly far from the traditional definition of functional programming. (Groovy支持闭包,并且支持以某种功能性编程的编程,尽管它仍然远离传统的函数式编程定义。)

Clojure is a dialect of Lisp with a few advanced features like Software Transactional Memory . (Clojure是Lisp的一种方言,具有一些软件事务内存等高级功能。) If you like Lisp and would like to use something like it under the JVM, Clojure is for you. (如果您喜欢Lisp并希望在JVM下使用类似的东西,那么Clojure就适合您。) It's possibly the most functional language running on the JVM, and certainly the most famous one. (它可能是在JVM上运行的功能强大的语言 ,当然也是最着名的语言 。) Also, it has a stronger emphasis on immutability than other Lisp dialects, which takes it closer to the heart of functional language enthusiasts. (此外,它比其他Lisp方言更强调不变性 ,这使得它更接近功能语言爱好者的心脏。)

Scala is a fully object oriented language, more so than Java, with one of the most advanced type systems available on non-research languages, and certainly the most advanced type system on the JVM. (斯卡拉是一个完全面向对象的语言,比Java更何况,用最先进的一个类型系统对非研究语言的版本,当然在JVM上最先进的类型系统。) It also combines many concepts and features of functional languages, without compromising the object orientation, but its compromise on functional language characteristics put off some enthusiasts of the latter. (它还结合了功能语言的许多概念和功能,而不会影响面向对象,但它在功能语言特性上的妥协使后者的一些爱好者失去了兴趣。)

Groovy has good acceptance and a popular web framework in Grails. (Groovy在Grails中具有良好的接受度和流行的Web框架。) It also powers the Gradle build system, which is becoming a popular alternative to Maven. (它还支持Gradle构建系统,该系统正在成为Maven的流行替代品。) I personally think it is a language with limited utility, particularly as Jython and JRuby start making inroads on the JVM-land, compared to the others. (我个人认为这是一种实用性有限的语言,特别是当Jython和JRuby开始在JVM-land上进行攻击时,与其他语言相比。)

Clojure, even discounting some very interesting features, has a strong appeal just by being a Lisp dialect on JVM. (Clojure,甚至折扣了一些非常有趣的功能,只是在JVM上成为一个Lisp方言,具有很大的吸引力。) It might limit its popularity, granted, but I expect it will have loyal community around it for a long time. (这可能会限制它的受欢迎程度,但我希望它能在很长一段时间内拥有忠诚的社区。)

Scala can compete directly with Java, and give it a run for its money on almost all aspects. (Scala可以直接与Java竞争,并在几乎所有方面为其付出代价。) It can't compete in popularity at the moment, of course, and the lack of a strong corporate backing may hinder its acceptance on corporate environments. (当然,它目前无法在人气中竞争,缺乏强大的企业支持可能会阻碍其在企业环境中的接受度。) It's also a much more dynamic language than Java, in the sense of how the language evolves. (从语言的演变来看,它也是一种比Java更具动态性的语言。) From the perspective of the language, that's a good thing. (从语言的角度来看,这是一件好事。) From the perspective of users who plan on having thousands of lines of code written in it, not so. (从计划在其中编写数千行代码的用户的角度来看,并非如此。)

As a final disclosure, I'm very familiar with Scala, and only acquainted with the other two. (作为最后的披露,我对Scala非常熟悉,并且只熟悉其他两个。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...