Hacker News new | ask | show | jobs
by erton23 2261 days ago
Unfortunately, I slowly got frustrated reading the what's coming for Scala 3.

* True intersections and union types -- use them sometimes, not something you can't live without though.

* Trait parameters -- slightly easier life for OOP, ok I guess.

* Function types and implicit function types -- right, will make your code even harder to read (subjective).

* Generic tuples -- again, I can't remember we ever had problems with tuples in Scala.

* Opaque types -- another small OOP improvement.

* Type lambdas -- I've never seen them used.

* Erased parameters -- probably useful if it improves performance even at the cost of readability right?

* Enums -- finally something practical, good.

And that's all about major changes in Scala 3. Ah, yes, we get a new compiler. Are you excited?

These changes look like a quarterly release than a major version shift. Now, imagine a project manager who's estimating the migration downtime for Scala 2 for the sake of the above.

4 comments

Trait params have little to do with OOP.

Opaque types are not a "small OOP improvement", they finally bring zero-cost newtypes to Scala, superseding value classes. Now you can finally ensure that object Ids, people's names, meters, feet, and degrees Celsius all have different types - without any extra boxing at runtime.

Your list is also missing typeclass derivation, which is going to be a fantastic quality of life improvement. Yes, even for people who don't care about what a typeclass is.

This is a point I want to stress the most, I think. Features like type lambdas, or libraries like Shapeless - they can possibly be extremely beneficial to you even if you don't use them directly in your code. Ask your nearby Haskell programmers about the virtues of `deriving (Eq, Ord)` and they'll talk your ear off. And that's before they even get to things like `deriving (FromJSON, ToJSON)`. Don't have a Haskell programmer nearby? It's ok, ask a Rust programmer about Serde instead. Typeclass derivation is just such a massive, massive feature to have in your language's repertoire.

Well. You also get better binary compatibility and the possibility to do whole program analysis.

Edit: oh. And this is on top of a rewritten, faster, compiler, a unified base paradigm making it easier to learn the language, and better error messages for compile errors. I think dismissing this as as minor release is disingenuous to how much effort goes in such a large scale rewrite. Granted, most of it is under the hood but it will pay off dividend.

Scala 3 could improve on 2.x struggles with supporting JDK 9 and up:

Support features of JDK 11+ https://github.com/scala/scala-dev/issues/139

Support Java Module System https://github.com/scala/scala-dev/issues/529

In comparison language features seem to attract much more attention:

Removing existential types https://contributors.scala-lang.org/t/proposal-to-remove-exi...

Significant indentation syntax https://github.com/lampepfl/dotty/pull/7083

That is a good example why betting on the platform languages is always a long term safer bet than betting the house on guest languages,

Eventually they won't keep up with the underlying platform.

It's not like it isn't working. Scala runs fine on JDK13 (probably 14 too, but we currently run one Play project in prod on 13).

Java is a pretty safe bet, as it has an outstanding backward compatibility track record.

Yup. I jumped ship for Swift a while ago.