4 ms·
> Java teams across the world are not at least seriously considering changing to Scala. I've used Scala before. It has challenges that would make it a non-star
by apta 7y ago
> Java teams across the world are not at least seriously considering changing to Scala.
I've used Scala before. It has challenges that would make it a non-starter for many teams. It has some cool features, but those (IMO) don't outweigh the negatives that come with the language: it's overly complex (different people have very different styles for writing the language), the compiler is slow, it generates more garbage than Java, lots of implicit behavior, the standard library is not up to par, among others. Java is improving significantly in the coming few releases: pattern matching, records, switch expressions, etc. will bring to programmers the bulk of what Scala has to offer without the added weight. Kotlin is a much better contender for most teams anyway, and even that will be a challenge IMO.
- dxxvi 7y agoIf I read it correctly, you said "Scala standard library is not up to par", "Java is improving significantly in the coming few releases: pattern matching, records, switch expressions". I see the other way around: Java 14 records, pattern matching and switch expressions are like a joke compared to Scala case class and pattern matching. For example, does Java 14 Stream have any method equivalent to `collect` in Scala, which is a combination of filter and map?
- apta 7y ago> Java 14 records, pattern matching and switch expressions are like a joke compared to Scala case class and pattern matching. What does Scala's pattern matching do that Java's (upcoming) doesn't? > For example, does Java 14 Stream have any method equivalent to `collect` in Scala, which is a combination of filter and map? Not that I'm aware, but then again, I don't see the large advantage compared to making two separate map + filter calls. Streams in Java are lazy, whereas calling `map` or `filter` on a concrete collection in Scala is eager, creating temporary intermediate collections only to discard them in the case of chaining calls.
- dxxvi 7y agoAn example of Scala's pattern matching: case class Person(name: String, age: Int) // a collection of 3 people val c1 = Vector(Person("A", 5), Person("B", 6), Person("C", 4)) // now I want a collection of people who have age > 4 and then their ages are doubled val c2 = c1 collect { case Person(name, age) if age > 4 => Person(name, age*2) } How do you write it in Java 14? Want something lazy like Java streams? It's LazyList in Scala 2.13 and Stream in Scala < 2.13.
- sorokod 7y agoIn Kotlin data class Person (val name: String, val age: Int) val c1 = listOf(Person("A", 5), Person("B", 6), Person("C", 4)) val c2 = c1.filter{ it.age > 4 }.map{ it.copy(age = it.age*2) }
- dxxvi 7y agoKotlin and Java don't have a powerful pattern matching like Scala. Maybe that's why they don't have `collect` for filter + map. However I'm learning kotlin now because my employer doesn't allow me to use Scala
- eweise 7y agoWhat part of Scala 3 do you think is overly complex? From what I understand, it mostly simplifies the language.
- oxnrtr 7y agoIt absolutely does not. It removes a few things and adds a whole lot of new stuff to it. It's a bigger, more complex language, even if you credit all the cleanups that were already in Scala 2 to Scala 3.