Skip to content

Commit bc942f4

Browse files
Merge pull request #10183 from dotty-staging/m1-blog
Add M1 blog article
2 parents 42d5c26 + 1f66159 commit bc942f4

File tree

1 file changed

+220
-0
lines changed

1 file changed

+220
-0
lines changed
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
---
2+
layout: blog-page
3+
title: Scala 3.0.0-M1 is here
4+
author: Anatolii Kmetiuk
5+
authorImg: /images/anatolii.png
6+
date: 2020-11-09
7+
---
8+
November 2020 brings an important milestone for Scala 3 – the release of Scala 3.0.0-M1. This milestone release is a precursor to the Scala 3.0.0 release candidate planned for the end of the year – which is as little as 6 weeks from now! Later on, the release candidate is planned to evolve into 3.0.0 stable release in February 2021.
9+
10+
Once 3.0.0 release candidate is out, no new features or breaking changes will take place on 3.0.x – it will only be updated for bug fixes. However, we are going to continue the work on making the language better and to test out our research in it. These changes will end up in Scala only as of 3.1.0.
11+
12+
For now though, our teams are focusing the efforts on getting done with the remainder of the 40-something projects that we planned for the upcoming release back in July 2020. Many of them are already completed. Those that aren't yet – get revised and re-planned. With the current global uncertainty and with the scale of the project, we cannot be certain, but we believe we have a reasonable chance of releasing 3.0.0-RC1 by Christmas.
13+
14+
Below, you can find a short summary of the changes that took place during between the 0.27.0-RC1 and 3.0.0-M1 releases.
15+
16+
<!--more-->
17+
18+
# Scala.js support for Scala 3
19+
Dotty 0.27.0-RC1 had introduced preliminary Scala.js support with the portable subset of Scala and native JavaScript types.
20+
Scala 3.0.0-M1 significantly expands on that support:
21+
22+
* support for non-native JS types ([#9774](https://github.com/lampepfl/dotty/pull/9774)), and
23+
* better support for other JS interop features, notably their interactions with Scala 3 features such as top-level declarations and `enum`s (e.g, [#9725](https://github.com/lampepfl/dotty/pull/9725) and [#9955](https://github.com/lampepfl/dotty/pull/9955)).
24+
25+
The only remaining feature of Scala.js that is not supported yet is JS exports: `@JSExport` and its siblings `@JSExportAll`, `@JSExportTopLevel` and `@JSExportStatic` are all ignored by Scala 3.0.0-M1.
26+
Support for JS exports will come in the next release.
27+
28+
For related reading, you can learn more on what it took to [implement Scala.js support in Scala 3 on our blog](https://www.scala-lang.org/2020/11/03/scalajs-for-scala-3.html).
29+
30+
# Allow `as` in place of `@` for pattern bindings
31+
As the title suggests, this change is fairly straightforward. Now, instead of:
32+
33+
```scala
34+
x match {
35+
case Foo(y @ Bar(z)) => println(y)
36+
}
37+
```
38+
39+
You can write:
40+
41+
```scala
42+
x match {
43+
case Foo(y as Bar(z)) => println(y)
44+
}
45+
```
46+
47+
As of Scala 3.1.0, the `@` syntax will be deprecated and the codebases should switch to `as` instead.
48+
49+
This change was implemented by PR [#9837](https://github.com/lampepfl/dotty/pull/9837).
50+
51+
# Pattern-Bound Given Instances
52+
The syntax for `given` instances in patterns has also changed. In the `for`-comprehensions, the correct way of using `given`s is as follows:
53+
54+
```scala
55+
for given Context <- applicationContexts do
56+
```
57+
58+
And in `match` clauses, you can use them as follows:
59+
60+
```scala
61+
pair match
62+
case (ctx as given Context, y) => ...
63+
```
64+
65+
For more information, see [documentation](https://dotty.epfl.ch/docs/reference/contextual/givens.html#pattern-bound-given-instances), and for discussion, see PR [#10091](https://github.com/lampepfl/dotty/pull/10091).
66+
67+
# Change wildcard given selectors
68+
This is another syntactic change which aims to simplify the code. Instead of:
69+
70+
```scala
71+
import p.{given _}
72+
```
73+
74+
The correct version of the wildcard `given` import now becomes:
75+
76+
```scala
77+
import p.given
78+
```
79+
80+
This change was implemented by PR [#9949](https://github.com/lampepfl/dotty/pull/9949).
81+
82+
# Final API for enumerations
83+
`enum` definitions are now released in their final design. since `0.27.0-RC1` we have made the following changes:
84+
85+
For the enum definition of Option:
86+
```scala
87+
enum Opt[+T] {
88+
case Sm(value: T)
89+
case Nn
90+
}
91+
```
92+
we will now generate on the companion objects of class cases `apply` and `copy` methods with the precise subtype:
93+
```scala
94+
object Sm {
95+
...
96+
def apply[T](value: T): Sm[T]
97+
...
98+
}
99+
```
100+
however expressions that call `apply` or `copy` will be widened to the parent enum type unless the precise type is expected, as we see here:
101+
```scala
102+
scala> Sm(23)
103+
val res0: Opt[Int] = Sm(23)
104+
105+
scala> val sm: Sm[23] = Sm(23)
106+
val sm: Opt.Sm[23] = Sm(23)
107+
```
108+
Previously, when an enumeration declared cases with value parameters, such as `Opt.Sm`, then the `Opt.values` array would no longer have indexes that match the enum case ordinals. We feel that this is problematic, so the `values` and `valueOf` methods will only be generated when an enum has exclusively singleton cases.
109+
110+
If an enumeration adds a case with value parameters, then consumers will recieve an error that explains why `values` has been removed.
111+
```scala
112+
scala> Opt.values
113+
1 |Opt.values
114+
|^^^^^^^^^^
115+
|value values is not a member of object Opt.
116+
|Although class Opt is an enum, it has non-singleton cases,
117+
|meaning a values array is not defined
118+
```
119+
For code that previously relied upon `values` to lookup singleton cases, we now provide an optimised method `fromOrdinal` that reflects singleton values. This method is always generated:
120+
```scala
121+
scala> Opt.fromOrdinal(1)
122+
val res1: Opt[?] = Nn
123+
```
124+
125+
# Keep `@alpha` optional for operators
126+
Following the discussion on [contributors](https://contributors.scala-lang.org/t/the-alpha-notation/4583), we now keep `@alpha` optional for operators. The checking behavior is still available when compiling with the `-Yrequire-alpha`.
127+
128+
`@alpha` annotations provide a way to define an alternate name for symbolic operators. You can learn more about `@alpha` annotations from the [documentation](https://dotty.epfl.ch/docs/reference/changed-features/operators.html#the-alpha-annotation). The change was implemented by PR [#10093](https://github.com/lampepfl/dotty/pull/10093).
129+
130+
# Optimizing the compiler
131+
During the last months, a considerable amount of effort went into investigating performance bottlenecks in the compiler and optimizing its workflow. We also work on stabilizing the compiler and porting relevant changes from the Scala 2 compiler to Scala 3. The following PRs are relevant to highlighting this work:
132+
133+
- Port classfile parsing improvements [#10037](https://github.com/lampepfl/dotty/pull/10037)
134+
- Semanticdb usability enhancements [#9768](https://github.com/lampepfl/dotty/pull/9768)
135+
- Optimize core and frontend [#9867](https://github.com/lampepfl/dotty/pull/9867)
136+
137+
# Known issues
138+
This release of Scala 3 doesn't work on JDK 14 because of a regression fixed in [#10135](https://github.com/lampepfl/dotty/pull/10135). JDK 15 doesn't work either because of [scala/bug#12172](https://github.com/scala/bug/issues/12172) which will be fixed in the new scala-library release.
139+
140+
# Let us know what you think!
141+
If you have questions or any sort of feedback, feel free to send us a message on our
142+
[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please
143+
[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new).
144+
145+
146+
## Contributors
147+
Thank you to all the contributors who made this release possible 🎉
148+
149+
According to `git shortlog -sn --no-merges 0.27.0-RC1..3.0.0-M1` these are:
150+
151+
```
152+
171 Martin Odersky
153+
94 Nicolas Stucki
154+
75 Liu Fengyun
155+
62 Aleksander Boruch-Gruszecki
156+
50 Filip Zybała
157+
35 Krzysztof Romanowski
158+
34 Anatolii Kmetiuk
159+
32 Sébastien Doeraene
160+
31 Guillaume Martres
161+
28 Jamie Thompson
162+
20 bishabosha
163+
19 Guillaume Raffin
164+
16 Krzysztof Romanwoski
165+
12 Ruslan Shevchenko
166+
9 Tom Grigg
167+
6 Som Snytt
168+
5 odersky
169+
5 Andrzej Ratajczak
170+
4 Michał Pałka
171+
3 Adrien Piquerez
172+
3 Tudor Voicu
173+
3 noti0na1
174+
2 Krzysztof Bochenek
175+
2 Tudor
176+
2 Raphael Jolly
177+
2 Miles Sabin
178+
1 Vasil Vasilev
179+
1 ansvonwa
180+
1 Greg Zoller
181+
1 felher
182+
1 gzoller
183+
1 zgrybus
184+
1 Fengyun Liu
185+
1 Philippus Baalman
186+
1 Krzysiek Bochenek
187+
1 Tomasz Godzik
188+
1 ysthakur
189+
```
190+
191+
If you want to get your hands dirty and contribute to Dotty, now is a good time to get involved!
192+
Head to our [Getting Started page for new contributors](https://dotty.epfl.ch/docs/contributing/getting-started.html),
193+
and have a look at some of the [good first issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%3Anovice).
194+
They make perfect entry points into hacking on the compiler.
195+
196+
We are looking forward to having you join the team of contributors.
197+
198+
## Library authors: Join our community build
199+
200+
Dotty now has a set of widely-used community libraries that are built against every nightly Dotty
201+
snapshot. Currently, this includes shapeless, ScalaPB, algebra, scalatest, scopt and squants.
202+
Join our [community build](https://github.com/lampepfl/dotty/tree/master/community-build)
203+
to make sure that our regression suite includes your library.
204+
205+
[Scastie]: https://scastie.scala-lang.org/?target=dotty
206+
207+
[@odersky]: https://github.com/odersky
208+
[@DarkDimius]: https://github.com/DarkDimius
209+
[@smarter]: https://github.com/smarter
210+
[@felixmulder]: https://github.com/felixmulder
211+
[@nicolasstucki]: https://github.com/nicolasstucki
212+
[@liufengyun]: https://github.com/liufengyun
213+
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
214+
[@biboudis]: https://github.com/biboudis
215+
[@allanrenucci]: https://github.com/allanrenucci
216+
[@Blaisorblade]: https://github.com/Blaisorblade
217+
[@Duhemm]: https://github.com/Duhemm
218+
[@AleksanderBG]: https://github.com/AleksanderBG
219+
[@milessabin]: https://github.com/milessabin
220+
[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk

0 commit comments

Comments
 (0)