SlideShare a Scribd company logo
1 of 17
Download to read offline
Structured web programming

  Created by Lars Bak & Gilad Bracha


        Come to the Dart side.
                  Gilad Bracha in an interview on Dart
What is DART?

 ● New programming language
 ● Open Source Project
 ● Simple OO programming language
 ● Class-based single inheritance with interfaces
 ● Optional static types
 ● Real lexical scoping
 ● Single-threaded
 ● Familiar Syntax
 ● It's still a Technology Preview
Hello World!
Dart is NOT the competition of
           JavaScript

● Dart is meant to fill a vacuum, not to replace
  JavaScript, but rather to fill the vacuum left by
  fragmented mobile platforms.

● It seems they are targeting the problem of
  programming in Java-like for android, Objective-C
  for iOS and so forth.

● It's not done.
Type-Checker
● Dart has a different type-checker.

● The conventional type-checker tries to prove a program
  obeys the type system.

● If it can't construct a proof - the program is considered
  invalid, "Guilty until proven innocent"

● In Dart, you are innocent until proven guilty.

● During development one can choose to validate types.
Optional Types
 ● Static checker provides warnings; tuned to be unobtrusive

 ● Type annotations have no effect except ...

 ● During development, you can check dynamic types against
   declarations
    ○ T x = o;        assert(o === null || o is T);

 ● By default, type annotations have no effect and no cost
    ○ Code runs free
Example
Classes
 ● Single class inheritance (Object is the default)
 ● Interfaces
 ● Constructor assign
   Greeter.withPrefix(this.prefix); //A constructor
   var greeter = new Greeter.withPrefix('Howdy');
 ● Setters and Getters
   class Greeter {
     String _prefix = 'Hello,'; // Hidden instance variable.
     String get prefix() => _prefix; // Getter for prefix.
     void set prefix(String value) {...} // Setter for prefix.
   }
   greeter.prefix = 'Howdy,'; // Set prefix.


Example
ISOLATES

 ● Inspired by Erlang, Dart has isolates
 ● Lightweight units of execution
     ○ Each isolate is conceptually a process
     ○ Nothing is shared
     ○ All communication takes place via message passing

 ● Isolates support concurrent execution
 ● Which gives us Actor based concurrency

Isolates
DART EXECUTION
SNAPSHOTTING IN THE DART VM

● Process of serializing the heap after loading the application

● Loading 54173 lines of Dart code takes 640 ms

● Loading same application from a snapshot takes 60 ms

● Startup > 10x faster
How to use Dart?

One can run Dart code in several ways:
● Translate Dart code to JavaScript that can run in any
  modern browser:
   ○ Chrome
   ○ Safari 5+
   ○ Firefox 4+

● Execute Dart code directly in a VM on the server side
●
● Use Dartboard to write, modify, and execute small Dart
  programs within any browser window
Embedding Dart in HTML

● Using the HTML script tag with type='application/dart'.

● Like other script tags, the script contents can be inlined as the
  body of the script tag or specified by reference via a URL using the
  script tag’s src attribute.

● The Dart script can have optional #source and #import directives.
  It must have a visible top-level function called main(), either
  declared directly in the script or in a sourced/imported file. The
  browser will invoke main() when the page is loaded.
Fundamental differences from JavaScript


● Isolated script tags
    ○ Each script tag runs in isolation.
    ○ Use #import to use code from other URL
    ○ Each script tag requires a main() to be run.
● Delayed Execution
    ○ Each script's main() is called on DOMContentLoaded
      event
    ○ Ordering is not guaranteed
    ○ Dart code executes after page load.
    ○ We can assume the DOM is fully loaded.
● No inline event listeners
Improving the DOM
● Better Querying
                 Old                                New
 elem.getElementById('foo');           elem.query('#foo');

 elem.getElementsByTagName('div');     elem.queryAll('div');

 elem.getElementsByName('foo');        elem.queryAll('[name="foo"]');

 elem.getElementsByClassName('foo');   elem.queryAll('.foo');

 elem.querySelector('.foo .bar');      elem.query('.foo .bar');

 elem.querySelectorAll('.foo .bar');   elem.queryAll('.foo .bar');
