SlideShare a Scribd company logo
Dart 
The better Javascript ? 
Jorg Janke 
jorg@accorto.com 
Slides link: 
http://bizfabrik.com 
October 2014
Structure 
● Why Dart? 
● Example 
● Dart Language 
● Dart Tooling 
● Questions 
The goal of Dart is "ultimately to 
replace JavaScript as the lingua 
franca of web development on 
the open web platform”
Where are you coming from? 
● Java 
o GWT 
o Servlet, JSP, JSF, .. 
● .Net 
o Typescript 
● PHP, Python, Ruby, … 
● Mobile Native 
● Javascript 
Front-end 
Technology
Who is Jorg Janke? 
● Education: MBA 
(Accounting), IT 
● Jobs 
o ADV/Orga 
o Unisys - Prod.Mgr 
o Oracle - Dir Apps 
o Self employed since 
1999 
● Experience 
o Mainframe, Unix, Linux 
o Algol, PL/I, SmallTalk 
o Oracle DBA 
o Java since 1.1 
o Dart since 1.0 
● Founder: Compiere 
o Open Source ERP
What is Dart 
● OO/Functional Programming Language 
o Executed in Dartium (Chrome) 
o Generating Javascript Executable dart2js 
● Created/Maintained by Google 
● ECMA-408 Standard 
o http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf 
● Targeting Client + Server
Lot’s of good Dart Overviews 
Check 
● https://www.dartlang.org/ 
● Books ... 
● http://video.coldfrontconf.com/ 
why-google-thinks-you-should-drop 
I concentrate here on Developer experience
Dart - becoming popular 
● TIOBE Index - October 2014 
o #1: C 17% 
o #2: Java 14% 
o #3: Objective-C 10% - odd - a bit high 
o #4: C++ 4.8% 
o #10: JavaScript 1.7% - odd - a bit low 
o #17: Dart 1.1% 
o #25: ActionScript 0.6% 
o http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
Why we picked 
Dart 
… not stayed with GWT
BizFabrik UI Requirements/Features 
● Mobile First 
o disconnected 
● 24/7 
o active for days 
● User 
o Expert/Guidance 
o Own Layout 
 switch 
