Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does type inference slow down auto-completion in the IDE

When using Scala for the first time in an IDE (Idea) I noticed that auto-completion is markedly slower, then when coding java. Although some of the slow-down may owe itself to relative immaturity of the scala tooling ecosystem at the time, I suspect that some of this slowdown may be an inherent property of the algorithmic complexity of parsing code that requires type inference.

java:

MyType type; type.doSomething() //Class of type already known

scala:

val type = new MyType; type.doSomething() //Class of type must be inferred or cached

Although languages which have type inference are a lot more succinct (and therefore easier to read), does this come at the expense of slower tooling? Is there an inherent trade-off?

like image 560
murungu Avatar asked Feb 03 '16 13:02

murungu


1 Answers

Yes.

To some extent, Scala is unavoidably slower. One of the costs of having inferred types, implicits and syntactic sugar is compile times. The exact times can be improved, but Scala will always compile slower than for ex.java.

Personally, I gladly make this trade-off. Having a clean and readable code base is a lot more important to me than compile times (which which are often under 1 sec if incremental compilation is used).

like image 134
VasiliNovikov Avatar answered Oct 25 '22 02:10

VasiliNovikov