4 ms·
One of the main problems with Scala is that it has a clusterfuck of niche use features, which even experienced developers have problem using. Scala core librar
by blackoil 9y ago
One of the main problems with Scala is that it has a clusterfuck of niche use features, which even experienced developers have problem using.
Scala core library is littered with :: +: and other nonsensical operators. Things like implicit may have few good use cases, but are mostly abused and make code hard to read. Blindly following immutability in even local function variables and stack makes code slow and unreadable.
- RBerenguel 9y agoEventually you get to understand these operators (and, after all they essentially mean append/concatenate/join in one sense or another... so it's basically add stuff to other stuff), and as for implicits, they make code much easier to follow if they are used sparingly and for good reasons. What makes Scala code (with implicits) hard to follow can be type classes, and understanding how all the pieces of the language fit together in these cases. As for immutability making things slow... Well, personally I start writing code for humans (and immutability makes the code much easier to read for humans). _If_ speed is an issue then I consider dropping immutability. So far have had no issues with Scala. Also depending on how much speed I need I wouldn't even think about using Scala.
- killin_dan 9y agoThat's what they say about perl. Keep trying and itll make sense! Granted, scala can be written to read much easier than perl, but that argument in particular don't carry much weight imo.
- RBerenguel 9y agoThe thing is, in Scala you can do really crazy and complicated stuff (see Shapeless, Cats, etc) that in other languages (with exceptions, of course) would be extremely hard or downright impossible. In Scala, it is just hard, but doable, but implies code being hard to read because what you are doing _is_ hard. This does not detract from doing as much as you can to make it readable, but sometimes it is impossible, or at least impossible to someone not used to it. I'm not good enough with Scala to understand some of it (yet, I hope) but this is something that is bugging me lately. Some things (in general, I'm not talking just about programming here) are hard. No matter how much sugar-coating, some stuff is hard to understand, complex and not everyone can get to the bottom of it. It just happens in some programming languages, happens in most of mathematics, physics and computer science.
- hhandoko 9y ago> Scala core library is littered with :: +: and other nonsensical operators. They are very useful. With the two you mentioned (:: and +:) they can be used for pattern matching in addition to concatenation (of a list / sequence), for example: scala> val list = 1 :: 2 :: Nil list: List[Int] = List(1, 2) scala> val x = list match { | case head :: _ => head | case _ => 0 | } x: Int = 1 scala> val seq = 1 +: Seq(2, 3) :+ 4 seq: Seq[Int] = List(1, 2, 3, 4) scala> val y = seq match { | case a +: _ :+ b => a + b | case _ => 0 | } y: Int = 5 It can be a bit confusing at first, especially for mutable vs immutable collection operators. But you end up remembering some, if not most of it, after using them a number of times.
- blackoil 9y agoand that's what I meant, when I said niche use cases. You can replace all operators with names and still have no difference. At some places code will be verbose, but on whole code will be more readable. Another example if you want is http://www.scala-lang.org/api/2.9.2/scala/sys/process/ProcessBuilder.html http://www.scala-lang.org/api/2.9.2/scala/sys/process/Proces.... All operators can be replaced by completely readable names like run, build, read, write. Scala on whole is optimized to have lesser no. of characters in code, in contrast to verbosity of Java. Case classes and lambdas are what good came out of it, I understood the concept and now I can use them. Operator overloading and Implicit are what move pendulum to other side, they are not some novel concept and make very readable code, unreadable.
- cheriot 9y agoWhy do we use operators at all? We can just as easily write out plus, minus, multiply, and divide. Concatenating to a list and pattern matching are extremely frequent operations in Scala. Some of the operators they use have been in use for decades in the languages that influenced Scala. Like many features across many languages it can be taken too far at times and people that enjoy Scala talk about them all the time. That said, the similarities of your example to operators I use at the command line every day makes it nice to read for me.
- 9y ago