3 ms·
But is the bytecode generated by Java more efficient than the one generated by Scala (in comparable situations ofc) ? And which reasons would make you choose J
by pedrorijo91 11y ago
But is the bytecode generated by Java more efficient than the one generated by Scala (in comparable situations ofc) ?
And which reasons would make you choose Java over Scala?
- kasey_junk 11y agoI'm not comfortable answering that generally. That said, bytecode generation was never the major issue, though I did find some cases where seemingly identical implementations would be faster/slower in one compiler or the other. Much more troubling: - Some Scala idioms are just not as performant as the naive java implementations. Function passing can create lots of objects for instance. - Some of Scala's "magic" features that allow for terse-ness can behind the scenes cause performance issues, that you might not expect without a clear understanding of what is going on. Implicit conversions for instance can also create tons of garbage. - The Scala collections library, while improving some, has lots of performance gotchas. Collections that don't match modern hardware or implicit conversions that de-optimize operations can happen pretty easily. Personally, I would choose Java over Scala if any of the following were true: - You were going to have many different versions of your software in the wild. - You had a constrained release cycle. - You intended for artifacts to exist for long periods without change. - You had specific backwards compatibility requirements. - You had a large team. - You had a team of highly varying skill sets. That is to say, I'd only pick Scala if I were working on a project where I controlled the life cycle of the product, releases were common, backwards compatibility was not an issue, and my team was small, cohesive and experienced. If those things weren't true, I might not pick Java, but I certainly wouldn't pick Scala.