Improving the DOM
● Use real collections
   ○ The queries return collections which are objects that implement the
     Dart core library's built-in collection interfaces.
   ○ This way we get rid of a lot of special methods & made attributes a
     map
                    Old                                   New
   elem.hasAttribute('name');            elem.attributes.contains('name');

   elem.getAttribute('name');            elem.attributes['name'];

   elem.setAttribute('name', 'value');   elem.attributes['name'] = 'value';

   elem.removeAttribute('name');         elem.attributes.remove('name');

   elem.hasChildNodes();                 elem.nodes.isEmpty();

   elem.firstChild();                    elem.nodes[0];

   elem.appendChild(child);              elem.nodes.add(child);
Improving the DOM
● Use constructors
   Old
        document.createElement('div')
   New
        new Element.tag('div')

   Or
        TableElement table = new Element.html(
          '<table><tr><td>Hello <em>Dart!</em></table>');
Improving the DOM
● Events
    ○ There are no inline events like 'onclick()'
    ○ New ElementEvents class. For each of the known event types, there is
      a property on that class: click, mouseDown, etc
    ○ There are event objects that can add and remove listeners and
      dispatch events.

                  Old                                        New
elem.addEventListener('click', (event) =>   elem.on.click.add( (event) => print
print('click!'), false);                    ('click!'));
elem.removeEventListener( 'click', elem.on.click.remove(listener);
listener);
A technology preview on




  dartlang.org
  dart.googlecode.com
  http://gototoday.dk/2011/10/10/lars-bak-on-dart/
  http://www.2ality.com/2011/10/dart-launch.html
  http://dartinside.com/
  @DartInside

More Related Content

What's hot

What's hot (20)

Dart
DartDart
Dart
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
Let's Play Dart
Let's Play DartLet's Play Dart
Let's Play Dart
 
Dart, Darrt, Darrrt
Dart, Darrt, DarrrtDart, Darrt, Darrrt
Dart, Darrt, Darrrt
 
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...OWF12/PAUG Conf Days Dart   a new html5 technology, nicolas geoffray, softwar...
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
 
Google Dart
Google DartGoogle Dart
Google Dart
 
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
 
Typescript
TypescriptTypescript
Typescript
 
Introduction to the Dart language
Introduction to the Dart languageIntroduction to the Dart language
Introduction to the Dart language
 
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
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
Generics
GenericsGenerics
Generics
 
8 introduction to_java_script
8 introduction to_java_script8 introduction to_java_script
8 introduction to_java_script
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 
TypeScript
TypeScriptTypeScript
TypeScript
 
XKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & ConstructsXKE - Programming Paradigms & Constructs
XKE - Programming Paradigms & Constructs
 

Viewers also liked

Observatorio ambiental
Observatorio ambientalObservatorio ambiental
Observatorio ambientalsiralexander
 
4 Steps to Imaging your gel
4 Steps to Imaging your gel4 Steps to Imaging your gel
4 Steps to Imaging your gelTito Jankowski
 
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)Spiros
 
Manual sup sppbs thn 1-2011
Manual sup sppbs thn 1-2011Manual sup sppbs thn 1-2011
Manual sup sppbs thn 1-2011sabrisahir
 

Viewers also liked (6)

Observatorio ambiental
Observatorio ambientalObservatorio ambiental
Observatorio ambiental
 
Magic shop
Magic shopMagic shop
Magic shop
 
4 Steps to Imaging your gel
4 Steps to Imaging your gel4 Steps to Imaging your gel
4 Steps to Imaging your gel
 
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)elm-d3 @ NYC D3.js Meetup (30 June, 2014)
elm-d3 @ NYC D3.js Meetup (30 June, 2014)
 
What About Elm?
What About Elm?What About Elm?
What About Elm?
 
Manual sup sppbs thn 1-2011
Manual sup sppbs thn 1-2011Manual sup sppbs thn 1-2011
Manual sup sppbs thn 1-2011
 

Similar to Structured web programming

CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developementfrwebhelp
 
Sharable of qualities of clean code
Sharable of qualities of clean codeSharable of qualities of clean code
Sharable of qualities of clean codeEman Mohamed
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Domkaven yan
 
Flutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepFlutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepChandramouli Biyyala
 
What’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth LaddWhat’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth Laddjaxconf
 
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 ChecksStoyan Nikolov
 
Productivity Enhencement with Visual Studio
Productivity Enhencement with Visual StudioProductivity Enhencement with Visual Studio
Productivity Enhencement with Visual StudioAhasan Habib
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Dart, unicorns and rainbows
Dart, unicorns and rainbowsDart, unicorns and rainbows
Dart, unicorns and rainbowschrisbuckett
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1Paras Mendiratta
 
Dart structured web apps
Dart   structured web appsDart   structured web apps
Dart structured web appschrisbuckett
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsOWASP Kyiv
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
Learn Dart And Angular, Get Your Web Development Wings With Kevin Moore
Learn Dart And Angular, Get Your Web Development Wings With Kevin MooreLearn Dart And Angular, Get Your Web Development Wings With Kevin Moore
Learn Dart And Angular, Get Your Web Development Wings With Kevin MooreCodeCore
 

Similar to Structured web programming (20)

CSharp presentation and software developement
CSharp presentation and software developementCSharp presentation and software developement
CSharp presentation and software developement
 
Sharable of qualities of clean code
Sharable of qualities of clean codeSharable of qualities of clean code
Sharable of qualities of clean code
 
Dartprogramming
DartprogrammingDartprogramming
Dartprogramming
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Flutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepFlutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by Step
 
What’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth LaddWhat’s new in Google Dart - Seth Ladd
What’s new in Google Dart - Seth Ladd
 
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
 
Productivity Enhencement with Visual Studio
Productivity Enhencement with Visual StudioProductivity Enhencement with Visual Studio
Productivity Enhencement with Visual Studio
 
Oops lecture 1
Oops lecture 1Oops lecture 1
Oops lecture 1
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
jQuery
jQueryjQuery
jQuery
 
Dart, unicorns and rainbows
Dart, unicorns and rainbowsDart, unicorns and rainbows
Dart, unicorns and rainbows
 
Angular JS2 Training Session #1
Angular JS2 Training Session #1Angular JS2 Training Session #1
Angular JS2 Training Session #1
 
Dart structured web apps
Dart   structured web appsDart   structured web apps
Dart structured web apps
 
Andriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tipsAndriy Shalaenko - GO security tips
Andriy Shalaenko - GO security tips
 
Clean Code 2
Clean Code 2Clean Code 2
Clean Code 2
 
UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
Learn Dart And Angular, Get Your Web Development Wings With Kevin Moore
Learn Dart And Angular, Get Your Web Development Wings With Kevin MooreLearn Dart And Angular, Get Your Web Development Wings With Kevin Moore
Learn Dart And Angular, Get Your Web Development Wings With Kevin Moore
 

