Skip to content

Add 3.3.0 announcement #1505

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 7 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions _data/scala-releases.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- category: current_version
title: Current 3.2.x release
version: 3.2.2
release_date: January 30, 2023
title: Current 3.3.x LTS release
version: 3.3.0
release_date: May 30, 2023
- category: current_version
title: Current 2.13.x release
version: 2.13.10
Expand Down
10 changes: 10 additions & 0 deletions _downloads/2023-05-30-3.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Scala 3.3.0 LTS
start: 30 May 2023
layout: downloadpage
release_version: 3.3.0
release_date: "May 30, 2023"
permalink: /download/3.3.0.html
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
api_docs: https://www.scala-lang.org/api/3.3.0/
---
187 changes: 187 additions & 0 deletions blog/_posts/2023-05-30-scala-3.3.0-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
layout: blog-detail
post-type: blog
by: Paweł Marks, VirtusLab
title: Scala 3.3.0 released!
---

![Scala 3.3]({{ site.baseurl }}/resources/img/scala-3.3_LTS-launch.png)

We are thrilled to announce that after long months of work and careful testing, we have released Scala 3.3.0, the first release in the new 3.3.x LTS series.

## What does "LTS" mean?

Scala 3.3.x is the first Long Term Support (LTS) release series. That means that it will be actively maintained for a period of at least three years. We have adopted a release model similar to the one that Java has successfully used for a long time.

In the following years, there will be new minor releases (3.4, 3.5, and so on) that can bring new backward-compatible features. We are calling them Scala Next; they are equivalent to Java's feature releases. Bug fixes and usability improvements from those releases will be back-ported and released as 3.3.x patches. Apart from those forward and backward-compatible changes, LTS will be feature frozen.

The LTS model doesn't change anything in our compatibility guarantees. Projects built with all future releases will be able to depend on any library compiled with Scala 3.3.x. This is just our standard guarantee that the newer compiler can always consume the output of the older version.

LTS might be a great choice for library authors who can now receive constant bug fixes and developer experience improvements without forcing the users of the library to update the compiler version in their project.

