Skip to content

Commit acf7211

Browse files
KordyjanSethTisueWojciechMazur
authored
Add 3.5.0 announcement (#1676)
* Add 3.5.0 announcement Co-authored-by: Seth Tisue <seth@tisue.net> Co-authored-by: Wojciech Mazur <wojciech.mazur95@gmail.com>
1 parent 471c11f commit acf7211

File tree

4 files changed

+205
-3
lines changed

4 files changed

+205
-3
lines changed

_data/scala-releases.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
- category: current_version
2-
title: Current 3.4.x release
3-
version: 3.4.2
4-
release_date: May 16, 2024
2+
title: Current 3.5.x release
3+
version: 3.5.0
4+
release_date: August 22, 2024
55
- category: current_version
66
title: Current 3.3.x LTS release
77
version: 3.3.3

_downloads/2024-10-22-3.5.0.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Scala 3.5.0
3+
start: 22 August 2024
4+
layout: downloadpage
5+
release_version: 3.5.0
6+
release_date: "August 22, 2024"
7+
permalink: /download/3.5.0.html
8+
license: <a href="https://www.scala-lang.org/license/">Apache License, Version 2.0</a>
9+
api_docs: https://www.scala-lang.org/api/3.5.0/
10+
---
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
---
2+
layout: blog-detail
3+
post-type: blog
4+
by: Paweł Marks, VirtusLab
5+
title: Scala 3.5.0 released!
6+
---
7+
8+
![Scala 3.5]({{ site.baseurl }}/resources/img/scala-3.5-launch.jpg)
9+
10+
We are happy to announce that after long and hard work by the entire compiler team, and after seven release candidates, the first version of the Scala 3.5 line is officially out!
11+
12+
## New default runner - Scala CLI
13+
14+
[Scala CLI](https://scala-cli.virtuslab.org/) is a popular tool among Scala devs. It allows lightning-fast running, testing, and prototyping of Scala scripts and single-module projects. In 3.5.0, it becomes part of the default Scala distribution. If you install Scala through popular package managers, such as Brew or SDKMAN!, the installed `scala` command allows you to compile, run, test, and even publish your code on Maven Central. It has out-of-the-box support for `using` directives, toolkits, compilation to JavaScript and native binaries, and other goodies formerly available only if you installed a separate tool.
15+
16+
### Short example
17+
18+
Given the following file named `biggerThan.scala`
19+
20+
```scala
21+
//> using dep com.lihaoyi::os-lib:0.10.3
22+
23+
@main def run(path: String, size: Int) =
24+
os.list(os.Path(path, os.pwd))
25+
.filter: p =>
26+
os.size(p) > size * 1024
27+
.foreach(println)
28+
```
29+
30+
We can run `scala biggerThan.scala -- ../my-directory 10`. This will download os-lib and its transitive dependencies, compile the source code, and finally run the compiled program, printing all files in `../my-directory` bigger than 10 kB. Subsequent invocations of the command will use cached bytecode, or if the source code changed, trigger incremental compilation.
31+
32+
As os-lib is a part of the default Scala Toolkit, we can replace `//> using dep com.lihaoyi::os-lib:0.10.3` with `//> using toolkit default`. Furthermore, we can add `#!/usr/bin/env -S scala shebang` at the top of the file. Then, after setting the permissions (`chmod +x biggerThan.scala`), we can treat `biggerThan.scala` like any executable script. Invoking `./biggerThan.scala ../my-directory 10` will incrementally compile the file and then run it.
33+
34+
To learn the full scope of the new capabilities, read about Scala CLI [commands](https://scala-cli.virtuslab.org/docs/commands/basics/) and [using-directives](https://scala-cli.virtuslab.org/docs/reference/directives) or glance at [the cookbook](https://scala-cli.virtuslab.org/docs/cookbooks/intro).
35+
36+
Merging Scala CLI into the distribution doesn't change the behavior of popular build tools that work with Scala, such as sbt, Mill, Maven, and Gradle. It does, however, allow for maintaining and publishing single-module multiplatform libraries without any build tool.
37+
38+
## What's new in 3.5.0?
39+
40+
### Best effort compilation
41+
42+
When using Metals, the IDE functions work great on code that compiles. However, once the user starts changing the code, the support drops in quality. This gets worse with a larger number of compilation errors and subsequent modifications. In 3.5.0, we have fixed this problem. We introduced a new mode of compilation called Best Effort Compilation. When enabled, the compiler will output BETASTy files for not-currently-compiling code. It can be used by tooling to provide autocompletion and other IDE features.
43+
44+
To enable the use of BETASTy files in Metals, start the language server with `-Dmetals.enable-best-effort=true` or put that into `metals.serverProperties` setting in VS Code. We plan to enable this feature by default soon after gathering feedback from users.
45+
46+
### Support for pipelined builds
47+
48+
Scala 3.5.0 supports pipelined compilation. It can be enabled by setting `ThisBuild/usePipelining := true` in sbt build definition. This can result in significant speedups in compilation time for multi-module projects.
49+
50+
You can learn more about how the pipelined compilation works and what benefits you can expect from [the talk by Jamie Thompson](https://www.youtube.com/watch?v=1uuFxEAiPuQ&t=1473s).
51+
52+
### `var` in refinements
53+
54+
Until now, only types, `val`s, and `def`s were allowed in type refinements. In 3.5.0, `var`s can also be declared.
55+
56+
```scala
57+
type A = { var number: Int }
58+
```
59+
60+
is now legal and equivalent to
61+
62+
```scala
63+
type A = { def number: Int, def number_=($number: Int): Unit }
64+
```
65+
66+
This change can simplify libraries based on metaprogramming using type refinements.
67+
68+
### Support for binary integer literals
69+
70+
Integer literals can now start with `0b` or `0B`. They will be interpreted as numbers in base 2.
71+
72+
```scala
73+
assert(0B1 == 1)
74+
assert(0B10 == 2)
75+
assert(0B_1000_0010 == 130)
76+
assert(0B_1000_0010 == 0x82)
77+
```
78+
79+
### Experimental: named tuples
80+
81+
Scala 3.5 introduces experimental support for named tuples. The feature, hidden behind the `language.experimental.namedTuples` import, allows you to give meaningful names to tuple elements and use those names during constructing, destructuring, and pattern matching.
82+
83+
```scala
84+
import scala.language.experimental.namedTuples
85+
86+
type Point = (x: Int, y: Int)
87+
val point: Point = (x = 1, y = 2)
88+
val is_it_point = (x = 5, y = 3)
89+
val it_is: Point = is_it_point
90+
91+
println(point.x) // prints 1
92+
93+
point match
94+
case (x = real, y = 0) => println(s"Real number: $real")
95+
case _ => println("Point doesn't represent a real number")
96+
```
97+
98+
This is an implementation of [SIP-58](https://github.com/scala/improvement-proposals/blob/d649f6e6f333cd9232d85a12bd0445d18a673f10/content/named-tuples.md).
99+
100+
### Experimental: new givens and context bounds syntax
101+
102+
Another experimental feature introduced in Scala 3.5 is the new syntax for type classes. Some of these improvements are: `Self` type member instead of the type parameter, auxiliary type alias `is` or named context bounds, just to name a few.
103+
The full list of proposed improvements and their examples can be found under [Modularity Improvements](https://scala-lang.org/api/3.5.0/docs/docs/reference/experimental/modularity.html) and [Better Support for Type Classes](https://scala-lang.org/api/3.5.0/docs/docs/reference/experimental/typeclasses.html).
104+
To test the new syntax you would be required to use both the source version `future` and the additional language import `experimental.modularity`.
105+
106+
```scala
107+
//> using options -source:future -language:experimental.modularity
108+
109+
trait Ord:
110+
type Self
111+
extension (x: Self)
112+
def compareTo(y: Self): Int
113+
def < (y: Self): Boolean = compareTo(y) < 0
114+
def > (y: Self): Boolean = compareTo(y) > 0
115+
116+
given intOrd: (Int is Ord) with
117+
extension (x: Int) def compareTo(y: Int) = if x < y then -1 else if x > y then +1 else 0
118+
119+
def descending[T: Ord as asc]: T is Ord = new:
120+
extension (x: T) def compareTo(y: T) = asc.compareTo(y)(x)
121+
122+
def maximum[T](xs: List[T])(using T is Ord): T =
123+
xs.reduceLeft((x, y) => if (x < y) y else x)
124+
125+
val xs = List(1, 2, 3)
126+
val _ = maximum(xs)
127+
val _ = maximum(xs)(using descending)
128+
val _ = maximum(xs)(using descending(using intOrd))
129+
```
130+
131+
This is an implementation of [SIP-64](https://github.com/scala/improvement-proposals/blob/db5cc6ab92758272f1a3528eacb46182ea216323/content/typeclasses-syntax.md).
132+
133+
## Work on a better scheme for given prioritization
134+
135+
Givens in Scala 3 have a peculiar problem with prioritization. The compiler tries to always select the instance with *the most specific subtype* of the requested type. This can lead to confusing situations, when user faces ambiguity errors in code that should intuitively work. Changing the scheme of given prioritization to always select the instance with *the most general subtype* that satisfies the context bound, would resolve such cases. We have conducted experiments that showed that the proposed scheme will result in a more intuitive and predictable given resolution. The negative impact on the existing projects is very small. We have tested 1500 open-source libraries, and new rules are causing problems for less than a dozen of them. We have already submitted PRs with changes that will make them work the same way under both the current and proposed rules.
136+
137+
For the detailed motivation of changes with examples of code that will be easier to write and understand, see our recent blogpost - [Upcoming Changes to Givens in Scala 3.7](https://scala-lang.org/2024/08/19/given-priority-change-3.7.html).
138+
139+
Our current plan is to introduce the new scheme in Scala 3.7. Starting from Scala 3.6, code whose behavior can differ between new and old rules (ambiguity on new, passing on old, or vice versa) will emit warnings, but the old rules will still be applied. 3.5 gives you a chance to detect if those changes affect your codebase. Running the compiler with `-source 3.6` will give you warnings; with `-source 3.7` or `-source future` you will get the new scheme.
140+
141+
## What's next?
142+
143+
There is already 3.5.1-RC2 published on Maven Central. This release contains multiple fixes and small improvements merged after we branched off the 3.5.0 to focus on polishing it. The release of the next version in the LTS line is coming soon. Scala 3.3.4-RC1 is available for testing. It contains all the forward and backward-compatible fixes available in Scala 3.5.0.
144+
145+
## Contributors
146+
147+
Thank you to all the contributors who made this release possible 🎉
148+
149+
According to `git shortlog -sn --no-merges 3.4.2..3.5.0` these are:
150+
151+
```
152+
153 Martin Odersky
153+
53 Eugene Flesselle
154+
41 Jamie Thompson
155+
29 Wojciech Mazur
156+
25 Nicolas Stucki
157+
22 Sébastien Doeraene
158+
18 noti0na1
159+
16 Matt Bovel
160+
13 Guillaume Martres
161+
11 Paweł Marks
162+
10 Hamza REMMAL
163+
9 Yichen Xu
164+
8 Jan Chyb
165+
7 Hamza Remmal
166+
7 Som Snytt
167+
6 Jędrzej Rochala
168+
5 Fengyun Liu
169+
5 dependabot[bot]
170+
3 Mikołaj Fornal
171+
2 Aviv Keller
172+
2 EnzeXing
173+
1 Chris Pado
174+
1 Filip Zybała
175+
1 Georgi Krastev
176+
1 Jisoo Park
177+
1 Katarzyna Marek
178+
1 Lucas Nouguier
179+
1 Lucy Martin
180+
1 Ola Flisbäck
181+
1 Pascal Weisenburger
182+
1 Quentin Bernet
183+
1 Raphael Jolly
184+
1 Seth Tisue
185+
1 Stephane Bersier
186+
1 Tomasz Godzik
187+
1 Yoonjae Jeon
188+
1 aherlihy
189+
1 rochala
190+
1 willerf
191+
192+
```

resources/img/scala-3.5-launch.jpg

740 KB
Loading

0 commit comments

Comments
 (0)