Live data from Hacker News

Scala 3.0.0-M1

github.com

71–80 of 148 posts

Re: Scala 3.0.0-M1

#71

In my company (10k+ devs) Scala seems to be losing steam. All the enthusiasts have moved to Go/Rust, while the pragmatics are staying in (moving back) in Java. No new major project is being built in Scala. Does anyone share this experience?

I think the big gap between releases was part of the problem. 2.13 took forever and frankly there haven't been any must-have new features since 2.11. So Scala is no longer new and exciting. But it's still the best at what it does.

I mean, if Rust had higher-kinded types, and the established library ecosystem, and the IDE support that Scala does, then I'd move to Rust too. But it doesn't. When you have a large codebase and need to manage cross-cutting concerns, the only thing that can do that as well as Scala does except Haskell (or more obscure options like Idris), and the state of Haskell tooling is miles behind Scala. I'm not attached to Scala for Scala's sake, but it's still my first choice.

Re: Scala 3.0.0-M1

#72

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…

There are no "special" methods in Scala. If you see something like "arr.map(_.nonEmpty).filter(a => a % 2)" in the standard library, you can use that syntax yourself too. E.g. "arr.customlyFiltered()" is easy to do. Or even easier "arr.filter(myCustomFilter)". If something doesn't work out for you, please feel free to use e.g. scalafiddle.io and make it example, then you will be helped! :) Scala is indeed not a high…

There is no straighforward elegant way of doing "obj.scalaMethod.myCustomMethod.scalaMethod.myCustomMethod" in Scala. I want to create a method and just inject it into the chain, no fiddling or ducktaping or using some black Scala magic.

"def myFun(a: String, b: Double): Boolean = {...}" and then "obj.mapValues.myFun.forall(_)" or just anything similar.

And yes, Scala is exactly the language when you need safe and maintainable code with far less unit tests required than in Java. But you have to invest into it and sometimes it is simply not worth it. The Scala2 to Scala3 migration situation makes things even worse unfortunately.

Re: Scala 3.0.0-M1

#73

Earlier quoted context omitted.

The opposite. If I write code on my own just for myself I use the highest level of brevity. But if I write code for a team, then in some places I will use explicit type annotations and variable names to aid people unfamiliar with the code to understand what's going on. What you are saying is pretty much "it's easier when everyone only uses nails, because then all I have to bring is a hammer". I think it's good to use…

If it was so simple as just using explicit types :) And this sort of flexibility is exactly why Scala is hard to read. Perl is another example of a great language that allows you a lot of flexibility. In fact, the ability to use just any symbol for a method is the worst thing about Scala. You quickly realize it once you start using Scala libraries some of which basically introduce you to a new Scala based DSL. This q…

Have you used Scala before? I used both perl and Scala and I had to laugh when I read what you said.

Yeah, Scala makes it possible to write cryptic DSLs. I just don't use libraries that do that, but there are not many such libraries anymore anyways, that was mostly abused in the early days of Scala. Now, 15 years later, that's almost non-existing anymore.

But not having symbolic characters in method names is just horrible. Here is Java code that calculates some datetime:

    LocalDateTime started = LocalDateTime.parse("2018-03-22T19:00:00")
    LocalDateTime finished = start.plus(Duration.ofMinutes(30)).plus(Duration.ofMinutes(15).multipliedBy(4)).plus(Duration.ofSeconds(45)).plus(Duration.ofMinutes(4).multipliedBy(3)).plus(Duration.ofSeconds(30))
 
Here is the exact same calculation, but with Scala's "symbolic" characters:

    val started = LocalDateTime.parse("2018-03-22T19:00:00")
    val finished = start + 30.minutes + 4 * 15.minutes + 45.seconds + 3 * 4.minutes + 30.seconds
I don't need very long to know what I find far more readable ;)

Re: Scala 3.0.0-M1

#74
post #21
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 am skeptical about the novelty of Scala's "OOFP" as you put it. It looks essentially the same as the original anonymous classes or SAM types in Java. Function values are objects with a single method and methods themselves are not first-class, but are wrapped in objects as required. The most important part of OO are the first-class modules; and in the literature, arguably more elegant examples of unifying first-clas…

It looks essentially the same as the original anonymous classes or SAM types in Java.

Decompiling a Scala .class file shows just how true this is.

Re: Scala 3.0.0-M1

#75

In my company (10k+ devs) Scala seems to be losing steam. All the enthusiasts have moved to Go/Rust, while the pragmatics are staying in (moving back) in Java. No new major project is being built in Scala. Does anyone share this experience?

Scala was the first serious attempt to break Java's stranglehold on the JVM that made any impact. A lot of people got very excited by it.

But then Kotlin, Ceylon, Clojure and others started to steal it's thunder and now it's just "one of the pack".

In fact, I'd say Java itself has stolen back from all those other languages to a large extent, with its language enhancements since v8.

Re: Scala 3.0.0-M1

#76

Earlier quoted context omitted.

There are no "special" methods in Scala. If you see something like "arr.map(_.nonEmpty).filter(a => a % 2)" in the standard library, you can use that syntax yourself too. E.g. "arr.customlyFiltered()" is easy to do. Or even easier "arr.filter(myCustomFilter)". If something doesn't work out for you, please feel free to use e.g. scalafiddle.io and make it example, then you will be helped! :) Scala is indeed not a high…

There is no straighforward elegant way of doing "obj.scalaMethod.myCustomMethod.scalaMethod.myCustomMethod" in Scala. I want to create a method and just inject it into the chain, no fiddling or ducktaping or using some black Scala magic. "def myFun(a: String, b: Double): Boolean = {...}" and then "obj.mapValues.myFun.forall(_)" or just anything similar. And yes, Scala is exactly the language when you need safe and ma…

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.

