SlideShare uma empresa Scribd logo
1 de 43
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:

Mais conteúdo relacionado

Mais procurados

introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
Kumar
 

Mais procurados (20)

Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Dart programming tutorial
Dart programming tutorialDart programming tutorial
Dart programming tutorial
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart language
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 
TypeScript introduction to scalable javascript application
TypeScript introduction to scalable javascript applicationTypeScript introduction to scalable javascript application
TypeScript introduction to scalable javascript application
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
Advanced PHP Simplified
Advanced PHP SimplifiedAdvanced PHP Simplified
Advanced PHP Simplified
 
Getting Started with TypeScript
Getting Started with TypeScriptGetting Started with TypeScript
Getting Started with TypeScript
 
Typescript: enjoying large scale browser development
Typescript: enjoying large scale browser developmentTypescript: enjoying large scale browser development
Typescript: enjoying large scale browser development
 
Introduction about type script
Introduction about type scriptIntroduction about type script
Introduction about type script
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
Code generating beans in Java
Code generating beans in JavaCode generating beans in Java
Code generating beans in Java
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 
Java script
Java scriptJava script
Java script
 

Semelhante a Dart the Better JavaScript

Big data beyond the JVM - DDTX 2018
Big data beyond the JVM -  DDTX 2018Big data beyond the JVM -  DDTX 2018
Big data beyond the JVM - DDTX 2018
Holden Karau
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
Eelco Visser
 
Big Data Beyond the JVM - Strata San Jose 2018
Big Data Beyond the JVM - Strata San Jose 2018Big Data Beyond the JVM - Strata San Jose 2018
Big Data Beyond the JVM - Strata San Jose 2018
Holden Karau
 

Semelhante a Dart the Better JavaScript (20)

Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
Big data beyond the JVM - DDTX 2018
Big data beyond the JVM -  DDTX 2018Big data beyond the JVM -  DDTX 2018
Big data beyond the JVM - DDTX 2018
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
Node.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first stepsNode.js Course 1 of 2 - Introduction and first steps
Node.js Course 1 of 2 - Introduction and first steps
 
Evolution of Spark APIs
Evolution of Spark APIsEvolution of Spark APIs
Evolution of Spark APIs
 
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018Beyond Wordcount  with spark datasets (and scalaing) - Nide PDX Jan 2018
Beyond Wordcount with spark datasets (and scalaing) - Nide PDX Jan 2018
 
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan KrausHTML, CSS & Javascript Architecture (extended version) - Jan Kraus
HTML, CSS & Javascript Architecture (extended version) - Jan Kraus
 
Introduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at lastIntroduction to Spark Datasets - Functional and relational together at last
Introduction to Spark Datasets - Functional and relational together at last
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)Road to sbt 1.0: Paved with server (2015 Amsterdam)
Road to sbt 1.0: Paved with server (2015 Amsterdam)
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Big Data Beyond the JVM - Strata San Jose 2018
Big Data Beyond the JVM - Strata San Jose 2018Big Data Beyond the JVM - Strata San Jose 2018
Big Data Beyond the JVM - Strata San Jose 2018
 
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
Lint, coverage, doc, autocompletion, transpilation, minification... powered b...
 
Introduction to Spark ML Pipelines Workshop
Introduction to Spark ML Pipelines WorkshopIntroduction to Spark ML Pipelines Workshop
Introduction to Spark ML Pipelines Workshop
 
Scala.js
Scala.js Scala.js
Scala.js
 
A fast introduction to PySpark with a quick look at Arrow based UDFs
A fast introduction to PySpark with a quick look at Arrow based UDFsA fast introduction to PySpark with a quick look at Arrow based UDFs
A fast introduction to PySpark with a quick look at Arrow based UDFs
 

Último

Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Monica Sydney
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
ydyuyu
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
ydyuyu
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
ayvbos
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Monica Sydney
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Monica Sydney
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
F
 

Último (20)

Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi EscortsRussian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
Russian Escort Abu Dhabi 0503464457 Abu DHabi Escorts
 
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
Tadepalligudem Escorts Service Girl ^ 9332606886, WhatsApp Anytime Tadepallig...
 
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
哪里办理美国迈阿密大学毕业证(本硕)umiami在读证明存档可查
 
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac RoomVip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
Vip Firozabad Phone 8250092165 Escorts Service At 6k To 30k Along With Ac Room
 
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrStory Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
Story Board.pptxrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
原版制作美国爱荷华大学毕业证(iowa毕业证书)学位证网上存档可查
 
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime NagercoilNagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
Nagercoil Escorts Service Girl ^ 9332606886, WhatsApp Anytime Nagercoil
 
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime BalliaBallia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
Ballia Escorts Service Girl ^ 9332606886, WhatsApp Anytime Ballia
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...Local Call Girls in Seoni  9332606886 HOT & SEXY Models beautiful and charmin...
Local Call Girls in Seoni 9332606886 HOT & SEXY Models beautiful and charmin...
 
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
一比一原版(Flinders毕业证书)弗林德斯大学毕业证原件一模一样
 
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi EscortsIndian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
Indian Escort in Abu DHabi 0508644382 Abu Dhabi Escorts
 
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Dindigul [ 7014168258 ] Call Me For Genuine Models ...
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu DhabiAbu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
Abu Dhabi Escorts Service 0508644382 Escorts in Abu Dhabi
 
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
20240510 QFM016 Irresponsible AI Reading List April 2024.pdf
 
一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理一比一原版田纳西大学毕业证如何办理
一比一原版田纳西大学毕业证如何办理
 

Dart the Better JavaScript

  • 1. Dart The better Javascript ? Jorg Janke jorg@accorto.com 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 jorg@accorto.com Slides link: