-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
434 lines (384 loc) · 11.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
<!DOCTYPE html>
<html>
<head>
<title>Hack&Learn – Dart</title>
<meta charset='utf-8'>
<script src='http://html5slides.googlecode.com/svn/trunk/slides.js'></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<style>
.special-center {
width: 450px;
margin: 70px auto 0 auto;
}
</style>
<body style='display: none'>
<section class='slides layout-regular template-custom'>
<article class='biglogo'></article>
<article>
<h1>Hack&Learn<br/>Dart</h1>
<p><a href="http://about.me/daniel.mendalka">Daniel Mendalka</a><br/>Dec 17, 2011</p>
</article>
<article class="build">
<h3>About Dart in general</h3>
<p>Public preview on October 10 – only 2 months 1 week old!</p>
<p class="bigger special-center">Dart » JavaScript<br/>Java » C</p>
<p class="bigger special-center">Java + JavaScript = Dart</p>
</article>
<article>
<h3>Dart in nutshell</h3>
<q>Purely Object-Oriented, optionally typed, class-based, single inheritance with actor-based concurrency.</q>
<div class='author'>Gilad Bracha</div>
</article>
<article>
<h3>Dart in nutshell</h3>
<ul class="build">
<li>
<b>Object-Oriented</b>
<ul>
<li>Everything is an Object</li>
<li>No primitives – null, int, double, num, … are objects</li>
</ul>
</li>
<li>
<b>Optionally typed</b>
<ul>
<li>Use var or <classname> for creating variable</li>
<li>Classes don't influance on runtime</li>
<li>Use Checked Mode if you need stop compilation on incompatible class error</li>
<li>"Guilty until proven innocent" – "Innocent until proven guilty"</li>
</ul>
</li>
</article>
<article>
<h3>Dart in nutshell</h3>
<ul class="build">
<li>
<b>Class-based</b>
<ul>
<li><code>class</code> & <code>extends</code></li>
<li><code>interface</code> & <code>implements</code></li>
</ul>
</li>
<li><b>Single inheritance</b></li>
<li>
<b>Actor-based concurrency</b>
<ul>
<li>Dart is single threaded</li>
<li>Inspired by Erlang, use Isolates for concurrency</li>
<li>Each isolate is seperate process</li>
<li>Nothing is shared</li>
<li>All communication via messages</li>
</ul>
</li>
</ul>
</article>
<article>
<h3>Performance</h3>
<p>Not yet, consider it as a feature to add in the future.</p>
<table>
<tr>
<th>Benchmark</th><th>VM</th><th>DartC</th>
</tr>
<tr>
<td>Mandelbrot</td><td>18.2%</td><td>88.7%</td>
</tr>
<tr>
<td>DeltaBlue</td><td>56.6%</td><td>52.2%</td>
</tr>
<tr>
<td>Richards</td><td>56.0%</td><td>70.9%</td>
</tr>
<tr>
<td>NBody</td><td>35.8%</td><td>63.6%</td>
</tr>
<tr>
<td>BinaryTrees</td><td>77.3%</td><td>104.3%</td>
</tr>
<tr>
<td>Fannkuch</td><td>53.8%</td><td>22.3%</td>
</tr>
<tr>
<td>Meteor</td><td>50.3%</td><td>42.1%</td>
</tr>
<div class="source">Octobet 19, 2011</div>
</table>
</article>
<article>
<h2>Code examples</h2>
</article>
<article>
<h3>Hello, World</h3>
<section class="build">
<pre>
main() {
print('Hello, World');
}
</pre>
<pre>
main() => print('Hello, World');
</pre>
</section>
</article>
<article>
<h3>String interpolation</h3>
<section>
<pre>
main() {
var s1 = 'Hello';
var s2 = 'World';
print(s1 + ', ' + s2);
print('$s1, $s2');
var count = 0;
print('$s1, $s2 ${count+1}');
}
</pre>
</section>
</article>
<article>
<h3>Class + getter & setter</h3>
<section>
<pre>
class Greeter {
String _prefix = 'Hello,'; // Hidden instance variable.
String get prefix() => _prefix; // Getter for prefix.
void set prefix(String value) { // Setter for prefix.
if (value == null) value = "";
_prefix = value;
}
greet(name) {
print('$prefix $name');
}
}
main() {
var greeter = new Greeter();
greeter.prefix = 'Howdy,';
greeter.greet('setter!');
}
</pre>
</section>
</article>
<article>
<h3>Named constructors</h3>
<section>
<pre>
class Greeter {
//(...)
Greeter();
Greeter.withPrefix(this.prefix);
//(...)
}
main() {
var greeter = new Greeter.withPrefix('Howdy,');
greeter.greet('setter!');
}
</pre>
</section>
</article>
<article>
<h3>Another trick with constructors</h3>
<section>
<pre>
class Rect {
var x,y;
Rect(this.x,this.y);
String toString() => "${this.x},${this.y}";
}
class Square extends Rect {
Square(x) : super(x,x);
}
main() {
print(new Rect(1,2));
print(new Square(2));
}
</pre>
</section>
</article>
<article>
<h3>Operator Overloading #1</h3>
<section>
<pre>
class Point {
var x, y;
Point(this.x, this.y);
operator +(Point second) {
return new Point(this.x + second.x, this.y + second.y);
}
String toString() => '${this.x},${this.y}';
}
main() {
Point p = new Point(2, 3);
Point q = new Point(3, 4);
print(p + q);
}
</pre>
</section>
</article>
<article>
<h3>Operator Overloading #2</h3>
<section>
<pre>
class Point {
var x, y;
Point(this.x, this.y);
operator ==(Point second) {
return (this.x == second.x && this.y == second.y);
}
}
main() {
print(new Point(2, 3) == new Point(2, 3));
}
</pre>
</section>
</article>
<article>
<h3>Optional & Named Parameters</h3>
<section>
<pre>
hello(msg, to, [from]) => '$from sent $msg to $to';
main() {
print(hello('Hi', 'Daniel')); //null sent Hi to Daniel
print(hello('Hi', from:'Daniel', to:'World')); //Daniel sent Hi to World
}
</pre>
<pre>
hello(msg, to, [from='Me']) => '$from sent $msg to $to';
main() {
print(hello('Hi', 'Daniel')); //Me sent Hi to Daniel
}
</pre>
</section>
</article>
<article>
<h3>Lexical scope</h3>
<section>
<pre>
// Javascript prints: "3, 3, 3"
// Dart prints: "1, 2, 3"
main() {
var callbacks = [];
for(var text in [1, 2, 3]) {
callbacks.add(() => print(text));
}
for (var callback in callbacks) {
callback();
}
}
</pre>
</section>
</article>
<article>
<h3>Isolate</h3>
<section>
<pre>
class Printer extends Isolate {
main() {
port.receive((message, replyTo) {
if (message == null) port.close();
else print(message);
});
}
}
main() {
new Printer().spawn().then((port) {
for (var message in ['Hello', 'from', 'other', 'isolate']) {
port.send(message);
}
port.send(null);
});
}
</pre>
</section>
</article>
<article>
<h3>Libraries</h3>
<section>
<pre>
#import('dart:html');
#import('dart:core');
//import another library
#import('customLibrary.dart');
//import library from external server
#import("http://dartwatch.com/externalLibrary.dart");
//import library with prefix
#import("myOtherLibrary.dart", prefix:"lib");
</pre>
<pre>
#library('mylibrary'); //define library name
#source('fileAsPartOfLibrary.dart'); //include files into library;
#source('secondFileAsPartOfLibrary.dart');
</pre>
</section>
</article>
<article>
<h3>New MIME type and inline Dart code</h3>
<section>
<pre>
<html>
<body>
<script type="application/dart">
main() {
Element element = document.getElementById('message');
element.innerHTML = 'Hello from Dart';
}
</script>
<div id="message"></div>
</body>
</html>
</pre>
</section>
</article>
<article>
<h3>Demos</h3>
<ul>
<li><a href="http://www.dartlang.org/samples/sunflower/sunflower-js.html" target="_blank">Sunflower</a></li>
<li><a href="http://www.dartlang.org/samples/spirodraw/spirodraw-js.html" target="_blank">Spirodraw</a></li>
<li><a href="http://total-dart.appspot.com/" target="_blank">Total</a></li>
</ul>
</article>
<article>
<h3>Tools</h3>
<ul>
<li><a href="http://try.dartlang.org/">try.dartlang.org</a></li>
<li><a href="http://www.dartlang.org/docs/getting-started/editor/index-macos.html">Dart Editor</a></li>
<li>
<b>Dartium</b>
<ul>
<li><a href="http://code.google.com/p/dart/wiki/PreparingYourMachine">Prepare</a><li>
<li><a href="http://dev.chromium.org/developers/how-tos/install-depot-tools">depot_tools</a><li>
<li><a href="http://code.google.com/p/dart/wiki/BuildingDartium">Building Dartium</a></li>
</ul>
</li>
</ul>
</article>
<article class="smaller">
<h3>Dark side</h3>
<q>Some examples, like Dart, portend that JavaScript has fundamental flaws and to support these scenarios requires a 'clean break' from JavaScript in both syntax and runtime. We disagree with this point of view.</q>
<div class="author">Microsoft's JavaScript team</div>
</article>
<article class="smaller">
<h3>Dark side</h3>
<q>Adding an additional web facing language (that isn't standardized) doesn't seem beneficial to the project, if anything it seems harmful (cf. VBScript in IE)</q>
<div class="author">Oliver Hunt (Webkit, Apple)</div>
</article>
<article class="smaller">
<h3>Dark side</h3>
<q style="font-size: 90%;">I guarantee you that Apple and Microsoft (and Opera and Mozilla, but the first two are enough) will never embed the Dart VM. So 'Works best in Chrome' and even 'Works only in Chrome' are new norms promulgated intentionally by Google. We see more of this fragmentation every day. As a user of Chrome and Firefox (and Safari), I find it painful to experience, never mind the political bad taste.</q>
<div class="author">Brendan Eich</div>
</article>
<article>
<h3>Community</h3>
<ul>
<li><a href="http://www.dartlang.org/" target="_blank">www.dartlang.org</a></li>
<li><a href="http://www.dartlang.org/slides/" target="_blank">www.dartlang.org/slides/</a></li>
<li><a href="http://dart.googlecode.com/" target="_blank">dart.googlecode.com</a></li>
<li><a href="http://blog.sethladd.com/" target="_blank">Seth Ladd's blog</a></li>
<li><a href="https://plus.google.com/s/%23dartlang" target="_blank">#dartlang on Google+</a></li>
<li><a href="http://dartwatch.com/" target="_blank">Dartwatch</a></li>
<li><a href="http://dartweekly.com/" target="_blank">Dart Weekly</a></li>
<li><b><a href="https://groups.google.com/a/dartlang.org/group/misc/topics" target="_blank">Dart discussion group</a></b></li>
</ul>
</article>
</section>
</body>
</html>