Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Dart: The Dawn of Web Apps
Search
Ladislav Thon
February 24, 2013
1
470
Dart: The Dawn of Web Apps
Ladislav Thon
February 24, 2013
Tweet
Share
More Decks by Ladislav Thon
See All by Ladislav Thon
On Value Types or Why Reference Locality Matters
ladicek
0
34
Write Yourself an Annotation Processor
ladicek
0
39
Kotlin or The Quest For Java.Next
ladicek
0
170
Dart++
ladicek
0
130
Oh my Dart!
ladicek
1
150
Dart: Preview
ladicek
0
81
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
500
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
173
51k
Code Reviewing Like a Champion
maltzj
521
39k
Mobile First: as difficult as doing things right
swwweet
222
9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
3
180
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Thoughts on Productivity
jonyablonski
68
4.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Transcript
Come to the Dart side! We have cookies!
Dart: The Dawn of Web Apps ladicek.github.com
500 000 lines of JS
500 000 lines of JS Say hello to Dart!
main() { print("Hello, Dart!"); }
class Person { var name, age; Person(this.name, this.age); toString() =>
"$name ($age years)"; } main() { var me = new Person("Ladislav Thon", 30); print(me); }
Optional typing void main() { Person me = new Person("Ladislav
Thon", 30); List<Person> people = [me, ...]; people.forEach((Person person) => print(person)); people.forEach((person) { // iterable print(person); }); people.forEach(print); // closurization }
Innocent until proven guilty
Client-side code import 'dart:html'; main() { query('#button').onClick.listen((event) { // stream
... }); }
Server-side code import 'dart:io'; main() { HttpServer.bind('127.0.0.1', 1337).then((server) { //
future server.listen((request) { // stream … }); }); }
Isolates import 'dart:isolate'; main() { var box = new MessageBox();
streamSpawnFunction(worker).add( { 'replyTo': box.sink, 'value': ... } ); // sink box.stream.listen((response) { ... }); // stream } worker() { stream.listen((message) { ... }); }
Mirrors import 'dart:mirrors'; main() { var person = new Person(...);
var personMirror = reflect(person); personMirror.getField('name').then((resultMirror) { print(resultMirror.reflectee); }); // async today, probably sync in the future }
And a lot more
Implicit interfaces & properties abstract class Person { get name;
get age; set age(value); } class Monster implements Person { final name = 'Cthulhu'; var age = '?!?!?!'; }
Inheritance & mixins class Entity { int id; } //
or whatever abstract class Named { get name; toString() => '$name'; } class Person extends Entity with Named { get name => 'Cthulhu'; }
Optional parameters class Person { var name, age; Person({this.name: '<unknown>',
this.age: 0}); growOlder([years = 1]) { age += years; } } main() { var me = new Person(name: 'Ladislav Thon'); me.growOlder(30); }
Constructors class Person { final name, age; Person(this.name, this.age); Person.me()
: name = 'Ladislav Thon', age = 30; static Person cache; factory Person.cachedMe() { if (cache == null) { cache = new Person.me(); } return cache; } }
Cascades class Person { var name, age; } main() {
var me = new Person() ..name = 'Ladislav Thon' ..age = 30; }
Privacy class Person { var _isEnemy; var name, age; }
main() { // in another library var me = ...; print(me._isEnemy); // NO! }
class Proxy { var target; Proxy(this.target); noSuchMethod(invocation) { print('Calling ${invocation.memberName}');
return invocation.invokeOn(target); } }
Web UI
Web UI Web Components
Web UI MDV Templates
Web UI Polyfill for current browsers
HTML part <element name="x-counter" constructor="Counter" extends="div"> <template> <span>{{value}}</span> <button on-click="increment()">+1</button>
</template> <script type="application/dart">...</script> </element>
Dart part import 'package:web_ui/web_ui.dart'; class Counter extends WebComponent { int
value = 0; increment() { value++; } }
Usage <html> <head> <link rel="components" href="counter.html"> </head> <body> <x-counter></x-counter> <script
type="application/dart">main() {}</script> </body> </html>
Conditions & iteration <table template if="rows != null && !rows.isEmpty">
<tr template iterate="headerItem in header"> <th>{{headerItem}}</th> </tr> <tbody template iterate="row in rows"> <tr template iterate="item in row"> <td>{{item}}</td> </tr> </tbody> </table>
Passing values <html> <head> <link rel="components" href="grid.html"> </head> <body> <x-grid
header="{{header}}" rows="{{rows}}"> </x-grid> <script type="application/dart">...</script> </body> </html>
Performance Fast startup
Performance Fast runtime (beats V8 already)
Tooling Eclipse, IntelliJ IDEA vim, Sublime Text
So what is it all about?
So what is it all about? Structure!
www.dartlang.org
ladicek.github.com ?