|
| 1 | +--- |
| 2 | +layout: blog-page |
| 3 | +title: Announcing Dotty 0.11.0-RC1 |
| 4 | +author: Allan Renucci |
| 5 | +authorImg: /images/allan.jpg |
| 6 | +date: 2018-11-30 |
| 7 | +--- |
| 8 | + |
| 9 | +Today we are excited to release Dotty version 0.11.0-RC1. |
| 10 | +This release serves as a technology preview that demonstrates new language features and the |
| 11 | +compiler supporting them. |
| 12 | + |
| 13 | +Dotty is the project name for technologies that are considered for inclusion in Scala 3. Scala has |
| 14 | +pioneered the fusion of object-oriented and functional programming in a typed setting. Scala 3 will |
| 15 | +be a big step towards realising the full potential of these ideas. Its main objectives are to |
| 16 | + |
| 17 | +- become more opinionated by promoting programming idioms we found to work well, |
| 18 | +- simplify where possible, |
| 19 | +- eliminate inconsistencies and surprising behaviours, |
| 20 | +- build on strong foundations to ensure the design hangs well together, |
| 21 | +- consolidate language constructs to improve the language’s consistency, safety, ergonomics, and |
| 22 | + performance. |
| 23 | + |
| 24 | +You can learn more about Dotty on our [website](https://dotty.epfl.ch). |
| 25 | + |
| 26 | +<!--more--> |
| 27 | + |
| 28 | +This is our 11th scheduled release according to our |
| 29 | +[6-week release schedule](https://dotty.epfl.ch/docs/usage/version-numbers.html). |
| 30 | + |
| 31 | +## What’s new in the 0.11.0-RC1 technology preview? |
| 32 | + |
| 33 | +### Opaque Type Aliases |
| 34 | + |
| 35 | +Opaque types aliases provide type abstraction without any overhead. Example: |
| 36 | + |
| 37 | +```scala |
| 38 | +opaque type Duration = Long |
| 39 | +``` |
| 40 | + |
| 41 | +This introduces `Duration` as a new type, which is implemented as a `Long` but is different from |
| 42 | +it. The fact that `Duration` is the same as `Long` is only known in the companion object of |
| 43 | +`Duration`. Here is a possible companion object: |
| 44 | + |
| 45 | +```scala |
| 46 | +object Duration { |
| 47 | + |
| 48 | + // These are the ways to lift to the Duration type |
| 49 | + def fromNanos(duration: Long): Duration = duration |
| 50 | + def fromSeconds(duration: Long): Duration = duration * 1000000000 |
| 51 | + |
| 52 | + // This is the first way to unlift the Duration type |
| 53 | + def toNanos(l: Duration): Long = l |
| 54 | + |
| 55 | + // Extension methods define opaque types' public APIs |
| 56 | + implicit class DurationOps(self: Duration) extends AnyVal { |
| 57 | + // This is the second way to unlift the Duration type |
| 58 | + def toSeconds: Long = self / 1000000000 |
| 59 | + def + (that: Duration): Duration = self + that |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +The companion object contains the `fromNanos` and `fromSeconds` methods that convert from longs to |
| 65 | +`Duration` values. It also adds a `toNanos` function and a decorator that implements `+` on |
| 66 | +duration values, as well as a conversion `toSeconds`. All of this is possible because within object |
| 67 | +`Duration`, the type `Duration` is just an alias of `Long`. |
| 68 | + |
| 69 | +Outside the companion object, `Duration` is treated as a new abstract type. So the following |
| 70 | +operations would be valid because they use functionality implemented in the `Duration` |
| 71 | +object. |
| 72 | + |
| 73 | +```scala |
| 74 | +val d1 = Duration.fromNanos(1000L) |
| 75 | +val d2 = Duration.fromSeconds(2L) |
| 76 | +val d3 = d1 + d2 |
| 77 | +``` |
| 78 | + |
| 79 | +But the following operations would lead to type errors: |
| 80 | + |
| 81 | +```scala |
| 82 | +val l: Long = d1 // error: found: Duration, required: Long |
| 83 | +val d: Duration = 3L // error: found: Long(3L), required: Duration |
| 84 | +d1 + 2L // error: found: Long(2L), required: Duration |
| 85 | +d1 - d2 // error: `-` is not a member of Duration |
| 86 | +``` |
| 87 | + |
| 88 | +### Worksheet Mode Support in Visual Studio Code |
| 89 | + |
| 90 | +Dotty IDE can now be used in Worksheet mode. A worksheet is a Scala file that is evaluated on save, |
| 91 | +and the result of each expression is displayed in a column on the right of your program. Worksheets |
| 92 | +are like a REPL session on steroids, and enjoy 1st class editor support: completions, hyperlinking, |
| 93 | +interactive errors-as-you-type, etc. |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | +For more information about the worksheets, see [Worksheet mode with Dotty |
| 98 | +IDE](http://dotty.epfl.ch/docs/usage/worksheet-mode.html) |
| 99 | + |
| 100 | +### Various IDE improvements |
| 101 | + |
| 102 | +#### Help with method signatures |
| 103 | + |
| 104 | +When writing a method call, Dotty IDE will now show contextual information that helps filling in the |
| 105 | +arguments of the method. |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +#### Improved display of documentation in Dotty IDE |
| 110 | + |
| 111 | +In this release, we reworked how we show documentation inside the IDE. We now extract usefull |
| 112 | +information from the Scaladoc comment, then format it before we display it in the IDE. |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +### And much more! |
| 117 | + |
| 118 | +Please read our [release notes](https://github.com/lampepfl/dotty/releases/tag/0.11.0-RC1) |
| 119 | +for more details! |
| 120 | + |
| 121 | +## Trying out Dotty |
| 122 | + |
| 123 | +### sbt |
| 124 | + |
| 125 | +You can setup a new sbt project with Dotty as the compiler by running: |
| 126 | + |
| 127 | +```shell |
| 128 | +sbt new lampepfl/dotty.g8 |
| 129 | +``` |
| 130 | + |
| 131 | +For more details on using Dotty with sbt, see the |
| 132 | +[example project](https://github.com/lampepfl/dotty-example-project). |
| 133 | + |
| 134 | +### [Mill](http://www.lihaoyi.com/mill/) |
| 135 | + |
| 136 | +The Mill build tool version 0.2.6 introduced experimental support for Dotty. For more details on |
| 137 | +using Dotty with Mill, see the |
| 138 | +[example project](https://github.com/lampepfl/dotty-example-project/tree/mill). |
| 139 | + |
| 140 | +### IDE support |
| 141 | + |
| 142 | +Start using the Dotty IDE in any Dotty project by following |
| 143 | +the [IDE guide](https://dotty.epfl.ch/docs/usage/ide-support.html). |
| 144 | + |
| 145 | +### Standalone installation |
| 146 | + |
| 147 | +Releases are available for download on the _Releases_ |
| 148 | +section of the Dotty repository: |
| 149 | +[https://github.com/lampepfl/dotty/releases](https://github.com/lampepfl/dotty/releases) |
| 150 | + |
| 151 | +For MacOs users, we also provide a [homebrew](https://brew.sh/) package that can be installed by |
| 152 | +running: |
| 153 | + |
| 154 | +```shell |
| 155 | +brew install lampepfl/brew/dotty |
| 156 | +``` |
| 157 | + |
| 158 | +In case you have already installed Dotty via `brew`, you should instead update it: |
| 159 | + |
| 160 | +```shell |
| 161 | +brew upgrade dotty |
| 162 | +``` |
| 163 | + |
| 164 | +## Let us know what you think! |
| 165 | + |
| 166 | +If you have questions or any sort of feedback, feel free to send us a message on our |
| 167 | +[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please |
| 168 | +[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new). |
| 169 | + |
| 170 | +## Contributing |
| 171 | + |
| 172 | +Thank you to all the contributors who made this release possible! |
| 173 | + |
| 174 | +According to `git shortlog -sn --no-merges 0.10.0..0.11.0-RC1` these are: |
| 175 | + |
| 176 | +``` |
| 177 | + 143 Martin Duhem |
| 178 | + 104 Nicolas Stucki |
| 179 | + 82 Martin Odersky |
| 180 | + 60 Guillaume Martres |
| 181 | + 35 Allan Renucci |
| 182 | + 21 poechsel |
| 183 | + 12 Olivier Blanvillain |
| 184 | + 10 Liu Fengyun |
| 185 | + 8 Aleksander Boruch-Gruszecki |
| 186 | + 6 Tobias Bordenca |
| 187 | + 5 Sébastien Doeraene |
| 188 | + 4 Stéphane Micheloud |
| 189 | + 3 João Pedro Evangelista |
| 190 | + 3 Miles Sabin |
| 191 | + 3 Neeraj Jaiswal |
| 192 | + 3 Abel Nieto |
| 193 | + 2 Ólafur Páll Geirsson |
| 194 | + 2 Fengyun Liu |
| 195 | + 2 veera venky |
| 196 | + 1 mikhail |
| 197 | + 1 Glavo |
| 198 | + 1 0xflotus |
| 199 | + 1 Paolo G. Giarrusso |
| 200 | +``` |
| 201 | + |
| 202 | +If you want to get your hands dirty and contribute to Dotty, now is a good time to get involved! |
| 203 | +Head to our [Getting Started page for new contributors](https://dotty.epfl.ch/docs/contributing/getting-started.html), |
| 204 | +and have a look at some of the [good first issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%3Anovice). |
| 205 | +They make perfect entry points into hacking on the compiler. |
| 206 | + |
| 207 | +We are looking forward to having you join the team of contributors. |
| 208 | + |
| 209 | +## Library authors: Join our community build |
| 210 | + |
| 211 | +Dotty now has a set of widely-used community libraries that are built against every nightly Dotty |
| 212 | +snapshot. Currently this includes ScalaPB, algebra, scalatest, scopt and squants. |
| 213 | +Join our [community build](https://github.com/lampepfl/dotty-community-build) |
| 214 | +to make sure that our regression suite includes your library. |
| 215 | + |
| 216 | +[Scastie]: https://scastie.scala-lang.org/?target=dotty |
| 217 | + |
| 218 | +[@odersky]: https://github.com/odersky |
| 219 | +[@DarkDimius]: https://github.com/DarkDimius |
| 220 | +[@smarter]: https://github.com/smarter |
| 221 | +[@felixmulder]: https://github.com/felixmulder |
| 222 | +[@nicolasstucki]: https://github.com/nicolasstucki |
| 223 | +[@liufengyun]: https://github.com/liufengyun |
| 224 | +[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain |
| 225 | +[@biboudis]: https://github.com/biboudis |
| 226 | +[@allanrenucci]: https://github.com/allanrenucci |
| 227 | +[@Blaisorblade]: https://github.com/Blaisorblade |
| 228 | +[@Duhemm]: https://github.com/Duhemm |
0 commit comments