本文介绍了Java 编译速度与 Scala 编译速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我已经在 Scala 中编程了一段时间,我喜欢它,但让我烦恼的一件事是编译程序所需的时间.这似乎是一件小事,但是使用 Java 我可以对我的程序进行一些小的更改,单击 netbeans 中的运行按钮,然后 BOOM,它正在运行,随着时间的推移,在 Scala 中编译似乎会消耗很多时间.我听说在许多大型项目中,脚本语言变得非常重要,因为编译需要时间,而我在使用 Java 时并没有看到这种需求.

I've been programming in Scala for a while and I like it but one thing I'm annoyed by is the time it takes to compile programs. It's seems like a small thing but with Java I could make small changes to my program, click the run button in netbeans, and BOOM, it's running, and over time compiling in scala seems to consume a lot of time. I hear that with many large projects a scripting language becomes very important because of the time compiling takes, a need that I didn't see arising when I was using Java.

但我来自 Java,据我所知,Java 比任何其他编译语言都快,而且由于我切换到 Scala(这是一种非常简单的语言)的原因,速度很快.

But I'm coming from Java which as I understand it, is faster than any other compiled language, and is fast because of the reasons I switched to Scala(It's a very simple language).

所以我想问一下,我能不能让 Scala 编译得更快,并且 scalac 会和 javac 一样快.

So I wanted to ask, can I make Scala compile faster and will scalac ever be as fast as javac.

推荐答案

Scala 编译器比 Java 更复杂,提供类型推断、隐式转换和更强大的类型系统.这些功能不是免费提供的,所以我不希望 scalac 像 javac 一样快.这反映了执行工作的程序员和执行工作的编译器之间的权衡.

The Scala compiler is more sophisticated than Java's, providing type inference, implicit conversion, and a much more powerful type system. These features don't come for free, so I wouldn't expect scalac to ever be as fast as javac. This reflects a trade-off between the programmer doing the work and the compiler doing the work.

也就是说,从 Scala 2.7 到 Scala 2.8 的编译时间已经有了明显的改善,我希望随着 2.8 的尘埃落定,这些改进会继续下去.本页记录了一些正在进行的改进 Scala 编译器性能的努力和想法.

That said, compile times have already improved noticeably going from Scala 2.7 to Scala 2.8, and I expect the improvements to continue now that the dust has settled on 2.8. This page documents some of the ongoing efforts and ideas to improve the performance of the Scala compiler.

Martin Odersky 在他的回答中提供了更多细节.

这篇关于Java 编译速度与 Scala 编译速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:30