Readit News logoReadit News
namelosw · 4 years ago
Congratulations!

I always have great respect for Scala because itself and the community tried to adopt and push the novel idea in the industry. Take a look at the changes, they're no joke to design and implement. At the same time, they're also trying to make the language consistent and simple. (Yes, I mean simple, not easy or single-paradigmed)

They are taking the hard way, and not only there are not enough people to appreciate the effort, but also attract some hatred from time to time. I hope Scala 3 would bring us and itself a bright future, and inspire more languages to move forward.

(For example, there are a lot of type features added to TypeScript in most releases because it needs to do the typing on existing dynamically typed languages, it may also be a hint that dependent type actually makes sense in mainstream languages).

amw-zero · 4 years ago
Can you elaborate on the changes in TS that hint at dependent types? That's interesting.
namelosw · 4 years ago
I'm not referring to some specific changes. It's just there are many type operators already and still not enough to express JavaScript.

In the earlier versions of TypeScript, I often stuck with something natural in JavaScript but cannot express the same thing with type annotations - It's like opening a pandora box, once some advanced type operators have been introduced, whenever I played with them I would quickly found more type operators to be desired.

And so it did. Things were getting better over years, there were a lot more type operators, mapped types, the infer keyword, etc. I feel it points to a direction: There is still a lot of existing JavaScript functions' type depend on the input which cannot be well-typed. For example, there are functions similar printf in most languages, or return type T when 0 is passed otherwise return type U. To satisfy those cases, we'll basically reinvent a whole new programming language in the type system - if the new language happens to be JavaScript itself it would be similar to other dependent type systems.

RobertKerans · 4 years ago
[edit, not quite what GP was referring to, but] At the minute, via [depending on context] a combination of generics/conditional types, unions/literals, type constructors, and [more recently] string templating you can get close in certain circumstances. It tends to be very fiddly though, and [IME] it's quite easy to cause TS to stop narrowing types properly. Someone else with more experience may be able to weight in -- despite using it for a few years I'd not really bothered to exercise some of the more expressive parts of the system until string templating experiments started popping up last year.

This issue thread on the TS repo may be of interest:

https://github.com/microsoft/TypeScript/issues/33014

acjohnson55 · 4 years ago
I'm so psyched about this. I've followed the development of Scala 3 for pretty much the whole voyage, and I think they've done an incredible job bringing the community along through some pretty radical changes to the language. It has definitely not been an easy process herding a community with very big, informed, divergent opinions on the language.

In the end, I think they did an awesome job. Many, many sacred cows of old Scala were confronted. I think the result is a much more approachable language, where simple things are easier.

agbell · 4 years ago
I totally agree. I love the direction of Scala 3. This quote says it all I think:

"Scala 3 takes a slightly different approach [from Scala 2] and focuses on intent rather than mechanism. Instead of offering one very powerful feature, Scala 3 offers multiple tailored language features, allowing programmers to directly express their intent"

So rather than something like implicits, that can be used N different ways, only 2 of which are practical, Scala 3 adds those 2 features explicitly.

https://docs.scala-lang.org/scala3/new-in-scala3.html

swader999 · 4 years ago
The days I spent chasing implicits are still lost to me forever.
nautilus12 · 4 years ago
I always felt like implicits were a weaker design in the language, glad to see they put some more thought behind it.
Buttons840 · 4 years ago
What's an example of something they made more approachable?

One of my first impressions of Scala, which I have barely seen, and do not know, is that there is a lot of syntax. Has anything been done to help with that? I don't think syntax matters much, but it's one of the only impressions I have of the language and wanted to ask about it.

peq · 4 years ago
Scala is one of the smallest typed languages in terms of syntax.

See slide 13: https://www.slideshare.net/Odersky/preparing-for-scala-3#13

With scala 3, syntax has been simplified even more, e.g.:

No more braces necessary. Top level declarations. Extension Methods.

OOPMan · 4 years ago
That's an interesting take, as someone that's used Scala for a while I feel like there actually isn't that much syntax.

I guess my perception is warped :-)

valenterry · 4 years ago
Amazing!!! Great to see Scala improving at such a fast pace!

I'm especially excited about union/intersection types. I think we could all witness how well they work out in typescript and I believe that every language with the concept of subtyping should have this feature. It is one of the things that make working in a statically typed language feel much more dynamic/lightweight without giving up on safety guarantees.

KajMagnus · 4 years ago
Amazing! That's the word that popped up in my mind too.

Scala 3 is my on shared 1st place favorite language

