哪些实际用例会导致替代 JVM 语言?
我最近在读Groovy,它与Java更相关。我没有任何动态语言的经验。我读到Groovy的创始人想要为现有的Java语言添加动态特性。我的问题是这样的。
Q1 提出像 Groovy 这样在 JVM 上运行的语言的令人信服的理由是什么。这引起了我的兴趣。请有人可以帮助我。
谢谢, 努万·阿兰巴奇
I was reading Groovy recently and it is more relates to Java.I don't have any experience in dynamic language.I have read that founder of Groovy want to add dynamic nature to existing Java language.My question is this.
Q1 what are the compelling reasons to come up with languages like Groovy running on JVM.It intrigued me.Please somebody can help me out.
Thanks,
Nuwan Arambage
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你这个问题是倒着问的。考虑到像 Groovy 或 Clojure 这样的语言的想法,如果它可以在广泛部署的运行时(例如 JVM)上运行,那么它被广泛采用的巨大障碍就被消除了。
You're asking the question backwards. Given the idea for a language like Groovy or Clojure, a huge impediment to it's widespread adoption is eliminated if it can run on a widely deployed runtime such as JVM.
的大量增强功能
对我来说,它具有普通 Java语法糖、闭包、常用数学和数学包含在内 。 i/o 库、JavaBean 功能、鸭子类型
有一些 - 它可能会花费一点性能开销,并且是最大的障碍,
重新使用架构良好的 Java 类
基本上它为您提供了 Ruby 人们喜欢的东西(非常简洁和富有表现力的脚本),同时遵守 Java 生态系统的所有方面,并在其中 事实上,既然 Groovy 1.8 即将推出,我已经完全停止编写 Java 了
它只是一个 jar 放到你的类路径中
就这么简单...
For me, its a plethora of enhancements not available in vanilla Java
syntax sugars, closures, inclusions of commonly-used math & i/o libraries, JavaBean features, duck typing
are some - it may cost a little performance overhead and is the greatest blocker
basically it gives you what Ruby people enjoy (dramatically terse and expressive scripts) while complying with all aspects of the Java ecosystem, and re-using well-architected classes Java
in fact I've already stopped writing Java altogether now that Groovy 1.8 is imminent
it is only a single jar drop into your classpath
that easy...
众所周知,Java 是非常强大的语言,但我们可以看到“某些东西”缺失了。众所周知,java是一种面向对象的编程语言。但事实是这样吗?你能对任何整数调用这个方法吗,比如“10.times..” 答案是“否”,你不能。但 Groovy 使 Java 成为完全面向对象的语言。在java中处理list,map是一些繁琐的任务,因为程序员需要这些非常简单,groovy就做到了。
更重要的是,groovy 易于阅读、维护,并且您的项目算法变成了精确的代码!
那就是“算法”=“groovy 代码”
我爱groovy!
As All know Java is very powerful language, but we can see "something" is missing. As all told java is an object oriented programming language. But is it so? Can you call the method on any integer like this "10.times. . " NO is the answer, you can't. But groovy makes Java as fully object Oriented language. And in java handling list,map are some tedious task, as the programmer need these to be very simple, groovy does that.
And more importantly, groovy is simple to read, maintain, and your algorithm of the project becomes the exact code!
That is "algorithm" = "groovy code"
I Love groovy!
我无法告诉您为什么存在其他语言,但我可以告诉您我是如何来到 Groovy 的。对我来说,当时有两点很重要:
* 如果你了解一些编程语言,Java 就很糟糕。它像对待小孩子一样对待你,而编译器就像你的母亲,不断地告诉你要做什么,而在涉及到更困难的领域时却会失败。
* 我需要一种脚本语言。那时的 Jython 和 JRuby 看起来已经死了,Beanshell 太像 Java 了。由于当时我主要编写 Java 程序,Groovy 对我来说几乎是自然的选择,因为它允许重用我的旧代码,而无需过多担心转换。
关于用例的问题有点难以回答,因为我的个人历史更多的是我的偏好之一。能够用更少的行编写更多的代码并不完全是一个用例,但原型设计与我和一个用例有关。在 Groovy 中,您通常可以更快地编写应用程序并交付原型。如果客户坚持,您通常可以轻松地将现有代码再次迁移到 Java。好处是,您可以在每个类的基础上执行此操作,因为 Java 和 Groovy 可以很好地交互。
I cannot tell you for why other languages exist, but I can tell you how I came to Groovy. For me two points where important back then:
* Java sucks if you know some programming languages. It handles you like a little child and the compiler is your mother continuously telling you what to do, while failing when it comes to the more difficult areas.
* I needed a scripting language. Jython and JRuby back then looked dead, Beanshell too much like Java. And since I mostly programed Java back then Groovy was the almost natural choice to me, as it allows to reuse my old code without bothering too much about conversions.
The question about use cases is a bit difficult to answer, since my personal history is more one of my preferences. Being able to write more code in less lines is not exactly a use case, but prototyping is related to me and a use cases. In Groovy you can then usually write an application more quickly and deliver your prototype. If the customer insists, you can usually easily migrate the existing code to Java again. The nice thing is, you can do this on a per class basis, since Java and Groovy interact well.