5 ms·
The fact that it takes so much intimate knowledge of how the collections are implemented to get some decent performances in Scala is probably one of the many re
by eta_carinae 14y ago
The fact that it takes so much intimate knowledge of how the collections are implemented to get some decent performances in Scala is probably one of the many reasons why this language hasn't taken off.
- monkeyfacebag 14y agoI agree in principle that one shouldn't have to understand the implementation of collections to use them effectively, but these limitations are by no means exclusive to Scala. Haskell's lists, difference lists and seqs work exactly the same way as Scala's list collections. Iteratively concatenating strings in Python will murder your performance. Most (all?) sufficiently complex systems involve tradeoffs.
- irahul 14y ago> Iteratively concatenating strings in Python will murder your performance. Understanding immutable strings aren't at the same level. People concatenate immutable strings all the time in Java/Python, but that is despite the documentation mentioning immutability and proper concatenation method(StringBuffer followed by toString, list.append() followed by " ".join(list))
- monkeyfacebag 14y ago> despite the documentation mentioning immutability and proper concatenation method What-do-you-know, Scala has documentation too[1]! And it mentions that appending to a List is O(n). [1] http://www.scala-lang.org/api/current/scala/collection/immutable/List.html http://www.scala-lang.org/api/current/scala/collection/immut...
- anorwell 14y agoData structures have inherent time and space complexity tradeoffs. This is just as true in C as it is in Scala.
- nessus42 14y agoI'm not sure what you mean by "hasn't taken off". Scala is pretty thriving in these parts: I.e., we use Scala where I work. Headhunters contact me about open Scala positions. A few months back there was a Scala symposium down the street that had several hundred attendees. There is a local user group that is "sold out every month. I.e., the room holds 75 people, and more than that number always wants to attend. Etc. It takes a long time for a new general purpose programming language to displace existing general purpose programming languages if it doesn't fill a very particular niche for which there is a great demand. Re performance, I recently implemented an algorithm in Scala that performs quite well. It didn't at first, but it was very easy for me to profile it using Java profiling tools and to tighten a couple of loops where most of the CPU was being consumed. I don't have any deep knowledge of Scala collections, but I know how to use a profiler. I don't think the initial implementation would have performed any better if it had been written in Java. Once I had gotten things speedy enough, I was further able to speed everything up by 4X just by changing a collection to the parallel version of the collection. Then all four cores could crunch on it. If I had 8 cores, it would have no doubt run 8X faster. That parallelization came from tweaking only one line of code! I would have never achieved this 4X speedup in Java.