Union/intersection types — indeed, I use all the time, in Typescript.

And Opaque Types looks lovely too. All across my code base, I have type aliases like "UserId" or "PageId" or "PostNr" or "DraftNr" etc, and it'll be nice that this can now be type safe for real, not just type aliases. (Just waiting for opaque types to arrive to Typescript too.)

geodel · 4 years ago
From their blog:

> After 8 years of work, 28,000 commits, 7,400 pull requests, 4,100 closed issues – Scala 3 is finally out. Since the first commit on December 6th 2012...

I mean it is lot of work for sure. But is it such a fast pace?

darksaints · 4 years ago
There's some weird history there. For most of the project's existence, Scala 3 was known as Dotty. It was basically a research project, and it was recognized from the beginning that it was a different language than Scala, largely due to the type system semantics...the goal being a formally defined, fully sound type system (Scala had some edge cases that made it not sound, even if it was more sound than most languages).

However, the language resembled Scala, was created by the same person, had some cool capabilities that a lot of Scala users longed for, and it was a chance to "start over" with some of the more questionable design decisions that had been made previously, so there was a lot of questions and pressure to make it Scala 3.

So it was decided to no longer treat Dotty as a second language, but rather to find a path to migrate the existing Scala ecosystem to this new language. This transitioned the project from a relatively slow-paced research language into a full fledged and funded project with an urge for engineering not just tool and ecosystem compatibility, but also bytecode compatibility with Scala.

So for most of those 8 years, there was no objective but to create a better language than Scala. Then very rapidly (maybe the last two years), it went from "this is a completely new language" to "these language ideas will be incorporated into Scala 3", to "this will actually become Scala 3 and we're working on a transition path".

And from the perspective of someone who was aware of Dotty and a regular user of Scala, that felt like an extremely fast transition. Especially for a language that took years to make much smaller changes in the past (2.10->2.11->2.12 felt like an eternity).

valenterry · 4 years ago
It is.

Scala does not use semver. The last major release was 2.13.0, not 2.0.0. That's a bit confusing I guess.

What that means is, they haven't just added some features, they redesigned/rewrote to language from ground up to simplify it and make formally sound. I actually don't know any other language that does that (though I'm sure there are others, maybe Haskell is one of them).

In addition, a lot of features are very impactful and unprecedented, such as match types. To me, for a mainstream language (even though a smaller one), it certainly feels fast pasted.

jules · 4 years ago
Scala 3 + VS code + worksheets is my favourite exploratory programming environment. Its has:

* Powerful functional features

* Powerful OO features

* Imperative features

* Powerful type system

* Great stdlib

* Great syntax

* Very fast write/test cycle with worksheets, way better than a REPL

* Great IDE features such as autocomplete

Scala may not be the best on any one axis, but the combination is unparalleled.

sireat · 4 years ago
I've been extremely happy with IntelliJ plugin for Scala. I do use Visual Studio Code for Python,JS,web, etc.

What would be advantage of using VS Code over IntelliJ for Scala?

jules · 4 years ago
I'm familiar with VS code and have a set up that I'm familiar with (shortcuts & settings) and I've only briefly looked at IntelliJ, so I'm not qualified to answer this question. What is the reason you're using IntelliJ rather than VS code?
saym · 4 years ago
Can you talk a little more about worksheets? I'm not familiar with scala worsheets at all.

Follow-up: How do you transition to productionizing your code after iterating in them?

jules · 4 years ago
Worksheets are a simple concept: you write lines of code in them, and the IDE runs the code automatically as you type, and displays the return value of each line. If you're familiar with the concept of Jupyter notebooks, it's a bit like that.

I tend to not view it as a replacement for an ordinary code file, but as a replacement for a REPL session. It has several advantages:

* Keeping track of your previous commands in a file is much more convenient than keeping track of it in your input history of the REPL.

* You can keep re-editing previous lines easily, and you can see the output of all lines.

* There is no hidden state (unlike a REPL). Everything is run from scratch every time.

* It's easier to define helper functions than in a REPL.

* It's easier to turn a worksheet into a unit test than it is to turn a REPL session into a unit test.

That said, it's also possible to start writing a module in a worksheet, and then turn it into an ordinary code file later.

Worksheets aren't perfect yet; I can think of many improvements, but they're already very useful to me. I think the end game will be to merge the concept of worksheet, unit test, debugger, printf debugging, and ordinary code file into one system, like Sean McDirmid's usable live programming research work (which in my opinion remains one of the most underrated research projects).

https://www.youtube.com/watch?v=01Xyoh-G6DE

zzbzq · 4 years ago
I don't know what worksheets are, but does Scala3 work with vscode now? Previously the plugins didn't do much, especially if you didn't use SBT.
esarbe · 4 years ago
The Scala/vscode story is pretty good now. [0]

[0] https://scalameta.org/metals/

jules · 4 years ago
It does work quite well with Scala 3.
kimi · 4 years ago
While we wait for an official document: https://docs.scala-lang.org/scala3/new-in-scala3.html - there is quite a lot of things in there!
humps · 4 years ago
riffraff · 4 years ago
I grinned a bit looking at that blog post and seeing how the highlighting of contributor names is completely messed up, presumably because of a bad regex.

Feels ironic, since Scala has a very advanced type system that would prevent such bugs, but the page contains the most classic issue of not handling non-ascii characters properly :)

