SlideShare una empresa de Scribd logo
1 de 44
Descargar para leer sin conexión
Dart
The better Javascript
Jorg Janke
jorg@accorto.com
Slides link:
http://lightningdart.com
October 2015
Structure
● What & Why Dart?
● Dart Language & Tooling
● Questions
○ no need to wait until the end
Where are You coming from?
● Java
○ GWT
○ Servlet, JSP, JSF, ..
● .Net
● PHP, Python,
Ruby, …
● Mobile Native
Front-end
Technology
● Javascript
○ CoffeeScript
○ Typescript
○ Dart
✋
Who is Jorg Janke?
● Education: MBA
(Accounting), IT
● Jobs
○ ADV/Orga
○ Unisys - Prod.Mgr
○ Oracle - Dir Apps
○ Accorto since 1999
● Experience
○ Mainframe, Unix, Linux
○ Algol, PL/I, SmallTalk
○ Oracle DBA
○ Java since 1.1
○ Dart since 1.0
● Founder: Compiere
○ Open Source ERP
What does Accorto do?
● Professional Services Automation (PSA)
on Salesforce https://www.accorto.com
○ Projects
■ Gantt
■ Resource Planning
○ Capturing Time & Expense
○ Billing
Dart Overview
ECMA-408
What is Dart?
● OO & Functional Programming Language
○ Debugged in Dartium (Chrome)
○ Generating Javascript Executable dart2js
● Created/Maintained by Google
● ECMA-408 Standard
○ http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf
● Targeting Client + Server
Dart Motivation
● Fast development cycles
● Fast & predictable performance
● Clear language semantics
● String types for great tool support
Change: from Dartium (own runtime engine)
➤ Javascript only
Lot’s of good Dart Overviews
Check
● https://www.dartlang.org
● Books ...
● https://www.dartlang.org/slides
I concentrate here on Developer experience
UI Options
Angular 2.0 - Now
https://github.com/ng2-dart-samples
● smaller gen JS
● 3x faster than 1.0
Dart Polymer
● Web Components
Bring Your Own
JS Framework
● JS Interop
Lightning Dart
● Lightning Experience UX
Dart Mobile - also native
● Share code
○ IOS
○ Android
○ Web
● Fletch (Runtime)
○ adds ~220k native App
○ on-the-fly code changes - also on iOS
UI for iOS
(Objective-C)
UI for Android
(Java)
Application Model
(Dart)
Runtime (Fletch)
Early Days!
Dart - Google Trends
Why pick Dart?
Accorto UI Requirements/Features
● Mobile First
○ disconnected
● 24/7
○ active for days
● User
○ Expert/Guidance
○ Own Layout
■ switch
○ Analytics built in
● Admin
○ Add/Change Tables/
Fields/Processes/
Validations/...
● General
○ Dynamic Model Driven
Architecture
○ Multi-Tenant/Locale
○ AWS/GAE/OnPremise
What we wanted to avoid
● Multiple UIs - browser + naive(s)
● Hard to Develop
○ Good IDE - Step through Debugging
● Hard to Maintain (different code styles, …) .. in 5y
○ Developer Learning curve -- “Sonar”
● Hard to Understand
○ Partners/Customers to extend
● Fighting libraries - dependencies - conflicts
Alternatives evaluated
● GWT (Used)
○ Easy Java Integration
○ Stable “mature”
○ Very good build process
○ A bit heavy
○ Lost in Translation (Java
Structure <> JS features
class <> prototypal)
● JSP/JSF/…
○ Connected only
● Coffeescript
○ Step in the right direction
● Typescript
○ step in the right direction
● Javascript “pure”
○ improved IDE support &
tooling - JSLint
○ hard to build sizeable apps
○ too many different styles
○ no static analysis
Dart selection reasons
● Good DOM (Polyfill)
API
● “Close to the metal”
○ eventually JS
○ Web Components, ...
● Streams, Futures
● Libraries
● Static Type support
No worry about
Javascript:
The Bad Parts
new - this - null - falsiness -
for (in) - class ...
Douglas Crockford
prototypal vs class
Static Typing increases Productivity
● Static typing and
Documentation
○ Dynamic Languages
require Context
switches
● Source: Dr. A. Stefik, +
An empirical study on the impact of static
typing on software maintainability
http://web.cs.unlv.edu/stefika/Papers.php
Accorto Architecture now
● Java Backend
○ SOAP/REST
■ Salesforce
● Lightning Design
○ scss
● Dart
○ Grid/Form/..
○ Gantt Graph (svg)
● Protocol Buffers
○ binary (smaller than
JSON, especially
data rows)
○ fast (~ same
de/serializing speed)
○ Data Transfer
Objects (get/set..)
○ for many languages
Lightning Design System
● Salesforce UX
https://www.lightningdesignsystem.com
○ SCSS - Font - Icons
○ General Purpose
■ Not restricted to
salesforce.com
● Lightning Dart
○ Functionality
● Components
○ Button … Picklist
● Controller
○ Form, Object
➤ Optimized Javascript
○ optimal low-level
language features
○ speed
➤ Typed code
● Maintainability
○ Well structured code
○ Not Optimization
● Productivity
○ Easy Debugging
Dart ⟹ Productivity & Efficiency
Dart Source dart2js js
Analyzer
Observatory
(profiler)
fmt, doc
Dart Environment
Dart Language
core, collection,
async, io, isolate, math,
mirrors, typed_data
DOM API
html, svg, indexed_db,
web_gl/audio/sql
Polymer
Angular Dart
Logging
Intl
Route
Packages
Protocol Buff
IDE:
- IntelliJ
DartPad
Plugins:
- Sublime
- Eclipse
- ...
Version Control
+ Dependencies
Test
Pub
Build / Libs / Distribution
...
Dart IDE options
WebStorm IDE
● Plugin
Other Editors
● Sublime, Eclipse,
Atom, Emacs, Vim
DartPad
https://dartpad.dartlang.org
● Interactive Editor
& Playground
Predefined Structure (Pub)
● bin
● doc
● example
● lib
○ lib.dart
● test
● tool
● web
○ project.dart
○ project.html
● pubspec.yaml
● packages
○ in main directory
○ links: sub directories
■ /web /tool /test
/bin /example
■ (not /lib)
○ allows “package/..”
references anywhere
copied into
packages
Testing made easy
@TestOn(“browser && !chrome”)
group(“my group”, () {
test(“my test”, () {
expect(11.remainder(3), equals(2));
});
test(“my async”, () async {
var value = await new Future.value(10);
expect(value, allOf([ ..matcher.. ])));
});
});
● pub run test
○ chrome, safari, ie, ff
○ content-shell (headless)
○ android,
○ mac-os, windows, ..
○ phantomjs
● pub global activate test_runner
○ run_tests
● dart webdriver
Java Converts:
You are ultimately writing Javascript !!!
Language Features
● Cannot cover all
○ for complete details see dartlang.org
● I like the most
○ single inheritance .. with mixins
■ intro to prototypal + functional programming
● with a safety net
○ named parameters
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
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) {}
○ saves the: this.p1 = p1;
● MyClass.fromXml(String xml) {..}
○ No overloading - better documentation
○ alternative
■ static MyClass parse(String xml) {..}
No overloading - but not missing it!
workaround if you want to:
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();
} enableControls(); }
Great! Function variables
● Example
○ static int parse(String s, { int onError(String s)});
● Use
○ int xx=int.parse(“12”);
○ int xx=int.parse(“12”, onError: (String s) {return -1;});
○ 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)
int active = 5;
:
int ms = initial;
if (active > 10)
ms += (active/10) * 200;
… compiles fine
ms is an int - right?
Runtime:
● double
Fix:
ms += (active~/10) * 200;
… Analyzer catches direct
assignments but not +=
Type Surprises - Lists
void add(List<int> ints) {..}
add([1,”a”, 3]);
List<O1> o1List = …;
List<O2> o2List = …;
for (O1 in o2List) {..}
… compiles fine
Runtime Error
… compiler (analyser)
should catch that
… certainly better than
plain Javascript
Libraries - Pub
Core Libraries
● async
● collection
● html + js
● io (server)
● svg, web_gl, ...
http://pub.dartlang.org
● angular
● googleapis
● dquery (jQuery)
● web_components
polymer
● intlwell designed
… but often not immutable
use js (libs) directly
Upgrades
● Expect a new Version every 1-2 months
○ independent from library upgrade cycle
○ Started Dart 1.0 - Nov 2013
■ 1.12.0 - Aug 2015
■ 1.13 .. looming
● Upgrade is quite painless
○ Also Library: pub upgrade
Dart Wishlist
● BigDecimal ⇉ Dec64 (vs double)
● Ability to return tuples
○ … like Scala
● Full Immutable library option
● CSS (Less/Saas) integration
○ Package + Minify css (like GWT)
Concentrate on Client!
Dart Productivity: Good!
● Easy to get going
○ Java ⇒ Functional
● Good Tools
○ not on Java level
● Rich Libraries
● Profiling
○ Observatory
● Mostly Unsurprising
semantics
○ No Strong Typing
(like Scala)
● Doc a bit light
○ helps if you know
Javascript/HTML
Summary (why not Javascript directly)
● Productivity
○ typed language
○ concise
■ especially async
○ tooling
○ libraries
○ debug & test
● Maintainability
○ dart2js optimizes
● Dev Compiler
○ create JS libraries
(alpha)
● Maintainable and
efficient Javascript
○ Very hard to manually
do - collaboratively
■ JS the good parts
When “back” to Java Programming
● where are named parameters?
● why is async so hard?
● very happy to get back to
● Dart:
The better Javascript !
Questions ?
Jorg Janke jorg@accorto.com
Slides link: http://lightningdart.com

