嵌入式 scala 与嵌入式 Groovy
我正在为我的应用程序搜索嵌入式语言。用纯 scala 编写的应用程序。我想在运行时添加一些功能。我有一个问题,scala嵌入比groovy嵌入更快吗?
i'm searchin embedded language for my application. application writen in pure scala. i want to added some functional at runtime. and i have question, is scala embedded more faster than groovy embedded ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不会添加另一种语言,scala 非常适合脚本编写。就速度而言,我猜 scala 通常比 groovy 更快(shootout.alioth.debian.org 上有旧的基准测试,但不知何故 groovy 似乎已经从当前基准测试中退出了?)。然而,响应能力并不是最优的,也就是说,正如您所知,运行用于 scala REPL 的“解释器”是一个动态编译的编译器。这对于实际编译来说会有一点延迟,但执行速度与正常编译的 scala 一样。在现代计算机上,您将不再注意到这种延迟。
有几个构建在 scala REPL 之上的小工具。使用一种语言的另一个优点可能是,将符号绑定到解释器可能会更容易,因为所有 scala 特定的东西(例如合成方法、伴随对象等)都是透明可见的。
编辑:虽然原始帖子是 2009 年的,但评论中散布着来自最近的 scala 2.8 和 groovy 1.7 的基准,显示仍然存在很大的差异:http://stronglytypedblog.blogspot.com/2009/07/java-vs-scala-vs-groovy-performance.html< /a>
i would not add another language, scala is great for the scripting. speed-wise i guess scala is typically faster than groovy (there are old benchmarks on shootout.alioth.debian.org, but somehow groovy seems to have dropped out from the current benchmarks?). however responsiveness is suboptimal, that is, as you may know, running the "interpreter" used for scala REPL is a compiler that compiles on the fly. this comes with a bit of latency for the actual compilation, but then the execution speed is just as normal compiled scala. on contemporary computers you won't notice this latency any more.
there are several little tools built on top of the scala REPL. another advantage of staying with one language might be that it gets probably easier to bind symbols to the interpreter, as all scala specific stuff (such as synthetic methods, companion objects etc.) are transparently visible.
edit: although the original post is from 2009, there are benchmarks from the recent scala 2.8 and groovy 1.7 spread across the comments, showing still a magnitude in difference: http://stronglytypedblog.blogspot.com/2009/07/java-vs-scala-vs-groovy-performance.html
据我所知,已经做了一些努力来实现 Java API(脚本语言支持,JSR 223),这是使用“作为脚本语言”的语言所必需的,但我不确定效果如何。
Scala 总体上比 Groovy 更快,因为它更接近 JVM 可以快速执行的习惯用法。
但 Groovy 实际上是 JVM 的脚本语言之一。还应该支持一起构建 Java/Scala/Groovy 文件,这样就不会产生问题。
As far as I know, there was some effort to implement the Java API (Scripting language support, JSR 223) which is necessary to use languages "as scripting languages", but I'm not sure how well that worked out.
Scala is overall faster than Groovy, because it stays more closely to the idioms which the JVM can execute fast.
But Groovy is really one of the scripting languages for the JVM. There should be also some support for building Java/Scala/Groovy files together, so that should not create problems.