o Analytics built in 
● Admin 
o Add/Change Tables/ 
Fields/Processes/ 
Validations/... 
● General 
o Dynamic Model 
Driven Architecture 
o Multi-Tenant/Locale 
o AWS/GAE/OnPremise
What we wanted to avoid 
● Multiple UIs - browser + naive(s) 
● Hard to Develop 
o Good IDE - Step through Debugging 
● Hard to Maintain (different code styles, …) .. in 5y 
o Developer Learning curve -- “Sonar” 
● Hard to Understand 
o Partners/Customers to extend 
● Fighting libraries - dependencies - conflicts
Alternatives evaluated 
● GWT (Used) 
o Easy Java Integration 
o Stable “mature” 
o Very good build process 
o A bit heavy 
o Lost in Translation (Java 
Structure <> JS features 
class <> prototypal) 
● JSP/JSF/… 
o Connected only 
● Coffeescript 
o Step in the right direction 
● Typescript 
o commitment? 
● Javascript “pure” 
o improved IDE support & 
tooling - JSLint 
o hard to build sizeable apps 
o too many different styles 
o no static analysis
BizFabrik Architecture 
● Java Backend 
o SOAP/REST 
● Dart 
o (Bootstrap css) 
o Grid/Form/.. 
o Gantt Graph (svg) 
● Communication 
o ? JSON (using Rest) 
● Protocol Buffers 
o binary (smaller than 
JSON, especially 
data rows) 
o fast (~ same 
de/serializing speed) 
o Data Transfer 
Objects (get/set..) 
o for many languages
Demo 
~ 1,400 kb compressed js
Grid Mode 
Built in Analytics/Data Visualization
User defined - switchable Layout 
Form Guidance Mode
Form Expert Mode 
Form|Grid 
Master/Detail/..
All UIs 
dynamically generated 
Customizable 
+ Dynamically Extendable 
(webhooks) 
Context dependent 
validation/visibility/layout 
(multiple levels) 
First dynamic MDA 
(Model Driven Architecture) 
Compiere ERP 
- 2000 Java Swing 
- 2007 GWT (1:1) 
Salesforce calls theirs 
MetaData Driven 
BizFabrik 
- redesigned from Scratch 
for Data Visualization of 
multiple DataSources 
- GWT 2012 
redesigned from Scratch 
- Dart 2014 (3 months)
Dart selection reasons 
● Good DOM 
(Polyfill) API 
● “Close to the metal” 
o eventually JS 
o Web Components, ... 
● Streams, Futures 
● Libraries 
● Type support 
No worry about 
Javascript: 
The Bad Parts 
new - this - null - falsiness - 
for (in) - ... 
Douglas Crockford
Static Typing increases Productivity 
● Static typing and 
Documentation 
o Dynamic Languages 
require Context 
switches 
● Source: Dr. A. Stefik, +An 
empirical study on the impact of static 
typing on software 
maintainabilityhttp://web.cs.unlv.edu/stefik 
a/Papers.php
Dart Environment 
Dart Language 
core, collection, 
async, io, isolate, math, 
mirrors, typed_data 
DOM API 
html, svg, indexed_db, 
web_gl/audio/sql 
Pub 
Build / Libs / 
Packages 
Logging 
Intl 
Route 
Polymer Distribution 
Angular Dart 
Protocol Buff 
IDE: 
- Dart 
- IntelliJ 
Plugins: 
- Sublime 
etc 
Version Control 
+ Dependencies 
Unittest
Dart IDE options 
Dart IDE 
● Scaled down old Eclipse 
version 
● Usability ++ 
o Starts very fast 
o Getting started 
● IDE Feature set -- 
o unstable with Dev Tools 
IntelliJ - Dart 
● works with minor itches 
Full Eclipse 
● not tried 
Chrome Dev Editor 
● early days 
Debugging in Dartium
Predefined Structure (Pub) 
● bin 
● doc 
● example 
● lib 
o lib.dart 
● test 
● tool 
● web 
o project.dart 
o project.html 
● pubspec.yaml 
● packages 
o in main directory 
o links: sub directories 
 /web /tool /test 
/bin /example 
 (not /lib) 
o allows “package/..” 
references anywhere 
copied into 
packages
Java Package => Libraries 
Java 
● Directory = package 
● File = class 
● FileName = className 
Dart 
● Directory, FileName 
does not matter... if you 
have good memory 
library libx; 
// part = code imports 
part “aa/bb/file.dart”; 
part of libx; 
class a{} 
class b{} 
aa/bb/file.dart
Java Converts: 
You are ultimately writing Javascript !!! 
Javascript: The Good Parts
Language Features 
● Cannot cover all 
o for complete details see dartlang.org 
● I like the most 
o single inheritance .. with mixins 
 intro to prototypal + functional programming 
● with a safety net 
o named parameters
Great! Optional / Named Parameters 
int f1 (int mandatory, {int optional: 2}) {..} 
use: 
f1(2); 
f1(2, optional: 3); 
int f2 (int mandatory, [int second = 2]) {..} 
use: 
f2(2); 
f2(1,2);
Named Constructors 
● MyClass(String this.p1, int this.i1) {} 
o saves the: this.p1 = p1; 
● MyClass.fromXml(String xml) {..} 
o No overloading - better documentation 
o alternative 
 static MyClass parse(String xml) {..}