Más contenido relacionado

La actualidad más candente

F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical Platform
Howard Mansell
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
Kumar
 

La actualidad más candente (20)

Dart presentation
Dart presentationDart presentation
Dart presentation
 
Dart programming tutorial
Dart programming tutorialDart programming tutorial
Dart programming tutorial
 
Dart
DartDart
Dart
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
 
From DOT to Dotty
From DOT to DottyFrom DOT to Dotty
From DOT to Dotty
 
F# Type Provider for R Statistical Platform
F# Type Provider for R Statistical PlatformF# Type Provider for R Statistical Platform
F# Type Provider for R Statistical Platform
 
C sharp
C sharpC sharp
C sharp
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Python for katana
Python for katanaPython for katana
Python for katana
 
Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416Avro - More Than Just a Serialization Framework - CHUG - 20120416
Avro - More Than Just a Serialization Framework - CHUG - 20120416
 
Maths&programming forartists wip
Maths&programming forartists wipMaths&programming forartists wip
Maths&programming forartists wip
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
 
Mel for beginners
Mel for beginnersMel for beginners
Mel for beginners
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Common Programming Paradigms
Common Programming ParadigmsCommon Programming Paradigms
Common Programming Paradigms
 
C# in depth
C# in depthC# in depth
C# in depth
 
