top | item 24986396

Scala 3.0.0-M1

191 points| cwhy | 5 years ago |github.com

145 comments

order

smabie|5 years ago

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 paradigm and it's unfortunate that no other language has embraced it.

It's ironic that I love Scala so much because I don't particularly enjoy dealing with the JVM and all its complexities and problem. But Scala is so good that it mostly makes up for it.

Scala does get a lot of hate (especially around here), but I've never really understood why. There's only one language I like more (kdb+/q), but that's a hard sell, especially because of the cost.

Too bad there's not really a ML/AI ecosystem around (besides Spark, which seems to be losing favor partially because of its embarrassing performance), because using Python is such a drag. However, I do understand why non-CS/type theory people might find the language intimidating.

But to that I'd say, I've seen new junior (though very smart) developers with no Scala or FP experience get onboarded and write idiomatic Scala code within a couple weeks to a month. The short term cost is more than worth it considering the absurd productivity compared to Java/Kotlin/Python/blublang.

Compared to OCaml/F#/Haskell, the improvement is a little less stark, though still clear imo (especially when considering editor tooling and available packages).

tastyminerals2|5 years ago

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 eyes.

Syntax aside I find Scala code hard to read due to how much implicitness it allows which stems from its "do FP or die" attitude which is again, weird for a language designed to incorporate both OOP and FP. Should I mention that in this regard D does a better job at serving the both worlds?

And finally, which threw me off completely is a real world case where we had to implement a word-entropy based algorithm to process tons of textual data and it appeared to be not much faster than a Python version despite all the optimization we tried to do. Scala is fast but there are many faster languages including Java itself. Considering the fact that its compiling times force you to leave your seat for a cup of coffee, you'd rather think of investing into another hard FP friendly language like Rust which simply has a wider applicability area. But yeah, this is all speculative but if you are thinking about what next language to pick up, these things start to matter.

Where Scala fits nicely is a small team which needs to build some business logic on top of the existing Java backend stack quickly and have a reliable working system. This is where it really shines. Scala provides a nice layer for JVM devs who have a soft spot for FP, safe and elegant solutions.

TeeWEE|5 years ago

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.

willtim|5 years ago

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-class modules and FP exist, for example by starting with FP and adding objects as records containing functions, this way both "objects" and methods would be first-class. Subtyping also adds significant complexity to the language and weakens type inference.

Scala is, first and foremost an OO language which embraces subtyping, class hierarchies and imperative programming, see for example its own collections library. As Java gets more and more FP features, there is a danger it will struggle to differentiate itself.

codeviking|5 years ago

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 done.

Now I'm writing a lot of Go. I'll admit, it's not nearly as fun to write. There's a lot less creativity and expressiveness -- though I think this is probably a good thing. But it also feels like I'm getting a lot more stuff done, and the tooling is amazing.

thirtyseven|5 years ago

> Too bad there's not really a ML/AI ecosystem around (besides Spark, which seems to be losing favor partially because of its embarrassing performance)

Compared to what? If you mean engines like Presto, I would say they have different use cases, plus Spark SQL puts them roughly in the same ballpark. Genuinely curious though, as a Spark user that is always interested in alternatives.

JD557|5 years ago

> Too bad there's not really a ML/AI ecosystem around (besides Spark, which seems to be losing favor partially because of its embarrassing performance), because using Python is such a drag.

I think it's not that bad. Sure, it loses to Python, but that's some tough competition.

Personally, I find that smile[1] covers most use cases. Breeze[2] also has a lot of love, but I'm not much of a fan of the `UFunc` abstraction.

I'm also really excited about polynote[3]. It's still a bit green and only supports Scala 2.11/2.12, but it's such a joy to be able to use Scala in notebooks :). You also get Python interop, in case you need to use some specific python library.

P.S.: I hope that Scala's ML/AI libraries other than Spark keep growing, because "embarassing" is a nice way to describe it's performance on everything that's not a "really-huge dataset".

1: https://github.com/haifengl/smile 2: https://github.com/scalanlp/breeze 3: https://github.com/polynote/polynote

moonchild|5 years ago

> only one language I like more (kdb+/q), but that's a hard sell, especially because of the cost

J? It's not quite the same, but is OSS.

sireat|5 years ago

When Scala, IntelliJ and SBT cooperate the language is so pleasant to work with.

There are some puzzling omissions though.

For example slice method is missing step. Coming from heavy data munging Python this really bites. Sure would be nice to have some syntactic sugar for slice.

Some seemingly simple tasks have no one way of solving them.

Let's take parsing JSON. Trivial in Python, painful in Scala. (almost the reverse in Python which has painful XML parsing and Scala's built in support for XML)

So far the easiest JSON library has been Li Haoyi's uPickle: https://www.lihaoyi.com/post/HowtoworkwithJSONinScala.html

