Live data from Hacker News

Scala 3.0.0-M1

github.com

91–100 of 148 posts

Re: Scala 3.0.0-M1

#91
post #4

I've always loved Scala and Scala 3 is shaping up to be extremely exciting. Love the new ADTs and braceless syntax: really gives the language a cleaner and more ML inspired feel. No other conventional language (including OCaml, F#, etc) seem to have the effortless kind of power Scala does. The combination of the extremely powerful type system with the "OOFP" paradigm is a great combination. OOFP is such a great parad…

Scala is weird. Sometimes it feels fluid and effortless but sometimes it simply cannot do things you would expect it to. For example, chaining custom methods. Why is it possible to do "arr.map(_.nonEmpty).filter(a => a % 2)" but not possible "arr.map(_.nonEmpty).myCustomFilter(_)"? In D thanks to UFCS and Properties you can chain all kinds of std and custom stuff together which looks more "efforless" and FP in my eye…

> Rust which simply has a wider applicability area

Rust is a great language but that's a pretty insane statement. The ecosystem is still tiny compared to the JVM.

Re: Scala 3.0.0-M1

#92
post #76

Earlier quoted context omitted.

It's not really black magic https://docs.scala-lang.org/overviews/core/implicit-classes.... but I don't really see why having a filter as a method should even be encouraged.

Implicits are not encouraged in our code base and for a good reason. This was just an example. It's not about filter at all but the general method chaining. Here is example from D if I must: real[] fun(int[] arr) { return arr.map!(a => a.to!double / PI).array; } void main() { int[] arr = 100.iota.array; // [0, 1, 2, 3, ...] real[] newArr = arr.map!(a=> a*2).array.fun); // [0, 0.63662, 1.27324, ...] } I don't know how…

Scala is more strict than D for this use case. In Scala, if you want a function to be available to a certain type as if it was a method call, you need to be explicit about it. You have to declare an "implicit class" that takes the base type as an argument, and define the function as a method of the implicit class. You also need to ensure the implicit class is in scope. Once these conditions are met, you can use it as a method.

    val t1 = MyType()
    def fun(t: MyType, argument: Int) = argument

    // can't do this yet
    // t1.fun(42)
    
    // In Scala 2 you use an implicit class to add methods to a type
    implicit class MyEnrichedType(t: MyType) {
      def fun(argument: Int) = fun(t, argument)
    }

    // In Scala 3 you use an extension
    extension (t: MyType)
      def fun(argument: Int) = fun(t, argument)
    
    // now it can be done
    t.fun(42)
Regarding your question about the stdlib methods being able to be chained: they are not special. They are defined for the type the methods return, so they can be used.

Rejecting all kinds of implicits and then complaining about Scala missing features is a bit unfair. "Implicit"is a single keyword, but not a single feature. Implicit arguments, implicit conversions and implicit classes are not the same thing. Fortunately, Scala 3 will clear this misunderstanding.

Re: Scala 3.0.0-M1

#93

Earlier quoted context omitted.

Implicits are not encouraged in our code base and for a good reason. This was just an example. It's not about filter at all but the general method chaining. Here is example from D if I must: real[] fun(int[] arr) { return arr.map!(a => a.to!double / PI).array; } void main() { int[] arr = 100.iota.array; // [0, 1, 2, 3, ...] real[] newArr = arr.map!(a=> a*2).array.fun); // [0, 0.63662, 1.27324, ...] } I don't know how…

Ah, I understand what you mean now. You are looking indeed for the thrush operator. I think it should be built into Scala's standard library, but until that happens, you can use the mouse library or build it yourself. Here is an example: // Need to define this once somewhere in your project implicit class TrushExtension[A](anything: A) { def |>[B](function: A => B) = function(anything) } // Your application code def…

If you would call it pipe operator, like it's called in many (Elm, Elixir, F#, OCaml) other languages that have it, people would understand you faster IMHO. It is even discussed for inclusion into JavaScript.

Re: Scala 3.0.0-M1

#94
post #4

I've always loved Scala and Scala 3 is shaping up to be extremely exciting. Love the new ADTs and braceless syntax: really gives the language a cleaner and more ML inspired feel. No other conventional language (including OCaml, F#, etc) seem to have the effortless kind of power Scala does. The combination of the extremely powerful type system with the "OOFP" paradigm is a great combination. OOFP is such a great parad…

Scala is weird. Sometimes it feels fluid and effortless but sometimes it simply cannot do things you would expect it to. For example, chaining custom methods. Why is it possible to do "arr.map(_.nonEmpty).filter(a => a % 2)" but not possible "arr.map(_.nonEmpty).myCustomFilter(_)"? In D thanks to UFCS and Properties you can chain all kinds of std and custom stuff together which looks more "efforless" and FP in my eye…

> compiling times force you to leave your seat for a cup of coffee

This is not the case in a codebase split into multiple modules that compile in parallel.

Re: Scala 3.0.0-M1

#95
post #12
post #7

Earlier quoted context omitted.

For me scala's feature set is absurdly big and there are always 10 ways todo things. Look at the spec of Scala. Its 200 pages long. That's insane. I'd rather use Kotlin.

The Kotlin spec is... 275 pages: https://kotlinlang.org/spec/pdf/kotlin-spec.pdf

And 796 pages for Java https://docs.oracle.com/javase/specs/jls/se14/jls14.pdf

Re: Scala 3.0.0-M1

#96
The Scala language is great but the ecosystem sacrifices simplicity for pure FP. Scala has always suffered from complexity problems due to libraries. For example, using Http/JSON/Database libraries have always been a lot harder than they need to be due to a die hard approach to pure FP.

Scala 3 looks pretty good, but I just can NOT see myself using Scala again, after having worked with it for 4-5 years at work and on personal projects. I write mostly/reasonably FP code without using Cats/Category theory. I’ve recently moved all my code from Scala to Kotlin and I’m loving it, found the perfect balance with Kotlin.

Re: Scala 3.0.0-M1

#97

Earlier quoted context omitted.

Scala is weird. Sometimes it feels fluid and effortless but sometimes it simply cannot do things you would expect it to. For example, chaining custom methods. Why is it possible to do "arr.map(_.nonEmpty).filter(a => a % 2)" but not possible "arr.map(_.nonEmpty).myCustomFilter(_)"? In D thanks to UFCS and Properties you can chain all kinds of std and custom stuff together which looks more "efforless" and FP in my eye…

> Rust which simply has a wider applicability area Rust is a great language but that's a pretty insane statement. The ecosystem is still tiny compared to the JVM.

Rust is a great language, and Scala is a great language, but they are different. They optimize for a different thing. Rust definitely rocks at high-performance, resource management, fine grained control over all the aspects of the program, at the expense of developer's time. Scala rocks at developer productivity and building abstractions, sacrificing a bit of performance.

However, I must say that Rust is also a very productive and quite powerful language (albeit IMHO not as powerful as Scala) and Scala is actually not that bad at performance either - probably better than a vast majority of other languages out there (albeit not as powerful as Rust or C++).

As far as ecosystems are considered - this is really hard to say. Rust has the whole C (and most of C++) ecosystem at hand plus a few really amazing Rust solutions like Cargo. Scala is limited mostly to JVM and JS, which are great ecosystems, but it is not true they offer everything. And there are still some caveats when using Java tools with Scala (e.g. profilers, debuggers or build systems).

Re: Scala 3.0.0-M1

#98
Very, very excited about Scala 3. Here are some of the things I'm looking forward to using:

* Generally a more clean language for everyday use, codifying existing patterns like newtypes (opaque types), typeclass derivation and extension methods

* Improved type inference & lots of other quality of life improvements

* A macro system based on the idea of multi-stage programming. This has a lot of potential for improving both type-safety and performance. An example: beating existing database systems query optimization with ~500 lines of Scala code [1]

* TASTY, a new intermediate representation (AST) for artifacts. This means that Scala will have a much better version upgrade / binary compatibility story in the future. (e.g. TASTY is used for facilitating 2.13 3.0 bi-direction upgrade!)

* Significant compile time improvements over Scala2 alraedy[2] (and we're only at M1 release)!

Scala has already been a wonderful language to work with professionally with many great tooling (linting, automatic migration, 2 good OSS IDEs), and I think Scala 3 will certainly push the state-of-the-art forward in many departments in the coming years.

[1]:https://www.cs.purdue.edu/homes/rompf/papers/rompf-icfp15.pd...

[2]: https://twitter.com/not_xuwei_k/status/1323643312230772737

Re: Scala 3.0.0-M1

#99
post #4

I've always loved Scala and Scala 3 is shaping up to be extremely exciting. Love the new ADTs and braceless syntax: really gives the language a cleaner and more ML inspired feel. No other conventional language (including OCaml, F#, etc) seem to have the effortless kind of power Scala does. The combination of the extremely powerful type system with the "OOFP" paradigm is a great combination. OOFP is such a great parad…

I really enjoyed writing Scala code. I'd agree with your evaluation with respect to the expressiveness and power provided by the language. ...but the tooling, at least at that time, was terrible. SBT was terribly overcomplicated, and full of foot-guns. I spent far too much time debugging dependency collisions, issues created by so-called "autoplugins" and other nuances that had nothing to do with getting real work do…

SBT is a fractal of awfulness and I have no idea why anyone ever uses it. But it's never been required. Just use maven and get on with your life.

Re: Scala 3.0.0-M1

#100
post #7
post #4

I've always loved Scala and Scala 3 is shaping up to be extremely exciting. Love the new ADTs and braceless syntax: really gives the language a cleaner and more ML inspired feel. No other conventional language (including OCaml, F#, etc) seem to have the effortless kind of power Scala does. The combination of the extremely powerful type system with the "OOFP" paradigm is a great combination. OOFP is such a great parad…

For me scala's feature set is absurdly big and there are always 10 ways todo things. Look at the spec of Scala. Its 200 pages long. That's insane. I'd rather use Kotlin.

Having switched from Scala to Python recently, I must say Python has probably 5x more ways to do things than Scala and I can't see people complaining on Python's complexity.

This is something that really surprised me, because "one obvious way " was announced to be a part of Zen of Python.

Post reply on HN