Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Seth Tisue <[email protected]>
  • Loading branch information
Kordyjan and SethTisue committed Aug 7, 2024
1 parent 6c6d932 commit 0497971
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions blog/_posts/2024-10-15-scala-3.5.0-released.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ title: Scala 3.5.0 released!

![Scala 3.5]({{ site.baseurl }}/resources/img/scala-3.5-launch.jpg)

We are happy to announce that after the long and hard work of the entire compiler team and seven release candidates, the first version of the Scala 3.5 line is officially out!
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!

## New default runner - Scala CLI

[Scala CLI](https://scala-cli.virtuslab.org/) is a popular tool among Scala devs. It allows lightning-fast running, testing, and prototyping of small Scala projects and scripts. Since 3.5.0, it has become a part of the default Scala distribution. If you install Scala through popular package managers, such as Brew or SDKMAN!, the installed `scala` command will allow you to compile, run, test, and even publish your code on Maven Central. It will have out-of-the-box support using-directives, toolkits, compilation to native and js targets, and other goodies formerly available only if you installed a third-party tool.
[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.

### Short example

If we have the following file named `biggerThan.scala`
Given the following file named `biggerThan.scala`

```scala
//> using dep com.lihaoyi::os-lib:0.10.3
Expand All @@ -27,23 +27,23 @@ If we have the following file named `biggerThan.scala`
.foreach(println)
```

We can run `scala biggerThan -- ../my-directory 10`. This will download the os-lib and all its transitive dependencies, then compile the source file, and finally run the compiled program, printing all files in `../my-directory` bigger than 10 kB. Subsequent invocations of the command will use cached binary, or in case of changes in the file, trigger incremental compilation.
We can run `scala biggerThan -- ../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.

As os-lib is a part of the default Scala toolkit, we can replace the `//> using dep com.lihaoyi::os-lib:0.10.3` line 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, we can treat `biggerThan.scala` as any executable script. Invoking `./biggerThan.scala ../my-directory 10` will incrementally compile the file and then run it.
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.

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).

Merging Scala CLI into the compiler doesn't change the behavior of popular build tools, such as sbt or Mill. It will, however, allow for maintaining and publishing single-module multiplatform libraries without any build tool.
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.

## What's new in 3.5.0?

### Best Effort Compilation
### Best effort compilation

When using Metals, the IDE functions work great as long as the code passes the compilation. 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 compiling code. It can be used by tooling to provide autocompletion and other IDE features.
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.

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.

### Support for Pipelined Builds
### Support for pipelined builds

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.

Expand Down Expand Up @@ -112,7 +112,7 @@ Our current plan is to introduce the new scheme in Scala 3.7. Starting from Scal

## What's next?

There is already 3.5.1-RC1 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 up until Scala 3.5.0.
There is already 3.5.1-RC1 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.

## Contributors

Expand Down

0 comments on commit 0497971

Please sign in to comment.