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

Mais conteúdo relacionado

Mais procurados

Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
zand3rs
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
Sagie Davidovich
 
Declarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing ExperienceDeclarative Internal DSLs in Lua: A Game Changing Experience
Declarative Internal DSLs in Lua: A Game Changing Experience
Alexander Gladysh
 
Metaprogramovanie #1
Metaprogramovanie #1Metaprogramovanie #1
Metaprogramovanie #1
Jano Suchal
 

Mais procurados (20)

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

Semelhante a No JS and DartCon

JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Howard Lewis Ship
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 

Semelhante a No JS and DartCon (20)

Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
JavaScript 2016 for C# Developers
JavaScript 2016 for C# DevelopersJavaScript 2016 for C# Developers
JavaScript 2016 for C# Developers
 
Dart structured web apps
Dart   structured web appsDart   structured web apps
Dart structured web apps
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Latinoware
LatinowareLatinoware
Latinoware
 
Dart, unicorns and rainbows
Dart, unicorns and rainbowsDart, unicorns and rainbows
Dart, unicorns and rainbows
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHave Your Cake and Eat It Too: Meta-Programming Techniques for Java
Have Your Cake and Eat It Too: Meta-Programming Techniques for Java
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 
jQuery Objects
jQuery ObjectsjQuery Objects
jQuery Objects
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications Testing JavaScript with Jasmine in Rails Applications
Testing JavaScript with Jasmine in Rails Applications
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
 
Week3
Week3Week3
Week3
 
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
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 

No JS and DartCon

Notas do Editor

  1. What is Dart?, Oreilly Publications
  2. What is Dart?, Oreilly Publications