Oohh well .. - no overloading 
workaround: 
String dump(dynamic param) { 
if (param is X1) return _dumpX1(param as X1); 
if (param is X2) return _dumpX2(param as X2); 
} 
String _dumpX1(X1 value) {..} 
String _dumpX2(X2 value) {..}
Async done nicely + future 
one many 
sync T 
Iterable<T> 
(..) {..} (..) sync* {..} 
async Future<T> Stream<T> 
await (..) async {..} (..) async* {..} 
main() async { startAnalytics() async { // 
doesn’t block 
.. await .. await 
analytics.loadLib(); 
}
Great! Function variables 
● Example 
o static int parse(String s, { int onError(String s)}); 
● Use 
o int xx=int.parse(“12”); 
o int xx=int.parse(“12”, onError: (String s) {return -1;}); 
o int xx=int.parse(“12”, onError: intErrorHandler); 
int intErrorHandler(String s) {return -1;} 
… if you are 
coming from 
Java7 
… this and Streams eliminate “callback hell”
Public - Internal - controlled 
class X { 
int public; 
int _internal; 
int get getter {..} 
void set setter (int value) {..} 
} 
Use: X xx = new X(); 
xx.public = 5; // r/w 
xx._internal = 5; // Library 
int z = xx.getter; 
xx.setter = 5; 
… a bit confusing at first when to use what: 
- function - isEmpty() 
- or attribute - isEmpty
Better Strings 
String s = ’’’Multiple 
Line 
String’’’; 
s = “String” “ in” “ parts”; 
s = ‘This “works” too’; 
s = r’raw string n’; 
s = “String with ${param}”; 
if (s.isEmpty) {} 
if (s.isNotEmpty) {} 
trivial, but I like it 
Java char <> 
CodeUnit|CharCode
Type Surprises (... coming from Java) 
bool initial = true; 
int active = 5; 
: 
int ms = initial ? 0 : 1000; 
if (active > 10) 
ms += (active/10) * 200; 
… compiles fine 
ms is an int - right?
Type Surprises (... coming from Java) 
bool initial = true; 
int active = 5; 
: 
int ms = initial ? 0 : 1000; 
if (active > 10) 
ms += (active/10) * 200; 
… compiles fine 
ms is an int - right? 
Runtime: 
● double 
Fix: 
ms += (active~/10) * 200; 
… compiler (analyzer) 
should catch that
Type Surprises - Lists 
int add(List<int> ints) {..} 
int x = add([1,”a”, 3]); 
List<O1> o1List = …; 
List<O2> o2List = …; 
for (O1 in o2List) {..} 
… compiles fine 
Runtime Error 
… compiler (analyser) 
should catch that
Libraries - Pub 
Core Libraries 
● async 
● collection 
● html + js 
● io (server) 
● svg, web_gl, ... 
http://pub.dartlang.org 
● angular 
● googleapis 
● dquery (jQuery) 
● web_components 
polymer 
use js (libs) directly 
● intl well designed 
… but often not immutable
Web Components 
Polymer 
● Design your own 
HTML tags 
● Two-way binding 
Dart - DOM 
● Shadow DOM 
AngularDart 1.0new 
● Re-implementation 
⇒ AngularJs 2.0 
● MVC Framework 
o Controller - 
Directives - 
Components 
we don’t write HTML - we generate the DOM
Upgrades 
● Expect a new Version every 1-2 months 
o independent from library upgrade cycle 
o Started Dart 1.0 - Nov 2013 
 1.6.0 - Aug 2014 
 1.7 .. looming 
● Upgrade is quite painless 
o Also Library: pub upgrade
Dart Wishlist 
● CSS (Less/Saas) integration 
o Minify css names (like GWT) 
● Load Modules on demand 
o Split generated js (like GWT) 
● BigDecimal ⇉ Dec64 
● Ability to return tuples 
o … like Scala 
● Full Immutable library option
Dart Productivity: Good! 
● Easy to get going 
o Java ⇒ Functional 
● Good Tools 
o not on Java level 
● Rich Libraries 
● Performance 
o Benchmarks 
● Mostly Unsurprising 
semantics 
o No Strong Typing 
(like Scala) 
● Doc a bit light 
o helps if you know 
Javascript/HTML
Dart Performance (native, js, dart2js) 
https://www.dartlang.org/performance/
When “back” to Java Programming 
● where are named parameters? 
● why is async so hard? 
● very happy to get back to Dart: 
The better Javascript ! 
Douglas Crockford: 
Dart: too much baggage 
… waiting for the messiah
Questions ? 
Jorg Janke 
jorg@accorto.com 
Slides link:

More Related Content

PDF
Structured web programming
PDF
Start dart
PDF
PPTX
PDF
Let's Play Dart
PDF
Dart, Darrt, Darrrt
PDF
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
Structured web programming
Start dart
Let's Play Dart
Dart, Darrt, Darrrt
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...

What's hot (20)

PDF
Dart Workshop
PDF
Dart programming tutorial
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
PDF
Crystal internals (part 1)
PPTX
002. Introducere in type script
PDF
8 introduction to_java_script
PDF
Introduction to the Dart language
PPTX
Getting started with typescript
PDF
TypeScript introduction to scalable javascript application
PPTX
TypeScript: Basic Features and Compilation Guide
PDF
Advanced PHP Simplified
PDF
Getting Started with TypeScript
PDF
Typescript: enjoying large scale browser development
PPTX
Introduction about type script
PDF
TypeScript: coding JavaScript without the pain
PDF
Code generating beans in Java
PDF
Java vs. C/C++
PDF
Typescript for the programmers who like javascript
PPT
introduction to javascript
PPTX
Java script
Dart Workshop
Dart programming tutorial
TypeScript - Silver Bullet for the Full-stack Developers
Crystal internals (part 1)
002. Introducere in type script
8 introduction to_java_script
Introduction to the Dart language
Getting started with typescript
TypeScript introduction to scalable javascript application
TypeScript: Basic Features and Compilation Guide
Advanced PHP Simplified
Getting Started with TypeScript
Typescript: enjoying large scale browser development
Introduction about type script
TypeScript: coding JavaScript without the pain
Code generating beans in Java
Java vs. C/C++
Typescript for the programmers who like javascript
introduction to javascript
Java script
Ad

Similar to Dart the Better JavaScript (20)

PDF
Dart the better Javascript 2015
PPTX
Dart, unicorns and rainbows
PPTX
Dart programming language
PPTX
Dart structured web apps
PPTX
Dartprogramming
PDF
Structured Apps with Google Dart
PDF
Introduction to Dart
PPTX
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
PDF
Dart By Example 1st Edition Davy Mitchell
PPTX
Presentaion on Dart and Flutter Development.pptx
PPT
No JS and DartCon
PPT
Building Single-Page Web Appplications in dart - Devoxx France 2013
PDF
Dart for Java Developers
PPTX
Dart_Programming_language_and_Flutter_Framework.pptx
PPTX
Dart London hackathon
PDF
Dart
PDF
Dart Programming Language - Singsys Blog
PDF
Introduction to Flutter - truly crossplatform, amazingly fast
PDF
Dart Scalable Application Development Learning Path 1st Edition Davy Mitchell...
Dart the better Javascript 2015
Dart, unicorns and rainbows
Dart programming language
Dart structured web apps
Dartprogramming
Structured Apps with Google Dart
Introduction to Dart
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
Dart By Example 1st Edition Davy Mitchell
Presentaion on Dart and Flutter Development.pptx
No JS and DartCon
Building Single-Page Web Appplications in dart - Devoxx France 2013
Dart for Java Developers
Dart_Programming_language_and_Flutter_Framework.pptx
Dart London hackathon
Dart
Dart Programming Language - Singsys Blog
Introduction to Flutter - truly crossplatform, amazingly fast
Dart Scalable Application Development Learning Path 1st Edition Davy Mitchell...
Ad

Recently uploaded (20)

PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PPTX
artificial intelligence overview of it and more
PPTX
innovation process that make everything different.pptx
PPTX
QR Codes Qr codecodecodecodecocodedecodecode
PPTX
Internet___Basics___Styled_ presentation
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
Introuction about WHO-FIC in ICD-10.pptx
DOCX
Unit-3 cyber security network security of internet system
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
Funds Management Learning Material for Beg
PPTX
Introduction to Information and Communication Technology
PDF
Testing WebRTC applications at scale.pdf
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PDF
Triggering QUIC, presented by Geoff Huston at IETF 123
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Slides PDF The World Game (s) Eco Economic Epochs.pdf
artificial intelligence overview of it and more
innovation process that make everything different.pptx
QR Codes Qr codecodecodecodecocodedecodecode
Internet___Basics___Styled_ presentation
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Decoding a Decade: 10 Years of Applied CTI Discipline
Introuction about WHO-FIC in ICD-10.pptx
Unit-3 cyber security network security of internet system
Design_with_Watersergyerge45hrbgre4top (1).ppt
Slides PPTX World Game (s) Eco Economic Epochs.pptx
Funds Management Learning Material for Beg
Introduction to Information and Communication Technology
Testing WebRTC applications at scale.pdf
An introduction to the IFRS (ISSB) Stndards.pdf
Triggering QUIC, presented by Geoff Huston at IETF 123
Module 1 - Cyber Law and Ethics 101.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
Automated vs Manual WooCommerce to Shopify Migration_ Pros & Cons.pdf
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION

Dart the Better JavaScript

  • 1. Dart The better Javascript ? Jorg Janke [email protected] Slides link: http://bizfabrik.com October 2014
  • 2. Structure ● Why Dart? ● Example ● Dart Language ● Dart Tooling ● Questions The goal of Dart is "ultimately to replace JavaScript as the lingua franca of web development on the open web platform”
  • 3. Where are you coming from? ● Java o GWT o Servlet, JSP, JSF, .. ● .Net o Typescript ● PHP, Python, Ruby, … ● Mobile Native ● Javascript Front-end Technology
  • 4. Who is Jorg Janke? ● Education: MBA (Accounting), IT ● Jobs o ADV/Orga o Unisys - Prod.Mgr o Oracle - Dir Apps o Self employed since 1999 ● Experience o Mainframe, Unix, Linux o Algol, PL/I, SmallTalk o Oracle DBA o Java since 1.1 o Dart since 1.0 ● Founder: Compiere o Open Source ERP
  • 5. What is Dart ● OO/Functional Programming Language o Executed in Dartium (Chrome) o Generating Javascript Executable dart2js ● Created/Maintained by Google ● ECMA-408 Standard o http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf ● Targeting Client + Server
  • 6. Lot’s of good Dart Overviews Check ● https://www.dartlang.org/ ● Books ... ● http://video.coldfrontconf.com/ why-google-thinks-you-should-drop I concentrate here on Developer experience
  • 7. Dart - becoming popular ● TIOBE Index - October 2014 o #1: C 17% o #2: Java 14% o #3: Objective-C 10% - odd - a bit high o #4: C++ 4.8% o #10: JavaScript 1.7% - odd - a bit low o #17: Dart 1.1% o #25: ActionScript 0.6% o http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
  • 8. Why we picked Dart … not stayed with GWT
  • 9. BizFabrik UI Requirements/Features ● Mobile First o disconnected ● 24/7 o active for days ● User o Expert/Guidance o Own Layout  switch o Analytics built in ● Admin o Add/Change Tables/ Fields/Processes/ Validations/... ● General o Dynamic Model Driven Architecture o Multi-Tenant/Locale o AWS/GAE/OnPremise
  • 10. What we wanted to avoid ● Multiple UIs - browser + naive(s) ● Hard to Develop o Good IDE - Step through Debugging ● Hard to Maintain (different code styles, …) .. in 5y o Developer Learning curve -- “Sonar” ● Hard to Understand o Partners/Customers to extend ● Fighting libraries - dependencies - conflicts
  • 11. Alternatives evaluated ● GWT (Used) o Easy Java Integration o Stable “mature” o Very good build process o A bit heavy o Lost in Translation (Java Structure <> JS features class <> prototypal) ● JSP/JSF/… o Connected only ● Coffeescript o Step in the right direction ● Typescript o commitment? ● Javascript “pure” o improved IDE support & tooling - JSLint o hard to build sizeable apps o too many different styles o no static analysis
  • 12. BizFabrik Architecture ● Java Backend o SOAP/REST ● Dart o (Bootstrap css) o Grid/Form/.. o Gantt Graph (svg) ● Communication o ? JSON (using Rest) ● Protocol Buffers o binary (smaller than JSON, especially data rows) o fast (~ same de/serializing speed) o Data Transfer Objects (get/set..) o for many languages
  • 13. Demo ~ 1,400 kb compressed js
  • 14. Grid Mode Built in Analytics/Data Visualization
  • 15. User defined - switchable Layout Form Guidance Mode
  • 16. Form Expert Mode Form|Grid Master/Detail/..
  • 17. All UIs dynamically generated Customizable + Dynamically Extendable (webhooks) Context dependent validation/visibility/layout (multiple levels) First dynamic MDA (Model Driven Architecture) Compiere ERP - 2000 Java Swing - 2007 GWT (1:1) Salesforce calls theirs MetaData Driven BizFabrik - redesigned from Scratch for Data Visualization of multiple DataSources - GWT 2012 redesigned from Scratch - Dart 2014 (3 months)
  • 18. Dart selection reasons ● Good DOM (Polyfill) API ● “Close to the metal” o eventually JS o Web Components, ... ● Streams, Futures ● Libraries ● Type support No worry about Javascript: The Bad Parts new - this - null - falsiness - for (in) - ... Douglas Crockford
  • 19. Static Typing increases Productivity ● Static typing and Documentation o Dynamic Languages require Context switches ● Source: Dr. A. Stefik, +An empirical study on the impact of static typing on software maintainabilityhttp://web.cs.unlv.edu/stefik a/Papers.php
  • 20. Dart Environment Dart Language core, collection, async, io, isolate, math, mirrors, typed_data DOM API html, svg, indexed_db, web_gl/audio/sql Pub Build / Libs / Packages Logging Intl Route Polymer Distribution Angular Dart Protocol Buff IDE: - Dart - IntelliJ Plugins: - Sublime etc Version Control + Dependencies Unittest
  • 21. Dart IDE options Dart IDE ● Scaled down old Eclipse version ● Usability ++ o Starts very fast o Getting started ● IDE Feature set -- o unstable with Dev Tools IntelliJ - Dart ● works with minor itches Full Eclipse ● not tried Chrome Dev Editor ● early days Debugging in Dartium
  • 22. Predefined Structure (Pub) ● bin ● doc ● example ● lib o lib.dart ● test ● tool ● web o project.dart o project.html ● pubspec.yaml ● packages o in main directory o links: sub directories  /web /tool /test /bin /example  (not /lib) o allows “package/..” references anywhere copied into packages
  • 23. Java Package => Libraries Java ● Directory = package ● File = class ● FileName = className Dart ● Directory, FileName does not matter... if you have good memory library libx; // part = code imports part “aa/bb/file.dart”; part of libx; class a{} class b{} aa/bb/file.dart
  • 24. Java Converts: You are ultimately writing Javascript !!! Javascript: The Good Parts
  • 25. Language Features ● Cannot cover all o for complete details see dartlang.org ● I like the most o single inheritance .. with mixins  intro to prototypal + functional programming ● with a safety net o named parameters
  • 26. Great! Optional / Named Parameters int f1 (int mandatory, {int optional: 2}) {..} use: f1(2); f1(2, optional: 3); int f2 (int mandatory, [int second = 2]) {..} use: f2(2); f2(1,2);
  • 27. Named Constructors ● MyClass(String this.p1, int this.i1) {} o saves the: this.p1 = p1; ● MyClass.fromXml(String xml) {..} o No overloading - better documentation o alternative  static MyClass parse(String xml) {..}
  • 28. Oohh well .. - no overloading workaround: String dump(dynamic param) { if (param is X1) return _dumpX1(param as X1); if (param is X2) return _dumpX2(param as X2); } String _dumpX1(X1 value) {..} String _dumpX2(X2 value) {..}
  • 29. Async done nicely + future one many sync T Iterable<T> (..) {..} (..) sync* {..} async Future<T> Stream<T> await (..) async {..} (..) async* {..} main() async { startAnalytics() async { // doesn’t block .. await .. await analytics.loadLib(); }
  • 30. Great! Function variables ● Example o static int parse(String s, { int onError(String s)}); ● Use o int xx=int.parse(“12”); o int xx=int.parse(“12”, onError: (String s) {return -1;}); o int xx=int.parse(“12”, onError: intErrorHandler); int intErrorHandler(String s) {return -1;} … if you are coming from Java7 … this and Streams eliminate “callback hell”
  • 31. Public - Internal - controlled class X { int public; int _internal; int get getter {..} void set setter (int value) {..} } Use: X xx = new X(); xx.public = 5; // r/w xx._internal = 5; // Library int z = xx.getter; xx.setter = 5; … a bit confusing at first when to use what: - function - isEmpty() - or attribute - isEmpty
  • 32. Better Strings String s = ’’’Multiple Line String’’’; s = “String” “ in” “ parts”; s = ‘This “works” too’; s = r’raw string n’; s = “String with ${param}”; if (s.isEmpty) {} if (s.isNotEmpty) {} trivial, but I like it Java char <> CodeUnit|CharCode
  • 33. Type Surprises (... coming from Java) bool initial = true; int active = 5; : int ms = initial ? 0 : 1000; if (active > 10) ms += (active/10) * 200; … compiles fine ms is an int - right?
  • 34. Type Surprises (... coming from Java) bool initial = true; int active = 5; : int ms = initial ? 0 : 1000; if (active > 10) ms += (active/10) * 200; … compiles fine ms is an int - right? Runtime: ● double Fix: ms += (active~/10) * 200; … compiler (analyzer) should catch that
  • 35. Type Surprises - Lists int add(List<int> ints) {..} int x = add([1,”a”, 3]); List<O1> o1List = …; List<O2> o2List = …; for (O1 in o2List) {..} … compiles fine Runtime Error … compiler (analyser) should catch that
  • 36. Libraries - Pub Core Libraries ● async ● collection ● html + js ● io (server) ● svg, web_gl, ... http://pub.dartlang.org ● angular ● googleapis ● dquery (jQuery) ● web_components polymer use js (libs) directly ● intl well designed … but often not immutable
  • 37. Web Components Polymer ● Design your own HTML tags ● Two-way binding Dart - DOM ● Shadow DOM AngularDart 1.0new ● Re-implementation ⇒ AngularJs 2.0 ● MVC Framework o Controller - Directives - Components we don’t write HTML - we generate the DOM
  • 38. Upgrades ● Expect a new Version every 1-2 months o independent from library upgrade cycle o Started Dart 1.0 - Nov 2013  1.6.0 - Aug 2014  1.7 .. looming ● Upgrade is quite painless o Also Library: pub upgrade
  • 39. Dart Wishlist ● CSS (Less/Saas) integration o Minify css names (like GWT) ● Load Modules on demand o Split generated js (like GWT) ● BigDecimal ⇉ Dec64 ● Ability to return tuples o … like Scala ● Full Immutable library option
  • 40. Dart Productivity: Good! ● Easy to get going o Java ⇒ Functional ● Good Tools o not on Java level ● Rich Libraries ● Performance o Benchmarks ● Mostly Unsurprising semantics o No Strong Typing (like Scala) ● Doc a bit light o helps if you know Javascript/HTML
  • 41. Dart Performance (native, js, dart2js) https://www.dartlang.org/performance/
  • 42. When “back” to Java Programming ● where are named parameters? ● why is async so hard? ● very happy to get back to Dart: The better Javascript ! Douglas Crockford: Dart: too much baggage … waiting for the messiah
  • 43. Questions ? Jorg Janke [email protected] Slides link: