Skip to content

3.1 release blogpost #1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 21, 2021
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
17437a4
Draft of 3.1 release blogpost
Kordyjan Oct 15, 2021
a5477d9
Apply some suggestions from code review
Kordyjan Oct 18, 2021
f021a91
Grammar fixes
Kordyjan Oct 18, 2021
a335e6b
Some clarifications in the 3.1 blogpost
Kordyjan Oct 18, 2021
1b430cf
Add compatibility notice
Kordyjan Oct 19, 2021
638f70f
Add point about unreductible match types raising error
Kordyjan Oct 19, 2021
c1ec919
Add contributors list
Kordyjan Oct 19, 2021
31f3083
Update other files related to the 3.1.0 release
Kordyjan Oct 19, 2021
30982b1
Add a paragraph about Mirrors for hierarchical sum types
Kordyjan Oct 20, 2021
2509e8a
Update blog/_posts/2021-10-19-scala-3.1.0-released.md
Kordyjan Oct 20, 2021
7ebcf45
Update blog/_posts/2021-10-19-scala-3.1.0-released.md
Kordyjan Oct 20, 2021
37b52cc
Update blog/_posts/2021-10-19-scala-3.1.0-released.md
Kordyjan Oct 20, 2021
5af7242
New Compatibility Notice
Kordyjan Oct 20, 2021
4410b30
Update the publication date
Kordyjan Oct 20, 2021
76d68d4
Two small clarifications
Kordyjan Oct 20, 2021
e0cdb31
Add stronger statement of our commitment
Kordyjan Oct 20, 2021
f20da70
Update blog/_posts/2021-10-21-scala-3.1.0-released.md
Kordyjan Oct 20, 2021
ba28464
Update blog/_posts/2021-10-21-scala-3.1.0-released.md
Kordyjan Oct 20, 2021
ec42953
Last clarifications
Kordyjan Oct 21, 2021
8bc74a5
Apply suggestions from code review
Kordyjan Oct 21, 2021
c59eb20
Update blog/_posts/2021-10-21-scala-3.1.0-released.md
Kordyjan Oct 21, 2021
0a7655f
Add note about versioning scheme
Kordyjan Oct 21, 2021
48b9ece
Change `canThrow` to `throws`
Kordyjan Oct 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions blog/_posts/2021-10-19-scala-3.1.0-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
layout: blog-detail
post-type: blog
by: Paweł Marks, VirtusLab
title: Scala 3.1.0 released!
---
Hello from the Scala 3 team! It has already been six weeks since we have announced the release candidate for the first minor version after the initial release of Scala 3. Now, after two more RCs, we can confidently promote Scala 3.1.0-RC3 to a new stable release of the language. In other words, Scala 3.1.0 is officially out!

You don't need to worry about having to migrate your projects to the new version. Scala 3 has strong compatibility guarantees, and all code working in 3.0.2 will also work in 3.1. On the other hand, switching to Scala 3.1 allows you to use many improvements and a handful of newly stabilized APIs.

## What's new in 3.1

### New experimental feature: safer exceptions

A new experimental feature that allows declaring and checking which exceptions can be thrown. It relies on the effects as implicit capabilities pattern.

You can opt-in using following import.

```scala
import language.experimental.saferExceptions
```

Now it is possible to mark types with exception that cna be thrown during the evalutaion:

```scala
def f(x: Double): Double canThrow LimitExceeded =
if x < limit then f(x) else throw LimitExceeded())
```

You can read more in [the document proposing this feature](https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/docs/reference/experimental/canthrow.md).

### Efficient bytecode for matching over strings

When Scala 3.0 has been compiling pattern matches with `Int` as a scrutinee type, it was emitting bytecode containing very efficient instructions: `lookupswitch` or `tableswitch`. Now in Scala 3.1, similar behavior was implemented for matching over `String` literals.

```scala
fruit match
case "apple" => 1
case "orange" => 2
case "banana" => 3
case _ => 0
```

will now generate `lookupswitch` over hash codes of `String` literals instead of a chain of conditional expressions. This behavior is consistent with what Java is doing and more performant than the old approach.

### Support for `-Wconf` and `@nowarn`

We have added a `-Wconf` compiler flag that allows filtering and configuring compiler warnings (silence them, or turn them into errors).

We have also integrated [the silencer plugin](https://github.com/ghik/silencer) into the compiler, which allows suppressing warnings locally using the `@nowarn` annotation.

`-Wconf` and `@nowarn` work largely the same way as in Scala 2, but some filters for selecting warnings are different. For the more details see the output of `-Wconf:help` flag.

### Simplified Manifest synthesis

For the sake of compatibility with Scala 2, the Scala 3 compiler now generates given instances for the `Manifest` trait. The new implementation is a slightly simplified approximation of the Scala 2 implementation. It guarantees that any of the expressions:

- `manifest[A] == manifest[B]`
- `manifest[A].runtimeClass == manifest[B].runtimeClass`
- `optManifest[A] == optManifest[B]`
- `optManifest[A].asInstanceOf[ClassTag[A]].runtimeClass == optManifest[B].asInstanceOf[ClassTag[B]].runtimeClass`

that was true in Scala 2, will also remain true when compiled with Scala 3.

### Other changes

- `Unapply.apply` constructor was added to the reflection API
- Scastie was integrated into Scaladoc to make snippets interactive.
- `@experimental` spec was changed. See more detail in [the design document](https://github.com/lampepfl/dotty/blob/release-3.1.0/docs/docs/reference/other-new-features/experimental-defs.md)
- Now `TastyInspector.{inspectTastyFiles, inspectTastyFilesInJar, inspectAllTastyFiles}` return a boolean value indicating whether the process succeeded
- A `Wildcard` was made a subtype of `Ident` in the reflection API
- `TypedOrTest` was added as a super type of `Typed` in the reflection API

Beside that scala 3.1.0 introduced multiple small improvements and fixed handful of bugs. You can see [the detailed changelog](https://github.com/lampepfl/dotty/releases/tag/3.1.0) on GitHub.

## What's next

During the Scala 3.1.0 stabilization period, which took the last six weeks, we haven't stopped improving the language and fixing the bugs in the compiler. You can already test the results of our work, as they are released as Scala 3.1.1-RC1. [The full changelog](https://github.com/lampepfl/dotty/releases/tag/3.1.1-RC1) is as always available on GitHub.

You can expect the stable release of Scala 3.1.1 in early December.

## Contributors

Thank you to all the contributors who made the release of 3.1.0 possible 🎉

According to `git shortlog -sn --no-merges 3.0.2..3.1.0` these are:

```
// TODO
```

## Library authors: Join our community build

Scala 3 now has a set of widely-used community libraries that are built against every nightly Scala 3 snapshot.
Join our [community build](https://github.com/lampepfl/dotty/tree/master/community-build)
to make sure that our regression suite includes your library.

[Scastie]: https://scastie.scala-lang.org/?target=dotty

[@odersky]: https://github.com/odersky
[@DarkDimius]: https://github.com/DarkDimius
[@smarter]: https://github.com/smarter
[@felixmulder]: https://github.com/felixmulder
[@nicolasstucki]: https://github.com/nicolasstucki
[@liufengyun]: https://github.com/liufengyun
[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain
[@biboudis]: https://github.com/biboudis
[@allanrenucci]: https://github.com/allanrenucci
[@Blaisorblade]: https://github.com/Blaisorblade
[@Duhemm]: https://github.com/Duhemm
[@AleksanderBG]: https://github.com/AleksanderBG
[@milessabin]: https://github.com/milessabin
[@anatoliykmetyuk]: https://github.com/anatoliykmetyuk