Is it prudent to use Scala for anything new?

7 points by rastafarigpu ↗ HN
Is it worth using Scala for new projects that don't use Spark? There seems to be a trend to not use Scala for anything new and either use Kotlin for functional programming or use Go where parallaisation is required. PySpark is popular among Spark folks. So, is it worth building anything new in Scala?

10 comments

[ 4.1 ms ] story [ 35.6 ms ] thread
Personally I am not a fan of Scala. There was the time I spent two days debugging something that used Scala actors to parallelize a calculation that: (1) got only a 2x speed up on an 8 core machine and (2) didn’t get the same result every time that we ran it.

It was a 20 minute job to rewrite in Java with an executor and it got (1) a 7.5x speed up and (2) the right answer.

In other cases it was human factors like the engineering manager who told me how great it was to handle errors with monads instead of exceptions except that they never actually handled the errors. This place claimed to be doing “functional programming” but they also claimed to be doing “code reviews” but if that were really the case that eng manager would have known that policies weren’t being followed (e.g. allegedly we writing unit tests but it was few and far between.)

Personally I thin Java is going in the right direction through JDK 8, JDK 17 and now JDK 21. If anything, Java is adopting “ML the good parts.” with pattern matching, sealed classes and such.

It seems that you struggled with an actor lib (edit: and with your company), not really with the language itself.
The speed with which Java has been evolving.. I'm not sure even Kotlin can survive let alone Scala.

Unless you already have a team with expertise in Scala, I don't seen the point.

(comment deleted)
My opinion, Scala is a clusterfak for luck of a better term. It was insufferable when i was learning it, so many features, so many ways to write something, some obscure syntax too.

Avoid it, Java is pretty OK I'd say.

It’s a great language to show how smart its creators are, that’s the only goal truly achieved by the language.

Don’t use it in real world applications please, while having some nice syntax improvements over java, it is a nightmare on many other levels

Reading Scala code is like meta thinking. It'll hurt your brain for ...no reason.
I love scala, much better than java, tho java does steal features from scala.

You can express yourself in much less code and safer.

I do use it profesionaly for past maybe 8 years, mostly backend services.

Anyway kotlin is probably also better than java.

I think Scala is a far more productive language than Java or Kotlin, but it has a higher learning curve. This means you have to spend some time learning it and if there are more people than you, then the same is true for them too.

Also, Scala is usually a bit slower than Java (let's say factor 1.5x) which will be a problem if you need raw performance/latency, e.g. if you want to write a high frequency trading app. You will not be happy doing that with Scala.

As to why I believe Scala is more productive - just look for example at Typescript and how much it improved developer experience by supporting union-types. Scala allows to do the same. Or think of Rust and its traits that make it really easy for library interoperability - Scala has the same (in an even better form). Last but not least, Scala is currently the language with one of the best effect systems in my opinion (https://zio.dev/). Kotlin for example has copied the approach with https://arrow-kt.io/ which I think is great actually. But when comparing Scala and Kotlin here, Scala wins by a large margin, it is a completely different world. It's like building a highly concurrent system in Erlang vs C.

Of course, if you don't want to learn things like union types, traits/typeclasses and effects (similar to async/await but more powerful) you will be annoyed by Scala. But once you learned them, you can never go back.