SlideShare a Scribd company logo
No JS + Intro to
   DartCon

 Dart       @Author
            Anand Shankar
            @Presented
What is Dart

Dart is a new open source web programming
language developed by Google. It was unveiled at
the GOTO conference, October-2011.
Dart helps developers to build structured
modern web apps.
Goal of Dart
The goal of Dart is ultimately to replace
JavaScript as the lingua franca of web development
on the open web platform.
Dart is a class-based, object-oriented language
with lexical scoping, closures, and optional static
typing.
Why Did Google Create Dart?
Engineers at Google have been thinking about web
apps for a long time. We’ve written
a bunch of complex and widely used large-scale
web apps (think Gmail, Google+, and Google Docs),
so we’re quite familiar with the challenges of
architecting web apps.
Why Did Google Create Dart?
We’ve also written a browser (Chrome) and a
JavaScript engine (V8), so we’ve thought
a lot about how to make web apps run faster.

Basically, we created Dart because we think it’ll
help bring more great apps to the web,
and we think it should be easier to create more
complex web applications.
Advantages of Dart over
              JavaScript
Good point is that it has native support.
A very critical issue with JavaScript is handling
concurrency. Dart has "isolates": these are used for
handling concurrency.
Coding difference between
   JavaScript and Dart
Code embedding
          JavaScript                          Dart
<script                          • <script
   src=‘myscript.js'></script>      type='application/dart'
                                    src='myscript.dart'></script
                                    >
                                 • To load JS for non-dartium
                                 <script
                                    src=“packages/browser/dar
                                    t.js” ></script>
Entry point

         JavaScript                      Dart
• Not required              • REQUIRED
                              – main() { }
Code modularity

         JavaScript                        Dart
