|
Type erasure is an interesting discussion, because functional programmers love type erasure. Consider the function: def foo[T](t: T): T
If the function is truly generic, then we know nothing about the implementation details of T. The only meaningful implementation of foo is identity: def foo[T](t: T): T = t
From a FP perspective, T should be erased, and the programmer should not cheat and use reflection. The type signature should tell you much about what the function does.I've used Scala professionally for the last 8 years. The tooling is fine, assuming you avoid exotic libraries like Shapeless. Compile times are fast enough that I don't think about it much, using IntelliJ incremental compilation. A full recompile of a micro service might take 30 seconds, whatever it is is not a big deal IMO. > opening projects in an IDE like IDEA could take up to 30 min on high end workstations This is insanely wrong. Maybe you are operating on experiences from 10 years ago? I have a new M2 MacBook Pro, and opening projects is quite fast. The first time you do it, it will resolve the SBT dependencies and index files. That can be done in the background, and is probably less than a minute for a typical project. Even my previous laptop could open projects quickly despite being 3 years old. > the Scala data structures have been at least an order of magnitude slower than the JVM native ones They are slower, but not an order of magnitude slower. Perhaps you are remembering the infamous email from the Yammer CTO that got leaked, but that was a long time ago, and the compiler and libraries have improved greatly since then. But yes, in performance critical code, you can just switch to an imperative style and use Java collections. I don't have time to explain the benefits of Scala features, but I'll just point out that other than implicits, many ML inspired features of Scala have made their way into modern languages, including Java, C#, Rust and Swift. Scala didn't invent those ideas, but repackaged them in a novel way. |
Concerning your type erasure example, the id function obviously doesn't need to know anything about types. In the real world, types have traits/interfaces/expected attributes etc. and type erasure prevents the compiler to verify this when using binary dependencies, which is obviously _not_ what one wants in a statically compiled language.