3 ms·
I currently write Scala at work. As far as I can tell, it's a lot like C or C++, except that you have to use while loops instead of for loops and you have to p
by anonymoushn 15y ago
I currently write Scala at work. As far as I can tell, it's a lot like C or C++, except that you have to use while loops instead of for loops and you have to perform unholy incantations to fake arrays of structs. If you don't do this, you can either try to allocate a few hundred million tuples and OutOfMemoryError, or you can allocate one array of a primitive for each field of the struct and give up on the idea of having decent cache locality. It's less capable of TCO than gcc, which is pretty hilarious for a functional programming language. Generic programming in Scala is lots of fun until you try to use an Ordering[Double] or an ArrayBuffer[Double] in a critical path.
Manageable parallelism is nice, though.
- soc88 15y agoAlmost every problem you mention is a problem of the underlying runtime. Are you sure you bash the right thing?
- anonymoushn 15y agoThis is true. The only things that are trivial to fix are the absence of for loops and the use of ArrayBuffer[AnyRef] to implement ArrayBuffer[Double]. It might also be possible to make TCO of mutually recursive final methods work, but it's probably more trouble than it's worth.
- soc88 15y agoAren't for loops already fixed since months? (see https://github.com/scala/scala/commit/4cfc633fc6cb2ab0f473c2e5141724017d444dc6 https://github.com/scala/scala/commit/4cfc633fc6cb2ab0f473c2...) Regarding ArrayBuffer: It is not as easy as it looks like, because of the conflicting nature of Arrays vs. Generics (yet another JVM problem). Amusingly I tried using Manifests to do exactly that last week. I hit the wall because the Manifests seemed to spread arbitrarily. Will try with TypeTags/macros when they become available.
- anonymoushn 15y agoI'm glad to learn that they're fixed for Range. Thanks.