Recently uploaded

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Structured web programming

  • 1. Structured web programming Created by Lars Bak & Gilad Bracha Come to the Dart side. Gilad Bracha in an interview on Dart
  • 2. What is DART? ● New programming language ● Open Source Project ● Simple OO programming language ● Class-based single inheritance with interfaces ● Optional static types ● Real lexical scoping ● Single-threaded ● Familiar Syntax ● It's still a Technology Preview Hello World!
  • 3. Dart is NOT the competition of JavaScript ● Dart is meant to fill a vacuum, not to replace JavaScript, but rather to fill the vacuum left by fragmented mobile platforms. ● It seems they are targeting the problem of programming in Java-like for android, Objective-C for iOS and so forth. ● It's not done.
  • 4. Type-Checker ● Dart has a different type-checker. ● The conventional type-checker tries to prove a program obeys the type system. ● If it can't construct a proof - the program is considered invalid, "Guilty until proven innocent" ● In Dart, you are innocent until proven guilty. ● During development one can choose to validate types.
  • 5. Optional Types ● Static checker provides warnings; tuned to be unobtrusive ● Type annotations have no effect except ... ● During development, you can check dynamic types against declarations ○ T x = o; assert(o === null || o is T); ● By default, type annotations have no effect and no cost ○ Code runs free Example
  • 6. Classes ● Single class inheritance (Object is the default) ● Interfaces ● Constructor assign Greeter.withPrefix(this.prefix); //A constructor var greeter = new Greeter.withPrefix('Howdy'); ● Setters and Getters class Greeter { String _prefix = 'Hello,'; // Hidden instance variable. String get prefix() => _prefix; // Getter for prefix. void set prefix(String value) {...} // Setter for prefix. } greeter.prefix = 'Howdy,'; // Set prefix. Example
  • 7. ISOLATES ● Inspired by Erlang, Dart has isolates ● Lightweight units of execution ○ Each isolate is conceptually a process ○ Nothing is shared ○ All communication takes place via message passing ● Isolates support concurrent execution ● Which gives us Actor based concurrency Isolates
  • 9. SNAPSHOTTING IN THE DART VM ● Process of serializing the heap after loading the application ● Loading 54173 lines of Dart code takes 640 ms ● Loading same application from a snapshot takes 60 ms ● Startup > 10x faster
  • 10. How to use Dart? One can run Dart code in several ways: ● Translate Dart code to JavaScript that can run in any modern browser: ○ Chrome ○ Safari 5+ ○ Firefox 4+ ● Execute Dart code directly in a VM on the server side ● ● Use Dartboard to write, modify, and execute small Dart programs within any browser window
  • 11. Embedding Dart in HTML ● Using the HTML script tag with type='application/dart'. ● Like other script tags, the script contents can be inlined as the body of the script tag or specified by reference via a URL using the script tag’s src attribute. ● The Dart script can have optional #source and #import directives. It must have a visible top-level function called main(), either declared directly in the script or in a sourced/imported file. The browser will invoke main() when the page is loaded.
  • 12. Fundamental differences from JavaScript ● Isolated script tags ○ Each script tag runs in isolation. ○ Use #import to use code from other URL ○ Each script tag requires a main() to be run. ● Delayed Execution ○ Each script's main() is called on DOMContentLoaded event ○ Ordering is not guaranteed ○ Dart code executes after page load. ○ We can assume the DOM is fully loaded. ● No inline event listeners
  • 13. Improving the DOM ● Better Querying Old New elem.getElementById('foo'); elem.query('#foo'); elem.getElementsByTagName('div'); elem.queryAll('div'); elem.getElementsByName('foo'); elem.queryAll('[name="foo"]'); elem.getElementsByClassName('foo'); elem.queryAll('.foo'); elem.querySelector('.foo .bar'); elem.query('.foo .bar'); elem.querySelectorAll('.foo .bar'); elem.queryAll('.foo .bar');
  • 14. Improving the DOM ● Use real collections ○ The queries return collections which are objects that implement the Dart core library's built-in collection interfaces. ○ This way we get rid of a lot of special methods & made attributes a map Old New elem.hasAttribute('name'); elem.attributes.contains('name'); elem.getAttribute('name'); elem.attributes['name']; elem.setAttribute('name', 'value'); elem.attributes['name'] = 'value'; elem.removeAttribute('name'); elem.attributes.remove('name'); elem.hasChildNodes(); elem.nodes.isEmpty(); elem.firstChild(); elem.nodes[0]; elem.appendChild(child); elem.nodes.add(child);
  • 15. Improving the DOM ● Use constructors Old document.createElement('div') New new Element.tag('div') Or TableElement table = new Element.html( '<table><tr><td>Hello <em>Dart!</em></table>');
  • 16. Improving the DOM ● Events ○ There are no inline events like 'onclick()' ○ New ElementEvents class. For each of the known event types, there is a property on that class: click, mouseDown, etc ○ There are event objects that can add and remove listeners and dispatch events. Old New elem.addEventListener('click', (event) => elem.on.click.add( (event) => print print('click!'), false); ('click!')); elem.removeEventListener( 'click', elem.on.click.remove(listener); listener);
  • 17. A technology preview on dartlang.org dart.googlecode.com http://gototoday.dk/2011/10/10/lars-bak-on-dart/ http://www.2ality.com/2011/10/dart-launch.html http://dartinside.com/ @DartInside