Live data from Hacker News

Scala 3.0

github.com

111–120 of 292 posts

Re: Scala 3.0

#111
I'm in need of a functional language for a small part of my system and I'm considering Scala and Purescript[0] (mostly because of their ecosystems). Maybe Scala 3 is a good time to be boarding Scala's ship.

I'd appreciate if anyone has any advices of one vs the other.

[0]https://www.purescript.org/

Re: Scala 3.0

#112
post #44

Earlier quoted context omitted.

I think apart from streams it was Kotlin that did the trick.

Java has not picked up a single feature from Kotlin yet (maybe nullability types someday?), and, in fact, opted for very different ones (e.g. contrast records vs. data classes, virtual threads vs. syntactic couroutines), although I guess Scala has provided some inspiration for some features, as Java's are closer to Scala's than to Kotlin's. ML is probably the biggest influence, with some Haskell flavour. But I find i…

> ML is probably the biggest influence

I disagree.

Java records are from Standard ML but sealed is not, it's from Scala with the improvement that subtypes of a sealed types are sealed too.

Java still not have a real syntax for ADT, Standard ML has datatype, Rust or Scala 3 have enums on steroid [1].

[1] https://dotty.epfl.ch/docs/reference/enums/adts.html

Re: Scala 3.0

#113

I think the best evolution of a programming language is when some features are removed and replaced by a unifying concept which makes the language both smaller and and more expressive. Has that happened in Scala 3?

Yes! See the redesigned implicits [1] and macros [2].

[1]: https://dotty.epfl.ch/docs/reference/contextual/motivation.h...

[2]: https://dotty.epfl.ch/docs/reference/dropped-features/macros...

Re: Scala 3.0

#114

Looking at the new features. Can anyone say what dependent function types are good for? In the example ( https://dotty.epfl.ch/docs/reference/new-types/dependent-fun... ), what's the difference between: def extractKey(e: Entry): e.Key = e.key and: def extractKey(e: Entry): Entry.Key = e.key // the way I'd normally think of it

With dependent types, each `e.key` has it's own and separate type. So, if you have two `e`s, the type of the first e's key will not match the type of the second e's key.

So, with:

def process(p: Path, key: p.Key): Something = ???

this will not compile:

val p1: Path = ???

val p2: Path = ???

process(p1, p2.key) <- compile-time-error

Re: Scala 3.0

#115
post #44

Earlier quoted context omitted.

Java has not picked up a single feature from Kotlin yet (maybe nullability types someday?), and, in fact, opted for very different ones (e.g. contrast records vs. data classes, virtual threads vs. syntactic couroutines), although I guess Scala has provided some inspiration for some features, as Java's are closer to Scala's than to Kotlin's. ML is probably the biggest influence, with some Haskell flavour. But I find i…

> ML is probably the biggest influence I disagree. Java records are from Standard ML but sealed is not, it's from Scala with the improvement that subtypes of a sealed types are sealed too. Java still not have a real syntax for ADT, Standard ML has datatype, Rust or Scala 3 have enums on steroid [1]. [1] https://dotty.epfl.ch/docs/reference/enums/adts.html

Java records and sealed types are its interpretation of product and sum types, and, true, this interpretation draws inspiration from Scala's. Deconstructing patterns are coming soon, but Java now does have real syntax for ADTs:

    sealed interface Expr {}
    record ConstantExpr(int i)       implements Expr {}
    record PlusExpr(Expr a, Expr b)  implements Expr {}
    record TimesExpr(Expr a, Expr b) implements Expr {}
    record NegExpr(Expr e)           implements Expr {}
For non-record classes, deconstructing patterns will be something like a dual to methods, and almost a first-class citizen. Among other things, they will allow patterns to support API designs that predate records and sealed types.

Re: Scala 3.0

#117
post #111

I'm in need of a functional language for a small part of my system and I'm considering Scala and Purescript[0] (mostly because of their ecosystems). Maybe Scala 3 is a good time to be boarding Scala's ship. I'd appreciate if anyone has any advices of one vs the other. [0] https://www.purescript.org/

I wouldn't jump on the Scala 3 ship just yet. Maybe if mostly a learning project but not for an important part. Whilst it was not a surprise release there will be long time until a majority of the libraries and frameworks will also work with it.

The big ones are mostly there, but there are lots of smaller ones that are not and there will be teething problems, even after a long alpha-beta-rc train. Scala 2.13 is still great.

Re: Scala 3.0

#118
post #85

Earlier quoted context omitted.

> Scala is not perfect but it’s very good. I like to refer to it as Haskell with an extra chromosome: slow, hard to comprehend, and incredibly strong. I'm lucky enough to write it in my day job and I feel like I'm living life on easy mode because of it. It'd take a lot of money to lure me back to garbage like Python/JS at this point.

> I like to refer to it as Haskell with an extra chromosome: slow, hard to comprehend, and incredibly strong. that's a weird and offensive thing to say

Didn't know that Scala was so easily offended. :D

Re: Scala 3.0

#119
So, they removed implicits and introduced a number of other tools to replace common usecases for implicits.

Can we take a step back now, and reflect on what was the original problem implicits were designed to solve and how it is solved now in Scala 3? I've heard the original problem was that they wanted a chain of functional transformations to return the same type of collection (unlike, say, Clojure or Java 9 which return a Stream).

Post reply on HN