You can read more about our compatibility guarantees in [the recent blog post](https://virtuslab.com/blog/the-scala-3-compatibility-story/).

## What's new in Scala 3.3.0

### Linting

Scala 3.3.0 brings back linting to the Scala compiler. Right now, you can enable checking for unused symbols and discarded values. More linting options will come soon in the following Scala 3.3.x releases.

#### Checking for unused values

There is an entire family of compiler options added in 3.3.0 for checking and reporting different kinds of unused symbols:

- `-Wunused:imports` - for unused imports
- `-Wunused:privates` - for unused local definitions
- `-Wunused:locals` - for unused local definitions
- `-Wunused:explicits` - for unused explicit parameters
- `-Wunused:implicits` - for unused implicit parameters (parameters in `using` clauses)
- `-Wunused:params` - for all unused method parameters
- `-Wunused:all` - for enabling all of the above lints

#### Checking for discarded values

Discarding non-unit values is usually the symptom of subtle mistakes. The compiler can now warn you about all discarded values saving you from bugs resulting from those hard-to-spot mistakes.

In the following simplified example

```Scala
def failure: Either[String, Nothing] = Left("something broke")

def failedComputation: Either[String, Unit] =
Right(()).map(_ => failure)
```

the programmer, by mistake, used the `map` method instead of `flatMap`. The code still compiles, but due to value discarding, behaves unexpectedly, returning `Right(())` from the `failedComputation` method. If the `-Wvalue-discard` flag is enabled, the compiler will report the warning, saving the user from a potential bug.

### More consistent braceless syntax

Braces around method parameters can now be replaced with a colon. This can lead to cleaner, shorter, and often more readable code in places like configuration DSLs or test case definitions.

```Scala
def canFail(input: String): Try[List[String]] = Try:
someComputation(input).flatMap: res =>
val partial = moreComputation(res)
andEvenMore(partial)

class TestSuite extends munit.FunSuite:
test("the job doesn't fail"):
val job = canFail("some data")
assert(job.isSuccess)
```

For the record, the braceless syntax has been introduced in Scala 3.0.0. However, braces were still needed to pass function arguments. Martin Odersky proposed to address this point in the proposal [SIP-44 - Fewer braces](https://docs.scala-lang.org/sips/fewer-braces.html), which was accepted by the SIP Committee in [August 2022](https://docs.scala-lang.org/sips/results/2022-08-26-meeting.html). The final implementation was released as an experimental feature in [Scala 3.2.0](https://github.com/lampepfl/dotty/releases/tag/3.2.0) in September. Finally, in [October](https://docs.scala-lang.org/sips/results/2022-10-21-meeting.html), the SIP Committee voted to promote it to a stable feature.

### `boundary` and `break`

Two new methods were added to the standard library: `boundary` and `break`. They are safer and more expressive replacements for non-local returns, which were deprecated recently.

`break` allows for a type-safe early escape from anywhere inside the block delimited by `boundary` to its end, returning the passed value from the entire block.

```Scala
import util.boundary, boundary.break

def sumOfRoots(number: List[Double]): Option[Double] = boundary:
val roots = numbers.map: n =>
println(s" * calculating square root for $n*")
if n >= 0 then Math.sqrt(n) else break(None)
Some(roots.sum)
```

When you run the above method, you will notice that it returns `None` when any of the input elements is negative. Moreover, thanks to `boundary`/`break`, you can see from the console output that it stops iterating after encountering the first negative element.

`break` can jump out of the `boundary` in the function deeper on the stack. To make it safe, only functions with a matching `Label` in their using clauses can break. This can be used to create isolated parts of an application with streamlined error handling. Library authors can abstract over `break` and `Label`, creating a nice API for error handling or dealing with uncertain data.

### The new default implementation of lazy vals

Last but not least, we have changed the default implementation of lazy vals. The new implementation has better performance and is safer under parallel access. This may result in improvements in the performance of effect systems.

## Should I update to Scala 3.3.0?

If you are maintaining a standalone Scala 3 project without external projects depending on it, feel free to switch to Scala 3.3.0 at any moment. You will enjoy all the improvements in the newest version of the compiler.

If you are a library author following semantic versioning, we advise you to update to Scala 3.3.0 in the next minor release of your project. Users of your library would also need to bump their compiler version to use the newest version of your library. If you have already published a minor version on 3.3.0 but learned about a critical vulnerability in your library, you should release a new patch release for the previous minor version of your library using the Scala version you had used before the bump (e.g. 3.2.2 or older). This patch can be consumed by all the users of previous versions of the library, no matter if they have already switched to 3.3.0 or not.

### Known incompatibility: Stability of inline parameters

In Scala, only stable paths can be used as prefix in path-dependent types.

```Scala
class Outer:
type Inner

val a = new Outer
val aInner: a.Inner = ??? // ok

var b = new Outer
// val bInner: b.Inner = ??? // error

def c = new Outer
// val cInner: c.Inner = ??? // error

def method(param: Outer): param.Inner = ??? // ok
```

There was a bug that resulted in the compiler assuming that all inline parameters are stable references. This could have led to unsound code being accepted by the compiler and potential runtime crashes.

```Scala
inline def method(inline param: Outer): param.Inner // error in Scala 3.3.0
```

Such pieces of code are now rejected by the compiler. The migration for that change is simple, as it only requires removing the `inline` modifier **from the parameter**. If the path-dependent type was used, it is safe to say that the intended behavior was to inline the method without inlining the parameter.

## Contributors

Thank you to all the contributors who made the release of 3.3.0 possible

According to `git shortlog -sn --no-merges 3.2.2..3.3.0` these are:

```
226 Martin Odersky
106 Szymon Rodziewicz
81 Dale Wijnand
56 Nicolas Stucki
52 Paul Coral
48 Kamil Szewczyk
45 Paweł Marks
28 Florian3k
28 Yichen Xu
15 Guillaume Martres
10 Michał Pałka
9 Kacper Korban
8 Fengyun Liu
7 Chris Birchall
7 rochala
6 Sébastien Doeraene
6 jdudrak
5 Seth Tisue
5 Som Snytt
5 nizhikov
4 Filip Zybała
4 Jan Chyb
4 Michael Pollmeier
4 Natsu Kagami
3 Anatolii Kmetiuk
3 Jamie Thompson
2 Adrien Piquerez
2 Alex
2 Dmitrii Naumenko
2 Lukas Rytz
2 Michael Pilquist
2 Vasil Vasilev
2 adampauls
2 yoshinorin
1 Alexander Slesarenko
1 Chris Kipp
1 Guillaume Raffin
1 Jakub Kozłowski
1 Jan-Pieter van den Heuvel
1 Julien Richard-Foy
1 Kenji Yoshida
1 Matt Bovel
1 Mohammad Yousuf Minhaj Zia
1 Philippus
1 Szymon R
1 Tim Spence
1 s.bazarsadaev
```
Binary file added resources/img/scala-3.3_LTS-launch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.