• No native implementation   • Defining library
                                – library bcb;
                                  class BCB13 { hello() => ‘Hello
                                  BCB 113’; }
                             • Using library
                                – import(‘bcb.BCB13');
                                  var msg = new BCB13();
Function

           JavaScript                             Dart
• function fun(a, b, c) { return   • fun(a, b, c) => c;
  c; };                               – fn(1);
   – fun(1)                           Result=ERROR:NoSuchMethodE
  Result= undefined                     xception
                                      – fn(1, 2, 3);
   – fun(1, 2, 3)
                                      Result= 3
  Result= 3
                                   • Optional parameters
                                      – fn(a, [b, c]) => c;
                                      – fn('a');
                                      Result= null
For Each Loop
         JavaScript                    Dart
• Not available          • data.forEach((key, value)
                           { print('${key}, ${value}'); });
Classes
         JavaScript                          Dart
• function BCB(){               • class BCB {
this.name=null;                 var name;
};                              greet() => 'Hello, $name';
                                }
BCB.prototype.greet=function(
   ){
return ‘Hello, ‘ + this.name;
}
Constructors
          JavaScript                      Dart
• function BCB(x) {          • class BCB {
this.x = x;                  var x;
};                           BCB(x) {
                              this.x = x;
                             }}
                             • In short
                             class BCB {
                             var x;
                             BCB(this.x); }
Inheritance
• JavaScript
• function Person(name) {
this.name = name;
}
• Person.prototype.greet = function() {
 return 'Hello, ' + this.name;
}
function Employee(name, salary) {
 Person.call(this, name);
this.salary = salary; }
• Employee.prototype = new Person();
  Employee.prototype.constructor = Employee;

 Employee.prototype.grantRaise =
   function(percent) {
this.salary = (this.salary * percent).toInt();
 }
• Dart
• class Person {
var name;
Person(this.name);
greet() => 'Hello, $name';
 }
class Employee extends Person {
 var salary;
Employee(name, this.salary) : super(name);
grantRaise(percent)
{
 salary = (salary * percent).toInt();
}
 }
Advance for loop
         JavaScript                     Dart
• Not available           • For( var x in list)
                           {
                           print(x);
                          }
Manipulating DOM

         JavaScript                       Dart
• var element =               • var element = new
  document.createElement('p     Element.html('<p>Hello BCB
  ');                           <em>12</em>.</p>');
• element.innerHTML =
  ‘Hello BCB <em>12</em>.';
Exceptions Handling

           JavaScript                            Dart
• try { undefinedFunction();       • try
 } catch(e) {                         { Math.parseInt("three"); }
if (e instanceof                      catch(BadNumberFormatEx
    ReferenceError)                   ception bnfe) {
    { console.log('You called a     print("Ouch! Detected:
    function that does not            $bnfe");
    exist'); } }                   }catch(var e) {
finally { console.log('This runs   print("If some other type of
    even if an exception is           exception"); }
    thrown'); }                    finally { print("This runs even if
                                      an exception is thrown"); }
Ajax
• JavaScript
var client = new XMLHttpRequest;
 client.onreadystatechange = function() {
if (this.readyState == 4) {
processData(this);
}}
client.open('GET', 'data.json');
 client.send();

function processData(request) {
console.log('The contents of your data: ' +
  request.responseText);
}
• Dart
HttpRequest.request("/data.json“).then(req)
  { print("The contents of your data: $
  {req.responseText}"); });
DartCon

DartCon is a Dart to JavaScript and JavaScript to
Dart converter.

     Find the DartCon and it’s Source Code
     https://github.com/ashankar/dartcon
Demo
http://www.altermediguide.com
http://www.openestartup.com
http://www.ekisaan.com
http://kevmoo.github.com/qr.dart/
Demo
http://threedart.github.com/three.dart/example
/canvas_geometry_hierarchy/Canvas_Geometry_H
ierarchy.html
http://threedart.github.com/three.dart/example
/webgl_geometries/WebGL_Geometries.html
http://jimmypettersson.eu/dev/dart/spaceinvad
ers/SpaceInvaders.html
http://dart-lang.github.com/pop-pop-win/
http://www.dartflash.com/games/escape/escap
e.html
References
http://www.dartlang.org
What is Dart?, Oreilly Publications
Questions ?
Thanks
      Anand Shankar
E-mail: com@ashankar.com
    Twitter: anandvns
   Facebook: anandvns

More Related Content

PDF
Dart
PPTX
Building High Perf Web Apps - IE8 Firestarter
PPTX
Dart London hackathon
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
PDF
Java Script Best Practices
PDF
Powerful JavaScript Tips and Best Practices
PDF
Ten useful JavaScript tips & best practices
PDF
Backbone.js: Run your Application Inside The Browser
Dart
Building High Perf Web Apps - IE8 Firestarter
Dart London hackathon
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Java Script Best Practices
Powerful JavaScript Tips and Best Practices
Ten useful JavaScript tips & best practices
Backbone.js: Run your Application Inside The Browser

What's hot (20)

PDF
Singletons in PHP - Why they are bad and how you can eliminate them from your...
PDF
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
PDF
JavaScript Basics and Best Practices - CC FE & UX
PDF
Headless Js Testing
PDF
Bottom Up
PDF
Kotlin @ Coupang Backend 2017
PDF
Object Oriented Programming in JavaScript
PDF
Scala 2013 review
PDF
Declarative Internal DSLs in Lua: A Game Changing Experience
PDF
[2019-07] GraphQL in depth (serverside)
PDF
(Greach 2015) Dsl'ing your Groovy
PDF
Node Boot Camp
PDF
Metaprogramovanie #1
PDF
JavaScript OOPs
PDF
Design Patterns Reconsidered
PDF
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
PPT
JavaScript Basics
PDF
TDC 2012 - Patterns e Anti-Patterns em Ruby
PDF
Unleash your inner console cowboy
PDF
A Few of My Favorite (Python) Things
Singletons in PHP - Why they are bad and how you can eliminate them from your...
Model-Driven Software Development - Pretty-Printing, Editor Services, Term Re...
JavaScript Basics and Best Practices - CC FE & UX
Headless Js Testing
Bottom Up
Kotlin @ Coupang Backend 2017
Object Oriented Programming in JavaScript
Scala 2013 review
Declarative Internal DSLs in Lua: A Game Changing Experience
[2019-07] GraphQL in depth (serverside)
(Greach 2015) Dsl'ing your Groovy
Node Boot Camp
Metaprogramovanie #1
JavaScript OOPs
Design Patterns Reconsidered
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
JavaScript Basics
TDC 2012 - Patterns e Anti-Patterns em Ruby
Unleash your inner console cowboy
A Few of My Favorite (Python) Things
Ad

Similar to No JS and DartCon (20)

PPTX
Dart, unicorns and rainbows
PPTX
Dart structured web apps
PPTX
Dartprogramming
PDF
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
PPTX
Dart programming language
PDF
Introduction to Dart
PDF
Structured web programming
PPTX
Dart Programming.pptx
PDF
Discover Dart - Meetup 15/02/2017
PDF
Discover Dart(lang) - Meetup 07/12/2016
PPTX
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
PPT
Building Single-Page Web Appplications in dart - Devoxx France 2013
PPTX
Chapter 2 Flutter Basics Lecture 1.pptx
PDF
Introduction to Flutter - truly crossplatform, amazingly fast
PDF
Dart workshop
PPTX
Dart the Better JavaScript
PDF
Structured Apps with Google Dart
PPTX
Dart ppt
PDF
Dart - en ny platform til webudvikling af Rico Wind, Google
Dart, unicorns and rainbows
Dart structured web apps
Dartprogramming
OWF12/PAUG Conf Days Dart a new html5 technology, nicolas geoffray, softwar...
Dart programming language
Introduction to Dart
Structured web programming
Dart Programming.pptx
Discover Dart - Meetup 15/02/2017
Discover Dart(lang) - Meetup 07/12/2016
Bringing your app to the web with Dart - Chris Buckett (Entity Group)
Building Single-Page Web Appplications in dart - Devoxx France 2013
Chapter 2 Flutter Basics Lecture 1.pptx
Introduction to Flutter - truly crossplatform, amazingly fast
Dart workshop
Dart the Better JavaScript
Structured Apps with Google Dart
Dart ppt
Dart - en ny platform til webudvikling af Rico Wind, Google
Ad

No JS and DartCon

Editor's Notes

  • #5: What is Dart?, Oreilly Publications
  • #6: What is Dart?, Oreilly Publications