Re: Scala 3.0.0-M1

#77

Earlier quoted context omitted.

There are no "special" methods in Scala. If you see something like "arr.map(_.nonEmpty).filter(a => a % 2)" in the standard library, you can use that syntax yourself too. E.g. "arr.customlyFiltered()" is easy to do. Or even easier "arr.filter(myCustomFilter)". If something doesn't work out for you, please feel free to use e.g. scalafiddle.io and make it example, then you will be helped! :) Scala is indeed not a high…

There is no straighforward elegant way of doing "obj.scalaMethod.myCustomMethod.scalaMethod.myCustomMethod" in Scala. I want to create a method and just inject it into the chain, no fiddling or ducktaping or using some black Scala magic. "def myFun(a: String, b: Double): Boolean = {...}" and then "obj.mapValues.myFun.forall(_)" or just anything similar. And yes, Scala is exactly the language when you need safe and ma…

Assuming that your object is a list of tuples, then you can do:

    val myFun = (a: String, b: Int) => b % 2 == 0
    List("a" -> 1, "b" -> 2, "c" -> 3).map(myFun.tupled).forall(identity) // false
    List("a" -> 2, "b" -> 4, "c" -> 6).map(myFun.tupled).forall(identity) // true
But I think that's not what you mean... are you maybe looking for the "thrush" / |> operator? Or do you have some example from another language that does a better job and show how it looks there?

Re: Scala 3.0.0-M1

#78
post #62
post #37

Earlier quoted context omitted.

Not at all, JetBrains are the first ones to admit it, also why they decided to stop contributing to Eclipse and merging the Kotlin plugin into the InteliJ source tree. > Kotlin support for VSCode or other IDEs is not on the roadmap for the Kotlin team. Community initiatives in this respect are welcome. -- https://kotlinlang.org/roadmap.html > The next thing is also fairly straightforward: we expect Kotlin to drive th…

Thanks for your reply. You have a point, but there is to me still a difference between a "scratch-itch language created and a good biz model on top", and a "biz model that required a new language". There is some legal stuff going on as well: Java was being monetized by Oracle and Google needed a way out. This helps Kotlin a lot imho. When then free-Java case totally lost, Google allows all to move to Kotlin and Intel…

Google screwed Sun and had their opportunity to buy it.

The Java ecosystem has dozens of JVM implementations. None of them have ever had a problem with either Sun or Oracle.

Only Microsoft with their J++, and Google with their actions fragmenting the ecosystem for Java developers.

Microsoft learned their lesson and are now a OpenJDK contributor.

Time will come for Google as well.

Switching to Kotlin doesn't remove the dependency on the Java world, unless they plan to rewrite everything in Kotlin/Native.

Re: Scala 3.0.0-M1

#79

Earlier quoted context omitted.

If it was so simple as just using explicit types :) And this sort of flexibility is exactly why Scala is hard to read. Perl is another example of a great language that allows you a lot of flexibility. In fact, the ability to use just any symbol for a method is the worst thing about Scala. You quickly realize it once you start using Scala libraries some of which basically introduce you to a new Scala based DSL. This q…

Have you used Scala before? I used both perl and Scala and I had to laugh when I read what you said. Yeah, Scala makes it possible to write cryptic DSLs. I just don't use libraries that do that, but there are not many such libraries anymore anyways, that was mostly abused in the early days of Scala. Now, 15 years later, that's almost non-existing anymore. But not having symbolic characters in method names is just hor…

"I just don't use libraries that do that" -- sounds like you found a solution :)

I agree that "+" looks better than ".plus" but this is a matter of taste (hello Ada).

Yes, I use Scala at work but I can't call myself a seasoned Scala dev, true. On the other hand, just every expert in this or that language will always have a counterargument for you and a solution to the problem. Because he IS an expert! The thing is, not all people are experts or even will be. Most people want a tool that doesn't get in your way, easy to pick up and deliver the results. That is why Python is so popular despite being slow, inefficient and basically a glue for C/C++ libraries. Hell, even for interfacing with C Python loses to Lua. But all these shortcomings didn't matter in the end. Python2 → Python3 didn't kill the language either. I am afraid Scala's error margin is not as big.

Re: Scala 3.0.0-M1

#80

Earlier quoted context omitted.

How is that a bad thing? It's the same in other languages and it is nice to have some flexibility. E.g. lisp: use whichever type of parentheses you want Or Kotlin: use short syntax lambdas fruits.filter(it == apple) or long syntax fruits.filter(fruit -> fruit == apple) or with annotated types: fruits.filter{fruit: Fruit -> fruit == apple} Sometimes brevity is good for the reader, sometimes more details are good for t…

The flexibility is perfectly fine when you're programming something on your own. But when you're in a team, or worse, in a large company, it starts to be a problem that everyone can use their own style. It's much easier to read someone else's code when you have a common code style. And in Scala there are not only many different ways to use the standard libraries or to structure your code, there is a pure FP vs OOP-st…

I've been writing Scala for the better part of 8 years now and I have my list of gripes about the language, but this is one I have never understood.

Yes, there are different code styles you can use with Scala (standard vs infix notation, parens vs braces, etc) but all of that can be standardized with code formatting tools.

In terms of FP vs OO style I don't think that is different for any other language. No matter which programming language you choose you have to make decisions about what sort of patterns you want to use in which scenario and enforce that across the team. I have seen many Java projects where a relatively small codebase has approximately every GoF pattern implemented somewhere (and a few novel patterns just for good measure).

Post reply on HN