Skip to content

Commit 483b771

Browse files
authored
Merge pull request #2844 from dotty-staging/release-0.2.0
Dotty 0.2.0-RC1 release announcement draft.
2 parents 4f4ed97 + 74aba5c commit 483b771

File tree

1 file changed

+368
-0
lines changed

1 file changed

+368
-0
lines changed
Lines changed: 368 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,368 @@
1+
---
2+
layout: blog-page
3+
title: Announcing Dotty 0.2.0-RC1, with new optimizations, improved stability and IDE support
4+
author: Dmytro Petrashko
5+
authorImg: /images/petrashko.jpg
6+
date: 2017-07-12
7+
---
8+
9+
Today, we are excited to release Dotty version 0.2.0-RC1. This release
10+
serves as a technology preview that demonstrates new language features
11+
and the compiler supporting them.
12+
13+
This release is based on the [previous milestone](/blog/2017/05/31/first-dotty-milestone-release.html).
14+
The highlights of this release are:
15+
- substantial improvement of quality of generated code for pattern matching
16+
- improvements in VS Code IDE stability
17+
- support Windows in VS Code IDE
18+
- improved compatibility with scalac
19+
- initial support for reproducible builds
20+
21+
22+
<!--more-->
23+
24+
This is our second scheduled release according to our [6-week release schedule](http://dotty.epfl.ch/docs/usage/version-numbers.html).
25+
26+
## What’s in the 0.2.0-RC1 technology preview?
27+
The [previous technology preview](/blog/2017/05/31/first-dotty-milestone-release.html) has shipped new language features planned for Scala 3:
28+
[Intersection Types](http://dotty.epfl.ch/docs/reference/intersection-types.html),
29+
[Union Types](http://dotty.epfl.ch/docs/reference/union-types.html),
30+
[Trait Parameters](http://dotty.epfl.ch/docs/reference/trait-parameters.html),
31+
[Enumerations](http://dotty.epfl.ch/docs/reference/enums/enums.html),
32+
[Algebraic Data Types](http://dotty.epfl.ch/docs/reference/enums/adts.html),
33+
[By-Name Implicits](http://dotty.epfl.ch/docs/reference/implicit-by-name-parameters.html).
34+
35+
This technology preview is geared towards improving stability and reliability. It includes:
36+
37+
- [Local optimizations upstreamed from the Dotty Linker](https://github.com/lampepfl/dotty/pull/2513), [2647](https://github.com/lampepfl/dotty/pull/2647) by ([@OlivierBlanvillain](https://github.com/OlivierBlanvillain)). See more details below.
38+
- [Optimizing Pattern Matcher](https://github.com/lampepfl/dotty/pull/2829) by ([@odersky](https://github.com/odersky))
39+
- [Idempotency checks](https://github.com/lampepfl/dotty/pull/2756) are the first step to reproducible builds
40+
- [Faster Base class sets](https://github.com/lampepfl/dotty/pull/2676) by ([@odersky](https://github.com/odersky)) and ([@darkdimius](https://twitter.com/darkdimius))
41+
- Numerous fixes to IDE and Dotty Language Server covering:
42+
43+
- [Windows support for VS Code plugin](https://github.com/lampepfl/dotty/pull/2776)
44+
- [Fix hover-on-type for implicitly converted expressions](https://github.com/lampepfl/dotty/pull/2836)
45+
- [Fixes to find all references in external projects](https://github.com/lampepfl/dotty/pull/2810), [2773](https://github.com/lampepfl/dotty/pull/2773/files)
46+
- [Fix conflict with dragos-vscode-scala](https://github.com/lampepfl/dotty/pull/2777)
47+
- [Fix ide crash on non-parsable file](https://github.com/lampepfl/dotty/pull/2752)
48+
- [Fix hover functionality for enum classes](https://github.com/lampepfl/dotty/pull/2722)
49+
- [Report errors on Dotty Language Server initialization](https://github.com/lampepfl/dotty/pull/2708)
50+
- [Fixes to sbt setting up Dotty IDE](https://github.com/lampepfl/dotty/pull/2690)
51+
- General stability improvements [2838](https://github.com/lampepfl/dotty/pull/2838), [2787](https://github.com/lampepfl/dotty/pull/2787), [2692](https://github.com/lampepfl/dotty/pull/2692)
52+
53+
- Scalac compatibility improvements:
54+
55+
- [Support Scala 2.12 traits](https://github.com/lampepfl/dotty/pull/2685)
56+
- [Fixes to handling of Scala 2 classfiles](https://github.com/lampepfl/dotty/pull/2834/files)
57+
- [Scalac parser crashes on Dotty.jar](https://github.com/lampepfl/dotty/pull/2719)
58+
59+
- Java compatibility improvements:
60+
61+
- [Fixes to handing of Java generic signatures](https://github.com/lampepfl/dotty/pull/2831)
62+
- [java.lang.System.out is final but that's a lie](https://github.com/lampepfl/dotty/pull/2781)
63+
64+
- Improved error messages:
65+
66+
- [Nicer error message for "implicit function type needs non-empty parameter list"](https://github.com/lampepfl/dotty/pull/2821)
67+
- [Nicer error message for nonsensical modifier combination](https://github.com/lampepfl/dotty/pull/2807/files), [2747](https://github.com/lampepfl/dotty/pull/2747)
68+
- [Nicer error message for supercall inside @inline method](https://github.com/lampepfl/dotty/pull/2740)
69+
- [Check that case classes don't inherit case classes](https://github.com/lampepfl/dotty/pull/2790)
70+
- [Check that named parameters don't conflict with positional ones](https://github.com/lampepfl/dotty/pull/2785)
71+
72+
- Improved command line handling:
73+
74+
- [Support params in a file like @file.txt](https://github.com/lampepfl/dotty/pull/2765)
75+
76+
- Type system stability:
77+
78+
- [Handle wildcard types in unions and intersections](https://github.com/lampepfl/dotty/pull/2742)
79+
80+
- Fixes to implicit search:
81+
82+
- [Fix shadowing of higher order implicits](https://github.com/lampepfl/dotty/pull/2739)
83+
84+
85+
### Better generated code:
86+
87+
As was [spotted](https://twitter.com/gkossakowski/status/870243464528744449) by [@gkossakowski](https://twitter.com/gkossakowski)
88+
in the previous release Dotty was on par with Scala 2.11 in speed. But why is that?
89+
The reason is that Dotty compiled by Dotty had really horrible code generated for pattern matching.
90+
91+
Let's illustrate on a simple example:
92+
93+
```
94+
case class CC(a: Int, b: Object)
95+
96+
def foo(x: Any): Int = {
97+
val (a, b) = x match {
98+
case CC(s @ 1, CC(t, _)) =>
99+
(s , 2)
100+
case _ => (42, 43)
101+
}
102+
a + b
103+
}
104+
105+
def booleans(a: Object) = {
106+
val (b1, b2) = (a.isInstanceOf[CC], a.isInstanceOf[List[Int]])
107+
(b1, b2) match {
108+
case (true, true) => true
109+
case (false, false) => true
110+
case _ => false
111+
}
112+
}
113+
```
114+
115+
116+
The Dotty that was released in the previous milestone didn't contain any optimizations and generated inefficient code for it.
117+
The java-with-goto code below is equivalent to what Dotty generated.
118+
119+
```
120+
// output of dotc 0.1.2-RC1
121+
public int foo(Object x) {
122+
var3_2 = x;
123+
if (!(var3_2 instanceof CC)) ** GOTO lbl-1000
124+
var4_3 = (CC)var3_2;
125+
if (CC$.MODULE$.unapply((CC)var3_2) == null) ** GOTO lbl-1000
126+
var5_4 = CC$.MODULE$.unapply((CC)var3_2);
127+
s = var5_4._1();
128+
var7_6 = var5_4._2();
129+
if (1 != s) ** GOTO lbl-1000
130+
var8_7 = s;
131+
if (!(var7_6 instanceof CC)) ** GOTO lbl-1000
132+
var9_8 = (CC)var7_6;
133+
if (CC$.MODULE$.unapply((CC)var7_6) != null) {
134+
var10_9 = CC$.MODULE$.unapply((CC)var7_6);
135+
var11_10 = var10_9._2();
136+
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)1), (Object)BoxesRunTime.boxToInteger((int)2));
137+
} else lbl-1000: // 5 sources:
138+
{
139+
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)42), (Object)BoxesRunTime.boxToInteger((int)43));
140+
}
141+
var2_11 = v0;
142+
a = BoxesRunTime.unboxToInt((Object)var2_11._1());
143+
b = BoxesRunTime.unboxToInt((Object)var2_11._2());
144+
return a + b;
145+
}
146+
147+
public boolean booleans(Object a) {
148+
Tuple2 tuple2 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof CC)), (Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof List)));
149+
boolean b1 = BoxesRunTime.unboxToBoolean((Object)tuple2._1());
150+
boolean b2 = BoxesRunTime.unboxToBoolean((Object)tuple2._2());
151+
Tuple2 tuple22 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)b1), (Object)BoxesRunTime.boxToBoolean((boolean)b2));
152+
Option option = Tuple2..MODULE$.unapply(tuple22);
153+
if (!option.isEmpty()) {
154+
Tuple2 tuple23 = (Tuple2)option.get();
155+
boolean bl = BoxesRunTime.unboxToBoolean((Object)tuple23._1());
156+
boolean bl2 = BoxesRunTime.unboxToBoolean((Object)tuple23._2());
157+
if (bl) {
158+
boolean bl3 = bl;
159+
if (bl2) {
160+
boolean bl4 = bl2;
161+
return true;
162+
}
163+
}
164+
}
165+
Option option2 = Tuple2..MODULE$.unapply(tuple22);
166+
if (option2.isEmpty()) return false;
167+
Tuple2 tuple24 = (Tuple2)option2.get();
168+
boolean bl = BoxesRunTime.unboxToBoolean((Object)tuple24._1());
169+
boolean bl5 = BoxesRunTime.unboxToBoolean((Object)tuple24._2());
170+
if (bl) return false;
171+
boolean bl6 = bl;
172+
if (bl5) return false;
173+
boolean bl7 = bl5;
174+
return true;
175+
}
176+
```
177+
178+
Due to the new optimizing pattern matcher, Dotty now is able to generate the code below without `-optimise`
179+
180+
```
181+
// output of 0.2.0-RC1 without -optimise
182+
public int foo(Object x) {
183+
var3_2 = x;
184+
if (!(var3_2 instanceof CC)) ** GOTO lbl-1000
185+
var4_3 = CC$.MODULE$.unapply((CC)var3_2);
186+
s = var5_4 = var4_3._1();
187+
if (1 == var5_4 && (var7_6 = var4_3._2()) instanceof CC) {
188+
t = CC$.MODULE$.unapply((CC)var7_6)._1();
189+
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)1), (Object)BoxesRunTime.boxToInteger((int)2));
190+
} else lbl-1000: // 2 sources:
191+
{
192+
v0 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToInteger((int)42), (Object)BoxesRunTime.boxToInteger((int)43));
193+
}
194+
var2_8 = v0;
195+
a = BoxesRunTime.unboxToInt((Object)var2_8._1());
196+
b = BoxesRunTime.unboxToInt((Object)var2_8._2());
197+
return a + b;
198+
}
199+
200+
public boolean booleans(Object a) {
201+
Tuple2 tuple2 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof CC)), (Object)BoxesRunTime.boxToBoolean((boolean)(a instanceof List)));
202+
boolean b1 = BoxesRunTime.unboxToBoolean((Object)tuple2._1());
203+
boolean b2 = BoxesRunTime.unboxToBoolean((Object)tuple2._2());
204+
Tuple2 tuple22 = Tuple2..MODULE$.apply((Object)BoxesRunTime.boxToBoolean((boolean)b1), (Object)BoxesRunTime.boxToBoolean((boolean)b2));
205+
if (tuple22 != null) {
206+
boolean bl;
207+
boolean bl2 = BoxesRunTime.unboxToBoolean((Object)tuple22._1());
208+
if (!bl2) {
209+
bl = bl2;
210+
} else {
211+
if (BoxesRunTime.unboxToBoolean((Object)tuple22._2())) {
212+
return true;
213+
}
214+
bl = bl2;
215+
}
216+
if (!bl) {
217+
if (false != BoxesRunTime.unboxToBoolean((Object)tuple22._2())) return false;
218+
return true;
219+
}
220+
}
221+
return false;
222+
}
223+
```
224+
225+
You can clearly see that it's shorter ;-) and it actually does less work.
226+
If you additionally enable local optimizations, you get decent generated code:
227+
228+
```
229+
// output of 0.2.0-RC1 with -optimise
230+
231+
public int foo(Object x) {
232+
int n;
233+
Tuple2 tuple2;
234+
CC cC;
235+
Object object;
236+
if (x instanceof CC && 1 == (n = (cC = (CC)x)._1()) && (object = cC._2()) instanceof CC) {
237+
((CC)object)._1();
238+
tuple2 = new Tuple2((Object)BoxesRunTime.boxToInteger((int)1), (Object)BoxesRunTime.boxToInteger((int)2));
239+
} else {
240+
tuple2 = new Tuple2((Object)BoxesRunTime.boxToInteger((int)42), (Object)BoxesRunTime.boxToInteger((int)43));
241+
}
242+
Tuple2 tuple22 = tuple2;
243+
return BoxesRunTime.unboxToInt((Object)tuple22._1()) + BoxesRunTime.unboxToInt((Object)tuple22._2());
244+
}
245+
246+
public boolean booleans(Object a) {
247+
boolean bl = a instanceof CC;
248+
boolean bl2 = a instanceof List;
249+
new Tuple2((Object)BoxesRunTime.boxToBoolean((boolean)bl), (Object)BoxesRunTime.boxToBoolean((boolean)bl2));
250+
new Tuple2((Object)BoxesRunTime.boxToBoolean((boolean)bl), (Object)BoxesRunTime.boxToBoolean((boolean)bl2));
251+
if (bl && bl2) {
252+
return true;
253+
}
254+
boolean bl3 = bl;
255+
if (bl3) return false;
256+
if (bl2) return false;
257+
return true;
258+
}
259+
```
260+
261+
This code still has a major inefficiency; it allocates tuples.
262+
We plan to continue the migration of local optimizations from the Dotty Linker that should allow us to generate code that is as
263+
good the code generated by the Dotty Linker with global analysis disabled:
264+
265+
```
266+
// output of Dotty linker https://github.com/dotty-linker/dotty/tree/opto
267+
public int foo(Object x) {
268+
CC cC;
269+
int n = 0;
270+
int n2 = 0;
271+
if (x instanceof CC && 1 == (cC = (CC)x)._1() && cC._2() instanceof CC) {
272+
n = 1;
273+
n2 = 2;
274+
} else {
275+
n = 42;
276+
n2 = 43;
277+
}
278+
return n + n2;
279+
}
280+
281+
public boolean booleans(Object a) {
282+
boolean bl = a instanceof CC;
283+
boolean bl2 = a instanceof List;
284+
if (bl && bl2 || !bl && !bl2) {
285+
return true;
286+
}
287+
return false;
288+
}
289+
```
290+
291+
## How can you try it out?
292+
We ship with tools that help you try out the Dotty platform:
293+
294+
- [IDE features for Visual Studio Code](http://dotty.epfl.ch/docs/usage/ide-support.html)
295+
- [sbt support, including retro-compatibility with Scala 2](https://github.com/lampepfl/dotty-example-project)
296+
297+
298+
You have several alternatives; use the `sbt-dotty` plugin, get a standalone
299+
installation, or try it online on [Scastie].
300+
301+
### sbt
302+
Using sbt 0.13.13 or newer, do:
303+
304+
```
305+
sbt new lampepfl/dotty.g8
306+
```
307+
308+
This will setup a new sbt project with Dotty as compiler. For more details on
309+
using Dotty with sbt, see the
310+
[example project](https://github.com/lampepfl/dotty-example-project).
311+
312+
### Standalone installation
313+
314+
Releases are available for download on the _Releases_
315+
section of the Dotty repository:
316+
[https://github.com/lampepfl/dotty/releases](https://github.com/lampepfl/dotty/releases)
317+
318+
We also provide a [homebrew](https://brew.sh/) package that can be installed by running:
319+
320+
```
321+
brew install lampepfl/brew/dotty
322+
```
323+
324+
In case you have already installed Dotty via brew, you should instead update it:
325+
326+
```
327+
brew upgrade dotty
328+
```
329+
330+
### Scastie
331+
332+
[Scastie], the online Scala playground,
333+
supports Dotty.
334+
You can try it out there without installing anything.
335+
336+
337+
## What are the next steps?
338+
339+
Over the coming weeks and months, we plan to work on the following topics:
340+
341+
- [Add support for using Dotty generated classes with Scala 2.12](https://github.com/lampepfl/dotty/pull/2827)
342+
- [Add Language-level support for HMaps and HLists](https://github.com/lampepfl/dotty/pull/2199);
343+
- Upstream more optimizations from Dotty Linker
344+
- [Add support for existing in the same classpath with Scala 2.12](https://github.com/lampepfl/dotty/pull/2827)
345+
346+
If you want to get your hands dirty with any of this, now is a good
347+
moment to get involved! Join the team of contributors, including
348+
Martin Odersky ([@odersky](https://twitter.com/odersky))
349+
Dmitry Petrashko ([@DarkDimius](https://twitter.com/DarkDimius)),
350+
Guillaume Martres ([@smarter](https://github.com/smarter)),
351+
Felix Mulder ([@felixmulder](https://twitter.com/felixmulder)),
352+
Nicolas Stucki ([@nicolasstucki](https://github.com/nicolasstucki)),
353+
Liu Fengyun ([@liufengyun](https://github.com/liufengyun)),
354+
Olivier Blanvillain ([@OlivierBlanvillain](https://github.com/OlivierBlanvillain)),
355+
and others!
356+
357+
## Library authors: Join our community build
358+
359+
Dotty now has a set of libraries that are built against every nightly snapshot.
360+
Currently this includes scalatest, squants and algebra.
361+
Join our [community build](https://github.com/lampepfl/dotty-community-build)
362+
to make sure that our regression suite includes your library.
363+
364+
365+
To get started, see [https://github.com/lampepfl/dotty](https://github.com/lampepfl/dotty).
366+
367+
368+
[Scastie]: https://scastie.scala-lang.org/?target=dotty

0 commit comments

Comments
 (0)