|
| 1 | +--- |
| 2 | +layout: blog-detail |
| 3 | +post-type: blog |
| 4 | +by: Martin Odersky |
| 5 | +title: "Towards Scala 3" |
| 6 | +--- |
| 7 | + |
| 8 | +Now that Scala 2.13 is only a few months away, it's time to consider the |
| 9 | +roadmap beyond it. It's been no secret that the work on [Dotty](https://github.com/lampepfl/dotty) over the |
| 10 | +last 5 years was intended to explore what a new Scala could look |
| 11 | +like. We are now at a stage where we can commit: Dotty will become |
| 12 | +Scala 3.0. |
| 13 | + |
| 14 | +Of course, this statement invites many follow-up questions. Here are |
| 15 | +some answers we can already give today. We expect there will be more |
| 16 | +questions and answers as things shape up. |
| 17 | + |
| 18 | +_When will it come out?_ |
| 19 | + |
| 20 | +The intent is to publish the final Scala 3.0 soon after Scala 2.14. At the |
| 21 | +current release schedule (which might still change), that means early 2020. |
| 22 | + |
| 23 | +_What is Scala 2.14 for?_ |
| 24 | + |
| 25 | +Scala 2.14's main focus will be on smoothing the migration to Scala 3. |
| 26 | +It will do this by defining migration tools, shim libraries, and |
| 27 | +targeted deprecations, among others. |
| 28 | + |
| 29 | +_What's new in Scala 3?_ |
| 30 | + |
| 31 | +Scala has pioneered the fusion of object-oriented and functional |
| 32 | +programming in a typed setting. Scala 3 will be a big step towards |
| 33 | +realizing the full potential of these ideas. Its main objectives are |
| 34 | +to |
| 35 | + |
| 36 | + - become more opinionated by promoting programming idioms we found |
| 37 | +to work well, |
| 38 | + - simplify where possible, |
| 39 | + - eliminate inconsistencies and surprising behavior, |
| 40 | + - build on strong foundations to ensure the design hangs well together, |
| 41 | + - consolidate language constructs to improve the language’s consistency, safety, ergonomics, and performance. |
| 42 | + |
| 43 | +The main language changes, either implemented or projected, are listed |
| 44 | +in the [Reference section on the Dotty website](http://dotty.epfl.ch/docs/reference/overview.html). |
| 45 | +Many of the new features will be submitted to the [SIP](https://docs.scala-lang.org/sips) process, subject to approval. |
| 46 | + |
| 47 | +It's worth emphasizing that Scala 2 and Scala 3 are fundamentally the |
| 48 | +same language. The compiler is new, but nearly everything Scala |
| 49 | +programmers already know about Scala 2 applies to Scala 3 as well, and |
| 50 | +most ordinary Scala 2 code will also work on Scala 3 with only minor |
| 51 | +changes. |
| 52 | + |
| 53 | +_What about migration?_ |
| 54 | + |
| 55 | +As with previous Scala upgrades, Scala 3 is not binary compatible with Scala 2. |
| 56 | +They are mostly source compatible, but differences exist. However: |
| 57 | + |
| 58 | + - Scala 3 code can use Scala 2 artifacts because the Scala 3 compiler |
| 59 | + understands the classfile format for sources compiled with Scala 2.12 and upwards. |
| 60 | + - Scala 3 and Scala 2 share the same standard library. |
| 61 | + - With some small tweaks it is possible to cross-build code for both Scala 2 and 3. |
| 62 | + We will provide a guide defining the shared language subset that can be compiled under both versions. |
| 63 | + - The Scala 3 compiler has a `-language:Scala2` option that lets it compile most Scala 2 code |
| 64 | + and at the same time highlights necessary rewritings as migration warnings. |
| 65 | + - The compiler can perform many of the rewritings automatically using a `-rewrite` option. |
| 66 | + - Migration through automatic rewriting will also be offered through the [scalafix](https://github.com/scalacenter/scalafix) tool, which can convert sources to the cross-buildable language subset without requiring Scala 3 to be installed. |
| 67 | + |
| 68 | +_What’s the expected state of tool support?_ |
| 69 | + |
| 70 | + - Compiler: The Scala 3 compiler `dotc` has been used to compile itself and a growing set of libraries for a number of years now. |
| 71 | + - IDEs: IDE support is provided by having `dotc` implement LSP, the [Language Server Protocol](https://langserver.org), |
| 72 | + including standard operations such as completion and hyperlinking and more advanced ones |
| 73 | + such as find references or rename. There’s a [VS Code plugin](http://dotty.epfl.ch/docs/usage/ide-support.html) incorporating these operations. |
| 74 | + JetBrains has also released a first version of Scala 3 support in their [Scala IntelliJ plugin](https://blog.jetbrains.com/scala/2017/03/23/scala-plugin-for-intellij-idea-2017-1-cleaner-ui-sbt-shell-repl-worksheet-akka-support-and-more), and we intend to work with them on further improvements. |
| 75 | + - REPL: A friendly REPL is supported by the compiler |
| 76 | + - Docs: A revamped Scaladoc tool generates docs for viewing in a browser and (in the future) also in the IDE.. |
| 77 | + - Build tools: There is a Dotty/Scala 3 plugin for [sbt](https://www.scala-sbt.org), and we will also work on Scala 3 integration in other build tools. |
| 78 | + |
| 79 | +_What about stability?_ |
| 80 | + |
| 81 | + - A [community build](https://github.com/lampepfl/dotty-community-build) contains some [initial open source projects](https://github.com/lampepfl/dotty-community-build/blob/master/src/test/scala/dotty/communitybuild/CommunityBuildTest.scala) that are compiled nightly using Scala 3. We plan to add a lot more projects to the build between now and the final release. |
| 82 | + - We plan to use the period of developer previews to ensure that core projects are published for Scala 3. |
| 83 | + - We have incorporated most of the Scala 2 regression tests in the Scala 3 test suite and will keep including new tests. |
| 84 | + - In the near future we plan to build all Scala 3 tools using a previous version of the `dotc` compiler itself. |
| 85 | + So far all tools are built first with the current Scala compiler and then again with `dotc`. |
| 86 | + Basing the build exclusively on Scala 3 has the advantage that it lets us “eat our own dog food” |
| 87 | + and try out the usability of Scala 3’s new language feature on a larger scale. |
| 88 | + |
| 89 | +_When can I try it out?_ |
| 90 | + |
| 91 | +You can start working with Dotty now. See the [getting |
| 92 | +started](http://dotty.epfl.ch/docs/contributing/getting-started.html) |
| 93 | +guide. Dotty releases are published every 6 weeks. We expect to be in |
| 94 | +feature-freeze and to release developer previews for Scala 3.0 in the |
| 95 | +first half of 2019. |
| 96 | + |
| 97 | +_What about macros?_ |
| 98 | + |
| 99 | +Stay tuned! We are about to release another blog post specifically |
| 100 | +about that issue. |
| 101 | + |
| 102 | +_How can I help?_ |
| 103 | + |
| 104 | +Scala 3 is developed completely in the open at |
| 105 | +[https://github.com/lampepfl/dotty](https://github.com/lampepfl/dotty). |
| 106 | +Get involved there, by fixing and |
| 107 | +opening issues, making pull requests, and participating in the |
| 108 | +discussions. |
0 commit comments