|
| 1 | +--- |
| 2 | +layout: blog-page |
| 3 | +title: Announcing Dotty 0.5.0-RC1 |
| 4 | +author: Allan Renucci |
| 5 | +authorImg: /images/allan.jpg |
| 6 | +date: 2017-12-01 |
| 7 | +--- |
| 8 | + |
| 9 | +Today, we are excited to release Dotty version 0.5.0-RC1. This release |
| 10 | +serves as a technology preview that demonstrates new language features |
| 11 | +and the compiler supporting them. |
| 12 | + |
| 13 | +If you’re not familiar with Dotty, it's a platform to try out new language concepts and compiler |
| 14 | +technologies for Scala. The focus is mainly on simplification. We remove extraneous syntax |
| 15 | +(e.g. no XML literals), and try to boil down Scala’s types into a smaller set of more fundamental |
| 16 | +constructs. The theory behind these constructs is researched in |
| 17 | +[DOT](https://infoscience.epfl.ch/record/215280), a calculus for dependent object types. |
| 18 | +You can learn more about Dotty on our [website](http://dotty.epfl.ch). |
| 19 | + |
| 20 | +<!--more--> |
| 21 | + |
| 22 | +This is our fifth scheduled release according to our [6-week release schedule](http://dotty.epfl.ch/docs/usage/version-numbers.html). |
| 23 | +The [previous technology preview](/blog/2017/10/16/fourth-dotty-milestone-release.html) added |
| 24 | +support for Scala 2.12 and came with a brand new REPL. |
| 25 | + |
| 26 | +## What’s new in the 0.5.0-RC1 technology preview? |
| 27 | + |
| 28 | +### Reworked implicit search [#3421](https://github.com/lampepfl/dotty/pull/3421) |
| 29 | +The treatment of ambiguity errors has changed. If an ambiguity is encountered |
| 30 | +in some recursive step of an implicit search, the ambiguity is propagated to the caller. |
| 31 | +Example: Say you have the following definitions: |
| 32 | + |
| 33 | +```scala |
| 34 | +class A |
| 35 | +class B extends C |
| 36 | +class C |
| 37 | +implicit def a1: A |
| 38 | +implicit def a2: A |
| 39 | +implicit def b(implicit a: A): B |
| 40 | +implicit def c: C |
| 41 | +``` |
| 42 | + |
| 43 | +and the query `implicitly[C]`. |
| 44 | + |
| 45 | +This query would now be classified as ambiguous. This makes sense, after all |
| 46 | +there are two possible solutions, `b(a1)` and `b(a2)`, neither of which is better |
| 47 | +than the other and both of which are better than the third solution, `c`. |
| 48 | +By contrast, Scala 2 would have rejected the search for `A` as |
| 49 | +ambiguous, and subsequently have classified the query `b(implictly[A])` as a normal fail, |
| 50 | +which means that the alternative `c` would be chosen as solution! |
| 51 | + |
| 52 | +Scala 2's somewhat puzzling behavior with respect to ambiguity has been exploited to implement |
| 53 | +the analogue of a "negated" search in implicit resolution, where a query `Q1` fails if some other |
| 54 | +query `Q2` succeeds and `Q1` succeeds if `Q2` fails. With the new cleaned up behavior these |
| 55 | +techniques no longer work. But there is now a new special type `scala.implicits.Not` which |
| 56 | +implements negation directly. For any query type `Q`: `Not[Q]` succeeds if and only if the |
| 57 | +implicit search for `Q` fails. |
| 58 | + |
| 59 | +### Dependent function types [#3464](https://github.com/lampepfl/dotty/pull/3464) |
| 60 | +A dependent function type describes functions where the result type may depend |
| 61 | +on the function's parameter values. Example: |
| 62 | + |
| 63 | +```scala |
| 64 | +class Entry { type Key; key: Key } |
| 65 | + |
| 66 | +def extractKey(e: Entry): e.Key = e.key // a dependent method |
| 67 | +val extractor: (e: Entry) => e.Key = extractKey // a dependent function value |
| 68 | +``` |
| 69 | + |
| 70 | +Scala already has _dependent methods_, i.e. methods where the result |
| 71 | +type refers to some of the parameters of the method. Method |
| 72 | +`extractKey` is an example. Its result type, `e.key` refers its |
| 73 | +parameter `e` (we also say, `e.Key` _depends_ on `e`). But so far it |
| 74 | +was not possible to turn such methods into function values, so that |
| 75 | +they can be passed as parameters to other functions, or returned as |
| 76 | +results. Dependent methods could not be turned into functions simply |
| 77 | +because there was no type that could describe them. |
| 78 | + |
| 79 | +In Dotty this is now possible. The type of the `extractor` value above is |
| 80 | + |
| 81 | +```scala |
| 82 | +(e: Entry) => e.Key |
| 83 | +``` |
| 84 | + |
| 85 | +This type describes function values that take any argument `x` of type |
| 86 | +`Entry` and return a result of type `x.Key`. |
| 87 | + |
| 88 | +### TASTY frontend |
| 89 | +[TASTY](https://docs.google.com/document/d/1Wp86JKpRxyWTqUU39H40ZdXOlacTNs20aTj7anZLQDw/edit) is a |
| 90 | +new serialization format for typed syntax trees of Scala programs. When compiled by Dotty, a program |
| 91 | +classfile will include its TASTY representation in addition to its bytecode. |
| 92 | + |
| 93 | +The TASTY frontend uses ASTs from the TASTY in classfiles as input instead of source files. There |
| 94 | +are currently two backends using the TASTY frontend: |
| 95 | + |
| 96 | + - A Dotty class file decompiler that let you decompile code previously compiled to TASTY: |
| 97 | + |
| 98 | + ```shell |
| 99 | + dotc -decompile -classpath <classpath> <classname> |
| 100 | + ``` |
| 101 | + |
| 102 | + - A Dotty TASTY compiler that will recompile code previously compiled to TASTY: |
| 103 | + |
| 104 | + ```shell |
| 105 | + dotc -from-tasty -classpath <classpath> <classname> |
| 106 | + ``` |
| 107 | + |
| 108 | + This is the first step toward linking and whole word optimisations, recompiling code to a |
| 109 | + different backends... |
| 110 | + |
| 111 | +### Generic java signatures [#3234](https://github.com/lampepfl/dotty/pull/3234) |
| 112 | +Dotty now emits generic signatures for classes and methods. Theses signatures are used by compilers, |
| 113 | +debuggers and to support runtime reflection. For example: |
| 114 | + |
| 115 | +```scala |
| 116 | +scala> class Foo[T, U] |
| 117 | +// defined class Foo |
| 118 | +scala> classOf[Foo[_, _]].getTypeParameters.map(_.getName).mkString(", ") |
| 119 | +val res0: String = "T, U" |
| 120 | +``` |
| 121 | + |
| 122 | +## Trying out Dotty |
| 123 | +### Scastie |
| 124 | +[Scastie], the online Scala playground, supports Dotty. |
| 125 | +This is an easy way to try Dotty without installing anything. |
| 126 | + |
| 127 | +### sbt |
| 128 | +Using sbt 0.13.13 or newer, do: |
| 129 | + |
| 130 | +```shell |
| 131 | +sbt new lampepfl/dotty.g8 |
| 132 | +``` |
| 133 | + |
| 134 | +This will setup a new sbt project with Dotty as compiler. For more details on |
| 135 | +using Dotty with sbt, see the |
| 136 | +[example project](https://github.com/lampepfl/dotty-example-project). |
| 137 | + |
| 138 | +### IDE support |
| 139 | +It is very easy to start using the Dotty IDE in any Dotty project by following |
| 140 | +the [IDE guide](http://dotty.epfl.ch/docs/usage/ide-support.html). |
| 141 | + |
| 142 | + |
| 143 | +### Standalone installation |
| 144 | +Releases are available for download on the _Releases_ |
| 145 | +section of the Dotty repository: |
| 146 | +[https://github.com/lampepfl/dotty/releases](https://github.com/lampepfl/dotty/releases) |
| 147 | + |
| 148 | +We also provide a [homebrew](https://brew.sh/) package that can be installed by running: |
| 149 | + |
| 150 | +```shell |
| 151 | +brew install lampepfl/brew/dotty |
| 152 | +``` |
| 153 | + |
| 154 | +In case you have already installed Dotty via brew, you should instead update it: |
| 155 | + |
| 156 | +```shell |
| 157 | +brew upgrade dotty |
| 158 | +``` |
| 159 | + |
| 160 | +## Let us know what you think! |
| 161 | +If you have questions or any sort of feedback, feel free to send us a message on our |
| 162 | +[Gitter channel](https://gitter.im/lampepfl/dotty). If you encounter a bug, please |
| 163 | +[open an issue on GitHub](https://github.com/lampepfl/dotty/issues/new). |
| 164 | + |
| 165 | +## Contributing |
| 166 | +Thank you to all the contributors who made this release possible! |
| 167 | + |
| 168 | +According to `git shortlog -sn --no-merges 0.4.0-RC1..0.5.0-RC1` these are: |
| 169 | + |
| 170 | +``` |
| 171 | + 112 Nicolas Stucki |
| 172 | + 108 Martin Odersky |
| 173 | + 33 Allan Renucci |
| 174 | + 18 Guillaume Martres |
| 175 | + 17 Martin Duhem |
| 176 | + 13 liu fengyun |
| 177 | + 9 Miron Aseev |
| 178 | + 4 Matt D'Souza |
| 179 | + 4 Raphael Bosshard |
| 180 | + 2 k0ala |
| 181 | + 2 Vitor Vieira |
| 182 | + 2 Fengyun Liu |
| 183 | + 2 Michal Gutowski |
| 184 | + 2 Robert Soeldner |
| 185 | + 2 Aurélien Richez |
| 186 | + 1 rsoeldner |
| 187 | + 1 Hermes Espínola González |
| 188 | + 1 Jean Detoeuf |
| 189 | + 1 Karol Chmist |
| 190 | + 1 Olivier Blanvillain |
| 191 | + 1 William Narmontas |
| 192 | + 1 Yevgen Nerush |
| 193 | + 1 gan74 |
| 194 | + 1 gosubpl |
| 195 | +``` |
| 196 | + |
| 197 | +If you want to get your hands dirty and contribute to Dotty, now is a good time to get involved! |
| 198 | +You can have a look at our [Getting Started page for new contributors](http://dotty.epfl.ch/docs/contributing/getting-started.html), |
| 199 | +the [Awesome Error Messages](http://scala-lang.org/blog/2016/10/14/dotty-errors.html) project or some of |
| 200 | +the simple [Dotty issues](https://github.com/lampepfl/dotty/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%3Anovice). |
| 201 | +They make perfect entry-points into hacking on the compiler. |
| 202 | + |
| 203 | +We are looking forward to having you join the team of contributors. |
| 204 | + |
| 205 | +## Library authors: Join our community build |
| 206 | +Dotty now has a set of widely-used community libraries that are built against every nightly Dotty |
| 207 | +snapshot. Currently this includes ScalaPB, algebra, scalatest, scopt and squants. |
| 208 | +Join our [community build](https://github.com/lampepfl/dotty-community-build) |
| 209 | +to make sure that our regression suite includes your library. |
| 210 | + |
| 211 | + |
| 212 | +[Scastie]: https://scastie.scala-lang.org/?target=dotty |
| 213 | + |
| 214 | +[@odersky]: https://github.com/odersky |
| 215 | +[@DarkDimius]: https://github.com/DarkDimius |
| 216 | +[@smarter]: https://github.com/smarter |
| 217 | +[@felixmulder]: https://github.com/felixmulder |
| 218 | +[@nicolasstucki]: https://github.com/nicolasstucki |
| 219 | +[@liufengyun]: https://github.com/liufengyun |
| 220 | +[@OlivierBlanvillain]: https://github.com/OlivierBlanvillain |
| 221 | +[@biboudis]: https://github.com/biboudis |
| 222 | +[@allanrenucci]: https://github.com/allanrenucci |
0 commit comments