C++ programming
C++ programmingC++ programming
C++ programming
 

Destacado

Artificial Intelligence and Expert Systems
Artificial Intelligence and Expert SystemsArtificial Intelligence and Expert Systems
Artificial Intelligence and Expert Systems
Siddhant Agarwal
 
Real Estate Investment Guide - Waveland, Mississippi
Real Estate Investment Guide - Waveland, MississippiReal Estate Investment Guide - Waveland, Mississippi
Real Estate Investment Guide - Waveland, Mississippi
Marco Santarelli
 

Destacado (20)

Semantic web
Semantic webSemantic web
Semantic web
 
Understanding RDF: the Resource Description Framework in Context (1999)
Understanding RDF: the Resource Description Framework in Context  (1999)Understanding RDF: the Resource Description Framework in Context  (1999)
Understanding RDF: the Resource Description Framework in Context (1999)
 
Resource description framework
Resource description frameworkResource description framework
Resource description framework
 
A First Course in RDF and RDFS (Resource Description Framework and Resource D...
A First Course in RDF and RDFS (Resource Description Framework and Resource D...A First Course in RDF and RDFS (Resource Description Framework and Resource D...
A First Course in RDF and RDFS (Resource Description Framework and Resource D...
 
Artificial Intelligence and Expert Systems
Artificial Intelligence and Expert SystemsArtificial Intelligence and Expert Systems
Artificial Intelligence and Expert Systems
 
NexJ CDM Overview: Better Understand Customers with NexJ Customer Data Manage...
NexJ CDM Overview: Better Understand Customers with NexJ Customer Data Manage...NexJ CDM Overview: Better Understand Customers with NexJ Customer Data Manage...
NexJ CDM Overview: Better Understand Customers with NexJ Customer Data Manage...
 
Play Framework (anatomy of a play application) @ Codacy
Play Framework (anatomy of a play application) @ CodacyPlay Framework (anatomy of a play application) @ Codacy
Play Framework (anatomy of a play application) @ Codacy
 
How to Hire a PR Firm
How to Hire a PR FirmHow to Hire a PR Firm
How to Hire a PR Firm
 
Introducing ProspectStream
Introducing ProspectStreamIntroducing ProspectStream
Introducing ProspectStream
 
Infocom webinar race car metaphore
Infocom webinar   race car metaphoreInfocom webinar   race car metaphore
Infocom webinar race car metaphore
 
How to Call A from B in Ember
How to Call A from B in EmberHow to Call A from B in Ember
How to Call A from B in Ember
 
Impel elemech-company
Impel elemech-companyImpel elemech-company
Impel elemech-company
 
Web 2.0 and the world of global collaboration v2010
Web 2.0 and the world of global collaboration v2010Web 2.0 and the world of global collaboration v2010
Web 2.0 and the world of global collaboration v2010
 
8 Reason You Need Mobile CRM
8 Reason You Need Mobile CRM8 Reason You Need Mobile CRM
8 Reason You Need Mobile CRM
 
Stop Branding Pollution: Managing brand complexity & ensuring consistency
Stop Branding Pollution: Managing brand complexity & ensuring consistencyStop Branding Pollution: Managing brand complexity & ensuring consistency
Stop Branding Pollution: Managing brand complexity & ensuring consistency
 
知识到底是什麽?
知识到底是什麽? 知识到底是什麽?
知识到底是什麽?
 
Step Up Business Intelligence
Step Up Business Intelligence Step Up Business Intelligence
Step Up Business Intelligence
 
What Lies Ahead
What Lies AheadWhat Lies Ahead
What Lies Ahead
 
Alacra On Demand
Alacra On DemandAlacra On Demand
Alacra On Demand
 
Real Estate Investment Guide - Waveland, Mississippi
Real Estate Investment Guide - Waveland, MississippiReal Estate Investment Guide - Waveland, Mississippi
Real Estate Investment Guide - Waveland, Mississippi
 

Similar a Dart the better Javascript 2015

Similar a Dart the better Javascript 2015 (20)

Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Scaling xtext
Scaling xtextScaling xtext
Scaling xtext
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Python for PHP developers
Python for PHP developersPython for PHP developers
Python for PHP developers
 
Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!Ruxmon.2013-08.-.CodeBro!
Ruxmon.2013-08.-.CodeBro!
 
BUD17-302: LLVM Internals #2
BUD17-302: LLVM Internals #2 BUD17-302: LLVM Internals #2
BUD17-302: LLVM Internals #2
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 
Quality Assurance in PostgreSQL
Quality Assurance in PostgreSQLQuality Assurance in PostgreSQL
Quality Assurance in PostgreSQL
 
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and KibanaBuilding a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
Building a Unified Logging Layer with Fluentd, Elasticsearch and Kibana
 
HelsinkiJS - Clojurescript for Javascript Developers
HelsinkiJS - Clojurescript for Javascript DevelopersHelsinkiJS - Clojurescript for Javascript Developers
HelsinkiJS - Clojurescript for Javascript Developers
 
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
Introduction to InfluxDB, an Open Source Distributed Time Series Database by ...
 
AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8AOT-compilation of JavaScript with V8
AOT-compilation of JavaScript with V8
 
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
 
[scala.by] Launching new application fast
[scala.by] Launching new application fast[scala.by] Launching new application fast
[scala.by] Launching new application fast
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
 
Custom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDBCustom Pregel Algorithms in ArangoDB
Custom Pregel Algorithms in ArangoDB
 
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json  postgre-sql vs. mongodbPGConf APAC 2018 - High performance json  postgre-sql vs. mongodb
PGConf APAC 2018 - High performance json postgre-sql vs. mongodb
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
2016-01-16 03 Денис Нелюбин. How to test a million
2016-01-16 03 Денис Нелюбин. How to test a million2016-01-16 03 Денис Нелюбин. How to test a million
2016-01-16 03 Денис Нелюбин. How to test a million
 

Último

Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 

Dart the better Javascript 2015

  • 1. Dart The better Javascript Jorg Janke jorg@accorto.com Slides link: http://lightningdart.com October 2015
  • 2. Structure ● What & Why Dart? ● Dart Language & Tooling ● Questions ○ no need to wait until the end
  • 3. Where are You coming from? ● Java ○ GWT ○ Servlet, JSP, JSF, .. ● .Net ● PHP, Python, Ruby, … ● Mobile Native Front-end Technology ● Javascript ○ CoffeeScript ○ Typescript ○ Dart ✋
  • 4. Who is Jorg Janke? ● Education: MBA (Accounting), IT ● Jobs ○ ADV/Orga ○ Unisys - Prod.Mgr ○ Oracle - Dir Apps ○ Accorto since 1999 ● Experience ○ Mainframe, Unix, Linux ○ Algol, PL/I, SmallTalk ○ Oracle DBA ○ Java since 1.1 ○ Dart since 1.0 ● Founder: Compiere ○ Open Source ERP
  • 5. What does Accorto do? ● Professional Services Automation (PSA) on Salesforce https://www.accorto.com ○ Projects ■ Gantt ■ Resource Planning ○ Capturing Time & Expense ○ Billing
  • 7. What is Dart? ● OO & Functional Programming Language ○ Debugged in Dartium (Chrome) ○ Generating Javascript Executable dart2js ● Created/Maintained by Google ● ECMA-408 Standard ○ http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf ● Targeting Client + Server
  • 8. Dart Motivation ● Fast development cycles ● Fast & predictable performance ● Clear language semantics ● String types for great tool support Change: from Dartium (own runtime engine) ➤ Javascript only
  • 9. Lot’s of good Dart Overviews Check ● https://www.dartlang.org ● Books ... ● https://www.dartlang.org/slides I concentrate here on Developer experience
  • 10. UI Options Angular 2.0 - Now https://github.com/ng2-dart-samples ● smaller gen JS ● 3x faster than 1.0 Dart Polymer ● Web Components Bring Your Own JS Framework ● JS Interop Lightning Dart ● Lightning Experience UX
  • 11. Dart Mobile - also native ● Share code ○ IOS ○ Android ○ Web ● Fletch (Runtime) ○ adds ~220k native App ○ on-the-fly code changes - also on iOS UI for iOS (Objective-C) UI for Android (Java) Application Model (Dart) Runtime (Fletch) Early Days!
  • 12. Dart - Google Trends
  • 14. Accorto UI Requirements/Features ● Mobile First ○ disconnected ● 24/7 ○ active for days ● User ○ Expert/Guidance ○ Own Layout ■ switch ○ Analytics built in ● Admin ○ Add/Change Tables/ Fields/Processes/ Validations/... ● General ○ Dynamic Model Driven Architecture ○ Multi-Tenant/Locale ○ AWS/GAE/OnPremise
  • 15. What we wanted to avoid ● Multiple UIs - browser + naive(s) ● Hard to Develop ○ Good IDE - Step through Debugging ● Hard to Maintain (different code styles, …) .. in 5y ○ Developer Learning curve -- “Sonar” ● Hard to Understand ○ Partners/Customers to extend ● Fighting libraries - dependencies - conflicts
  • 16. Alternatives evaluated ● GWT (Used) ○ Easy Java Integration ○ Stable “mature” ○ Very good build process ○ A bit heavy ○ Lost in Translation (Java Structure <> JS features class <> prototypal) ● JSP/JSF/… ○ Connected only ● Coffeescript ○ Step in the right direction ● Typescript ○ step in the right direction ● Javascript “pure” ○ improved IDE support & tooling - JSLint ○ hard to build sizeable apps ○ too many different styles ○ no static analysis
  • 17. Dart selection reasons ● Good DOM (Polyfill) API ● “Close to the metal” ○ eventually JS ○ Web Components, ... ● Streams, Futures ● Libraries ● Static Type support No worry about Javascript: The Bad Parts new - this - null - falsiness - for (in) - class ... Douglas Crockford prototypal vs class
  • 18. Static Typing increases Productivity ● Static typing and Documentation ○ Dynamic Languages require Context switches ● Source: Dr. A. Stefik, + An empirical study on the impact of static typing on software maintainability http://web.cs.unlv.edu/stefika/Papers.php
  • 19. Accorto Architecture now ● Java Backend ○ SOAP/REST ■ Salesforce ● Lightning Design ○ scss ● Dart ○ Grid/Form/.. ○ Gantt Graph (svg) ● Protocol Buffers ○ binary (smaller than JSON, especially data rows) ○ fast (~ same de/serializing speed) ○ Data Transfer Objects (get/set..) ○ for many languages
  • 20. Lightning Design System ● Salesforce UX https://www.lightningdesignsystem.com ○ SCSS - Font - Icons ○ General Purpose ■ Not restricted to salesforce.com ● Lightning Dart ○ Functionality ● Components ○ Button … Picklist ● Controller ○ Form, Object
  • 21. ➤ Optimized Javascript ○ optimal low-level language features ○ speed ➤ Typed code ● Maintainability ○ Well structured code ○ Not Optimization ● Productivity ○ Easy Debugging Dart ⟹ Productivity & Efficiency Dart Source dart2js js Analyzer Observatory (profiler) fmt, doc
  • 22. Dart Environment Dart Language core, collection, async, io, isolate, math, mirrors, typed_data DOM API html, svg, indexed_db, web_gl/audio/sql Polymer Angular Dart Logging Intl Route Packages Protocol Buff IDE: - IntelliJ DartPad Plugins: - Sublime - Eclipse - ... Version Control + Dependencies Test Pub Build / Libs / Distribution ...
  • 23. Dart IDE options WebStorm IDE ● Plugin Other Editors ● Sublime, Eclipse, Atom, Emacs, Vim DartPad https://dartpad.dartlang.org ● Interactive Editor & Playground
  • 24. Predefined Structure (Pub) ● bin ● doc ● example ● lib ○ lib.dart ● test ● tool ● web ○ project.dart ○ project.html ● pubspec.yaml ● packages ○ in main directory ○ links: sub directories ■ /web /tool /test /bin /example ■ (not /lib) ○ allows “package/..” references anywhere copied into packages
  • 25. Testing made easy @TestOn(“browser && !chrome”) group(“my group”, () { test(“my test”, () { expect(11.remainder(3), equals(2)); }); test(“my async”, () async { var value = await new Future.value(10); expect(value, allOf([ ..matcher.. ]))); }); }); ● pub run test ○ chrome, safari, ie, ff ○ content-shell (headless) ○ android, ○ mac-os, windows, .. ○ phantomjs ● pub global activate test_runner ○ run_tests ● dart webdriver
  • 26. Java Converts: You are ultimately writing Javascript !!!
  • 27. Language Features ● Cannot cover all ○ for complete details see dartlang.org ● I like the most ○ single inheritance .. with mixins ■ intro to prototypal + functional programming ● with a safety net ○ named parameters
  • 28. 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
  • 29. 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);
  • 30. Named Constructors ● MyClass(String this.p1, int this.i1) {} ○ saves the: this.p1 = p1; ● MyClass.fromXml(String xml) {..} ○ No overloading - better documentation ○ alternative ■ static MyClass parse(String xml) {..}
  • 31. No overloading - but not missing it! workaround if you want to: 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) {..}
  • 32. 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(); } enableControls(); }
  • 33. Great! Function variables ● Example ○ static int parse(String s, { int onError(String s)}); ● Use ○ int xx=int.parse(“12”); ○ int xx=int.parse(“12”, onError: (String s) {return -1;}); ○ 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”
  • 34. 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
  • 35. 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
  • 36. Type Surprises (... coming from Java) int active = 5; : int ms = initial; if (active > 10) ms += (active/10) * 200; … compiles fine ms is an int - right? Runtime: ● double Fix: ms += (active~/10) * 200; … Analyzer catches direct assignments but not +=
  • 37. Type Surprises - Lists void add(List<int> ints) {..} add([1,”a”, 3]); List<O1> o1List = …; List<O2> o2List = …; for (O1 in o2List) {..} … compiles fine Runtime Error … compiler (analyser) should catch that … certainly better than plain Javascript
  • 38. Libraries - Pub Core Libraries ● async ● collection ● html + js ● io (server) ● svg, web_gl, ... http://pub.dartlang.org ● angular ● googleapis ● dquery (jQuery) ● web_components polymer ● intlwell designed … but often not immutable use js (libs) directly
  • 39. Upgrades ● Expect a new Version every 1-2 months ○ independent from library upgrade cycle ○ Started Dart 1.0 - Nov 2013 ■ 1.12.0 - Aug 2015 ■ 1.13 .. looming ● Upgrade is quite painless ○ Also Library: pub upgrade
  • 40. Dart Wishlist ● BigDecimal ⇉ Dec64 (vs double) ● Ability to return tuples ○ … like Scala ● Full Immutable library option ● CSS (Less/Saas) integration ○ Package + Minify css (like GWT) Concentrate on Client!
  • 41. Dart Productivity: Good! ● Easy to get going ○ Java ⇒ Functional ● Good Tools ○ not on Java level ● Rich Libraries ● Profiling ○ Observatory ● Mostly Unsurprising semantics ○ No Strong Typing (like Scala) ● Doc a bit light ○ helps if you know Javascript/HTML
  • 42. Summary (why not Javascript directly) ● Productivity ○ typed language ○ concise ■ especially async ○ tooling ○ libraries ○ debug & test ● Maintainability ○ dart2js optimizes ● Dev Compiler ○ create JS libraries (alpha) ● Maintainable and efficient Javascript ○ Very hard to manually do - collaboratively ■ JS the good parts
  • 43. When “back” to Java Programming ● where are named parameters? ● why is async so hard? ● very happy to get back to ● Dart: The better Javascript !
  • 44. Questions ? Jorg Janke jorg@accorto.com Slides link: http://lightningdart.com