Live data from Hacker News

The Road to Scala 3

scala-lang.org

161–170 of 196 posts

Re: The Road to Scala 3

#161
post #101
post #75

Earlier quoted context omitted.

> 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…

If 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,…

> 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.

Re: The Road to Scala 3

#162
post #161
post #101

Earlier quoted context omitted.

If 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,…

> 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 separa…

An 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.

Re: The Road to Scala 3

#163
post #140

Earlier quoted context omitted.

> But I just mean that not every language needs to aim to be a top 5 language. I wonder about the extent to which this is true. One of my primary considerations in picking the language for a product is economic fit. Once you get outside of the top 10 or so, I think you need an especially strong set of niche-specific positives to offset the negatives of a small community. As an example, for fun I've been working on a…

> > But I just mean that not every language needs to aim to be a top 5 language. > I wonder about the extent to which this is true. One of my primary considerations in picking the language for a product is economic fit. Once you get outside of the top 10 or so, I think you need an especially strong set of niche-specific positives to offset the negatives of a small community. I think you have to take into account the…

Good point on the ecosystem. That definitely makes Scala more viable. I know I never would have tried it without that. Although I think that applies more to runtimes and (some) libraries than what I think the real drivers of cost are, like hiring and a community of practice (e.g., forums, mailing lists, and the likelihood of having the SO answer you need in your first few Google hits). And I think there's still a tax there; if you're doing a lot of Java interop you'll still have to know Java and the quirks of dealing with it from Scala.

Of course, there could be special-purpose stuff that's very nice not to have to rewrite. PDF generation comes to mind, as it's an enormous pain in the ass, and there are some good Java libraries for it. But it's often not much more work to encapsulate something like that as a service or a CLI tool.

Not to say people shouldn't do it, of course. But I'm not sure what Scala's niche should be as it shrinks. I originally saw it as a better Java, but I think Kotlin did a better job of is winning there. I get the impression that Clojure is doing better at "functional language on the JVM". Which is already a niche inside the FP niche. And given how much other languages have been learning from functional approaches, I don't know whether that niche is growing. I look forward to seeing if they find one.

Re: The Road to Scala 3

#164
post #87
post #2

When I gave up on Scala in 2016, I did so because its future looked fragmented and uncertain. Fast forward more than three years, and the first release of Scala 3 won’t be out until another year from now. Compare this with the pace of development of Go or Rust: those languages are driven by a vision, and have a dedicated team behind them. Scala is declining because no one could figure out for the longest time what wa…

Is it declining? Citation needed? I agree that Scala is not the new kid on the block anymore but I don't see it decline. When you look at the language rankings of the last few years, Scala seems to have settled at about ~12th place currently.

Scala is nowhere near the first 20.

Re: The Road to Scala 3

#165

Earlier quoted context omitted.

When?

Scalas insane generic type system would be an example of them going wrong. The current proposed Go method seems fairly reasonable.

I'll give an example of the Scala type system: let's define combining 2 integers as adding them together, then combining 2 lists of integers will give a new list where an element is the result of combining of 2 elements in the given 2 lists. Now we can make it a bit more generic: if a type A has a method combine, then 2 lists of elements of type A can be combined together to give a new list of which each element is from combining 2 elements in the 2 given lists.

How do you implement it in Go? It can be done in Java with generics, but if I make the problem a little bit more generic, a little bit more complicated, then I don't think Java can do it.

Re: The Road to Scala 3

#166
post #45

The way I look at modern Scala is a mix of Python and Java. Do it badly, and you end up with the unmaintainability of Python and the clunkiness of Java. Awful. Do it well, and you end up with the convenience and interactivity of Python and the typesafety, performance, and toolability of Java. This lets you implement your code quickly the first time, and have it run blazing fast on a hot JVM, with the compiler having…

I assume you don't have to use sbt builds because you use mill?

Also you mentioned command line tools. Any chance you could elaborate on how you distribute them?

Thanks

Re: The Road to Scala 3

#167

Earlier quoted context omitted.

> When using a Java library in Clojure, many times its just better to just write some Java for your Clojure program specifically for the purpose of calling it from Clojure. What? Calling Java from Clojure couldn't be any easier. The same as calling JavasScript from ClojureScript

From Cursive's author https://old.reddit.com/r/Clojure/comments/5twabp/new_clojuri...

Ok, that's fair enough, though one could argue this is about writing new java like code not accessing existing java code.

Re: The Road to Scala 3

#168
post #140

Earlier quoted context omitted.

> > But I just mean that not every language needs to aim to be a top 5 language. > I wonder about the extent to which this is true. One of my primary considerations in picking the language for a product is economic fit. Once you get outside of the top 10 or so, I think you need an especially strong set of niche-specific positives to offset the negatives of a small community. I think you have to take into account the…

Good point on the ecosystem. That definitely makes Scala more viable. I know I never would have tried it without that. Although I think that applies more to runtimes and (some) libraries than what I think the real drivers of cost are, like hiring and a community of practice (e.g., forums, mailing lists, and the likelihood of having the SO answer you need in your first few Google hits). And I think there's still a tax…

Yes, I agree with you, I think it's niche is probably going to shrink away from the "better java" and enterprise space but will probably hold up in the data science space as the only real counterpoint to Python for large scale distributed data processing. For people who for whatever reason want to use the JVM, or who need language performance that can't be achieved with Python, there isn't really anything else in the data science space to compete with it.

The killer problem for me is that you can't write a good library in Scala and have Java users adopt it. Because it uses its own collections etc, unless you build highly non-idiomatic Scala code, you will always end up with a huge impedence mismatch there. So while you can use libraries from java, you can't contribute to them, and your audience is always limited. Contrast with Kotlin or Groovy where you can write idiomatic Java-consumable libraries much more easily (esp. Groovy).

Re: The Road to Scala 3

#169
post #164
post #87

Earlier quoted context omitted.

Is it declining? Citation needed? I agree that Scala is not the new kid on the block anymore but I don't see it decline. When you look at the language rankings of the last few years, Scala seems to have settled at about ~12th place currently.

Scala is nowhere near the first 20.

Depends on the criteria and the group of companies you survey. In our customer survey done mostly among top 100 enterprises it comes at #3 very close to Python (which is #2), and it is much stronger in absolute numbers than C# or JS. And the trend is growing.

Of course, this is not representative to the whole market and heavily biased towards big companies with big backends that need to scale, but neither are Tiobe, GitHub or SO rankings.

Re: The Road to Scala 3

#170
post #133

Earlier quoted context omitted.

Yes, Kotlin seems to me like the future of Java.

Kotlin is not the future of anything. They got the Android boost and still, two years later, all they have to offer is a molasses-slow improvement pace and a shitty dev experience in their signature IDE (which also happens to be made by the same company). Last time I tried to create a Kotlin project in IDEA, it couldn't provide type information on hover. The Kotlin dialect of Gradle was barely supported enough to be…

Yeah, Jetbrains marketing wants you to think it is the other way round, but actually tooling support for Scala is ahead of Kotlin by far, except maybe Android.

Scala is not tied to a single IDE, it works great in VScode, Eclipse and Intellij and anything else that supports LSP, which is an open standard. And it works really well - including type inference and very advanced implicits stuff.

And recently Scala got excellent incremental compilation support by Bloop from ScalaCenter, which not only blows Kotlin out of the water but even Java with Gradle. The last year I develop purely in Java and I use Scala bloop for day-to-day development, because I couldn't stand multi-minute Gradle compile times. Getting incremental compile times counted in milliseconds (!) or single seconds at worst is something very hard to give up on.

Post reply on HN