Still, it does not parse JSON where objects have uknown arbitrary value types. Arbitrary value types are extremely common in real life JSON.

Due to pattern matching you see people suggesting you write your own parser! Sure it can be done, but then the next thing you'll be rolling your own crypto...

superyesh|5 years ago

>Too bad there's not really a ML/AI ecosystem around (besides Spark, which seems to be losing favor partially because of its embarrassing performance), because using Python is such a drag.

Even if Spark might not be the best tool for ML, it is still the tool to beat for data processing and custom ETL.

Thalarg|5 years ago

> considering the absurd productivity compared to Java/Kotlin/Python/blublang

I have not see more unproductive language than Scala.

newhkusers1|5 years ago

Scala deserves all the hate. It might be a fun language for a throwaway pet project but I'd never recommend it in an enterprise setting.

It's an extremely unproductive language because it's too flexible. There are so many different ways to do the same thing which introduces unnecessary complexity.

jatcwang|5 years ago

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

blackoil|5 years ago

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?

hamandcheese|5 years ago

Medium company (low hundreds of devs). My team is starting some new projects in Scala, which will be the first Scala at the company.

So far it’s going okay. But I personally am surprised at how disinterested most folks are in learning anything new.

kitd|5 years ago

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.

cmollis|5 years ago

My company uses Java for most things.. some python for scripting. There are a few of us who use Scala because of the work we do (Spark). I have to say that I prefer it over Java, and Spark is great for what we use it for. The functional features allow you to be concise and require a bit of creativity which makes it fun to work in. However, I doubt that I would use Scala outside of Spark. I think it's mostly because other typical frameworks that get used are Java-based so I would just code in that. That seems to be true of most of what I've done professionally: the framework or platform that makes your job easier (or even necessary) usually seems to require some specific language. (e.g.) When I coded a lot in IOS, it was Objective-C and then Swift (liked them both); a lot of web frameworks use Java or Python; front-end dev : javascript. At some point, they all just feel the same to me, to be honest. Some I like more, some I like less.. but the process is usually about the same. Clearly there seems to be the theme in the industry to move general-purpose development closer to machine-code (away from JVMs and the like).. Go, Rust, Swift, Lua, Dart are some examples. I think this is generally a good thing. At some point, Spark alternative will appear that will probably be written in Rust, if I had to guess... (Vega? or whatever it's called)

rethab|5 years ago

My experience as a freelancer is that the two camps are:

- enthusiasts who will stay with scala

- others who think they should have used kotlin/java from the beginning.

The latter camp is bigger and growing.

tasuki|5 years ago

Enthusiasts moving to Rust (and Haskell), sure. But Go? That's definitely a language for the pragmatics, right alongside Java.

MrBuddyCasino|5 years ago

In my experience people just moved to Kotlin. Hardly seeing any new projects in Scala, except maybe for Spark and such. It is mostly just maintenance at this point.

lmm|5 years ago

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.

dtech|5 years ago

In my environment Kotlin has won the better-Java use-case quite thoroughly.

edem|5 years ago

What I'm seeing is that Scala devs I know have started using Kotlin (including me). It is a much more pragmatic language that doesn't try to reinvent the wheel, like Scala does.

fnord123|5 years ago

Same experience here. JDK11 and beyond added some more enthusiasm to base Java. If Loom lands I think a lot of people will also lose interest in Kotlin as well (because AIUI a big draw for Kotlin is the async story).

rethab|5 years ago

Scala 3 is a huge change. As someone who used Scala for years, but always wondered whether they can retain their users with competition from Kotlin, I'm extremely curious what this will mean for Scala in the long run.

I'm skeptical, because the cost to migrate is big. But I'm hopeful, because Scala is a language I like to write code in.

Edit: why am I skeptical? I know scala 3 is largely meant to be backwards compatible. But scala has always been a language of many styles ("java without semicolon" vs "haskell compiled with scalac"). All this new syntax in scala three adds a whole new dimension to this issue.

pjmlp|5 years ago

On the JVM, I think Scala won't have any major issues it is just another guest language and isn't used to sell InteliJ licenses.

Kotlin is chaining itself to Android, it will rule there thanks to Google's sponsorship, on everything else it is just yet another language to chose from with a weaker eco-system, used to sell InteliJ licenses.

klysm|5 years ago

Yeah there are certainly some Python 2/3 fears for Scala 3, but the plan and upgrade path seem much more thought out

petre|5 years ago

Is there a document with the differences between 2.13 and 3?

jillesvangurp|5 years ago

The crucial point here is if Scala 3 maintains backwards compatibility with Scala 2.x. If not, it's effectively a new language and then the game becomes which of the existing scala code bases will switch over and when. There's a large amount of existing Scala code out there and embarking on a migration of that stuff is going to take very long. We're talking many years here potentially. The few Scala projects I've dealt with, even updating to minor releases of Scala was a big deal.

The python 2 to 3 transition took well over a decade. You have similar discussions in what remains of the Perl community around v5 and v6. IMHO what Oracle has been doing with Java in recent years is impressive in the sense that they provide a credible upgrade path and put a lot of effort into that while still adding non trivial new language features. But it has a price of added complexity or compromises with new features and unfortunate legacy features that are not going to way. Javascript and typescript have the same issue. Javascript has a lot of weird legacy features and typescript preserves backward compatibility with that weirdness and attempts to engineers around that.

I'm currently using Kotlin across Android and Server (mostly) with an intention to also use it on IOS and Web very soon. Its multi-platform capability is increasingly a good selling point and I love how that ecosystem is booming in the last year/months. I'm definitely an early adopter of multi-platform but this seems to be one of those things where it seems like a bet worth making at this point.

Kotlin is of course a much younger language so it does not have a lot of legacy yet burdening it. Yet, Jetbrains seems to be good at managing new features while minimizing disruption, dealing with necessary deprecations, and generally not breaking compatibility. Their experience as tool makers gives them a unique edge over a lot of other languages.

Arguably Kotlin emerged as a rejection of Scala to replace Java by Jetbrains: they considered it and dismissed it as an option and then embarked on a journey to create their own language. I think the success of the language (relative to Scala) seems to indicate that that wasn't a bad choice. Scala intended to do many of the same things but it just never caught on with people actually doing those things to the extent that Kotlin seems to be catching on. The transition from Java to Kotlin is a lot less of a hard sell than the transition to Scala was. Though I know plenty of people that stubbornly stick with Java still. Of course early adoption in the Android community was a big deal. But then you could argue that that same opportunity was there for Scala to take and I don't think much serious effort ever was put in that notion. The need for something else than Java was quite big there and a big driver for this. All Kotlin did was provide a credible upgrade path to Java developers and the Android community jumped on it because it was easy to switch and obviously better. You see the same happening in the Spring community which is increasingly Kotlin centric.

Meanwhile Scala seems to be bleeding mind-share to more pure (for lack of a better word) languages Crystal, Elixir, etc. or more system oriented languages like Rust, or indeed Kotlin. It's a bit of a repeat of what happened to the Ruby community a few years ago. Certain types of people were very passionate about that language for a while and then moved on.

aliakhtar|5 years ago

I have a pretty large codebase written in scala 2.12 or so (whatever the version was around late 2018). I'd like to migrate it to scala 3. Any ideas how hard it'll be?

alexashka|5 years ago

Just want to give Martin Odersky a shout out - what a legend this guy.

62 years old, going strong.

I'm not even in the java ecosystem but Scala strikes me as the most likely language to do something fresh and interesting on top of an existing ecosystem in the next few years, which is terrific news.

trumpeta|5 years ago

There are many reasons why I respect him, but the fact that he laid out a time plan for Scala 3 already 2 years ago and then kept the timeline is mind-boggling.

osdev|5 years ago

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.

hocuspocus|5 years ago

> 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.

Hu? There are plenty of alternatives to the pure FP ecosystem.

HTTP: Dispatch, Requests-Scala, literally any Java client if that's still too FP for you

JSON: uPickle, Play JSON, or simply Jackson

DB: ScalikeJDBC. Quill and Slick do a lot more but are not particularly die-hard FP either.

edem|5 years ago

Same here. Kotlin is a pragmatic language and it is a much better fit for the "Turbo Java" role that Scala originally wanted to do.

pjmlp|5 years ago

Nice to see Scala 3 finally making the first steps to release.

ph2082|5 years ago

I have downloaded this big open source project which uses spring and ibatis and have everything which OOP offers.

For learning Scala, I am trying to re-write it using play framework. Case classes do offer reduction in boiler plate code. But write now feeling overwhelmed about how to map all this deep inheritance tree, factories etc. from OOP world to functional way of doing things.

I hope someone write side by side mapping of doing things in Scala 2 vs Scala 3.

edem|5 years ago

The most important thing that no one seems to mention is that Scala 3 is not compatible with Scala 2. This means that they are creating competition for themselves. It is the Python 2 vs 3 problem all over again.

hbogert|5 years ago

I never quite got what made python 2 -> 3 so much more complicated than say php 5 to 7.

I heard nobody complain the time I was still active in the PHP world (lucky me right?). Yet the Python2 code just kept lingering everywhere.

x87678r|5 years ago

Scala can be nice but up until now compilation is way too slow to live with. Hopefully this will make it more palatable, but I've moved to Kotlin already.

esarbe|5 years ago

I've been working with Scala for 7 years now. Compilation speeds have been getting better throughout the 2.12.x/2.13.x cycles. Compilation speeds for Scala 3 are looking very good too.

esarbe|5 years ago

Nice. Looking forward to start using all the 'intention over mechanism' features that Dotty introduced.