killingtime74 · 4 years ago
Scala is not perfect but it’s very good. It’s competitive pressure arguably improved Java (streams, pattern matching, data classes).
isbvhodnvemrwvn · 4 years ago
I think apart from streams it was Kotlin that did the trick.
halfmatthalfcat · 4 years ago
I was waiting for this comment. Every single thread about Scala has someone pushing this narrative that Kotlin is the real arbiter of change when it really has been Scala the entire time pushing boundaries on the JVM.

Kotlin is great and if you want a cleaner Java experience, by all means use it but Scala is real champion in pushing many, many things into the mainstream.

pron · 4 years ago
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 it amusing that people think that Java is trying to compete with other languages on the Java platform, no matter how small, rather than with bigger, more relevant competitors.
valenterry · 4 years ago
Scala was probably the major factor here. However, the fact that Kotlin picked up these features from Scala (or at least inspired it) also proves that they are mature/stable and this has always been important for Java - so Kotlin did have an impact as well.
pulse7 · 4 years ago
It doesn't matter "who did the trick". It is well known that Java was influenced by ideas in other programming languages from the beginning. And also other languages - including Scala and Kotlin - are similar in this respect... So yes: Kotlin influenced Java and Java influenced Kotlin. Let's compare final products with final products and not "how did we get there"...
xfer · 4 years ago
Kotlin doesn't sound like a good language to bet on since most suitable(for jvm) features it has will be integrated by Java now that it has picked up pace.

I guess it only has decent marketshare because of google's android support(they are throwing stuff on the wall to move away from Oracle IP i guess) and Jetbrains being very popular among java devs.

pjmlp · 4 years ago
Both are guest languages, Java owns the platform.

What did the trick are the other programming languages that can stand on their own as platforms.

hocuspocus · 4 years ago
How so? Kotlin doesn't even have proper pattern matching.
namelosw · 4 years ago
It could also be transitive: Scala inspired Kotlin and then Kotlin did the trick, I hope they could share the credit :)
OOPMan · 4 years ago
Let's not talk about the thing Java calls pattern matching
AtlasBarfed · 4 years ago
Most new Java language features seem to chase groovy features more than others, but then again many of the jvm langs do similar features to extend ahead of java's limitations.
jim-jim-jim · 4 years ago
> 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.

cage433 · 4 years ago
> 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

valenterry · 4 years ago
It has one advantage compared to Haskell though: as a Java/Kotlin (or even Python or javascript) developer, you can start with it an be productive immediately. You can then slowly absorb new concepts until you are pretty much ready to write full-fledged Haskell.

That's why some call it Haskellator. :)

This also means that many codebases have different styles though, whereas in Haskell you have one style (FP).

gher-shyu3i · 4 years ago
Slow from a performance perspective, or to read and write code?
jiofih · 4 years ago
Or a lot less money :)

Dead Comment

jmfldn · 4 years ago
A big moment for Scala. I've used it professionally for 5 years and am still in love with it. The expressiveness, the power, everything about it is a joy. This just takes it to another level by removing a few warts and simplifying it whilst adding some amazingly useful new features. A really tricky balance needed to be struck.

I think they've pulled off an unlikely and amazing feat with this release.

wokwokwok · 4 years ago
I presume from the major increment this is a breaking change.

What will tangibly be broken with 3.0, and is there any migration tooling?

— Nevermind, https://scalacenter.github.io/scala-3-migration-guide/ seems to cover this quite respectably.

valenterry · 4 years ago
Yes - and in particular, Scala 3.0 makes use of TASTy, which will reduce backwards/compatibility issues a lot for future development.

Luckily Scala has one of the strongest statical type-systems, which will make migrating much smoother (not completely painless though)