in November 2013 by Google, and the Dart and Chrome teams wanted to help developers all over the world try Dart. • The Dart team also wants to hear feedback from developers who never used Dart. • Dart Flight Schools are community run events being organized by local Google Developer Groups or other developer meetups all over the world. https://www.dartlang.org/events/2014/ 6light-‐school/ 3
create or manipulate global variables window.x = 0; var x =0 ; // x declared outside a function var x = y = 0; // y becomes global variable http://en.wikipedia.org/wiki/ Principle_of_least_astonishment 8
spaghetti style programming • Object-‐oriented programming is hard • Lacks solid programming structures (Sets, Maps, Classes) • No consistent means of developing large applications • Too much wrapper code for programs, frameworks & plugins • Unpredictable runtime performance • Weak Tool support
"If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature." http://en.wikipedia.org/wiki/ Principle_of_least_astonishment 14
17 • Syntax and constructs inspired by JavaScript, Java & C# • Object model inspired by Smalltalk • Compilation strategy inspired by Self • Optional types inspired by Strongtalk • Isolates design inspired by Erlang
open source, easy to learn and unsurprising OO language • Compact and straight forward semantics • Real lexical scoping • Supports types, without requiring them (optional) • Simple object model (class-‐based single inheritance with interface support)
to JavaScript • Runs in the client and on the server • Has a wide array of built-‐in libraries. Supports code sharing. • Single-‐threaded but supports simple concurrency with isolates • Predictable performance
user’s expectations) – Speed and better user experience. – Speed will continue to drive innovation for web applications and a more structured language is easier to optimize. • Better productivity (developer’s expectations) – Programmer productivity is key as web applications get larger. – Support for libraries and packages helps developer work with each other and easily reuse code from other projects. – Types make APIs clearer and easier to use. – Tools help refactor, navigate, and debug code.
you can place in a variable is an object. • Every object is an instance of a class. • All objects inherit from the Object class. • Even numbers, functions, and null are objects.
references. • Uninitialized variables have an initial value of null. • Even variables with numeric types are initially null, because numbers are objects.
types is optional. • Variables with no specicied type get a special type: dynamic. • The Dart language has special support for the following types-‐ – numbers • int • double – strings – booleans – lists (also known as arrays) – maps – symbols
decimal, it is a double. • 64-‐bit (double-‐precision) cloating-‐point numbers (IEEE 754). • Subtype of num. https://www.dartlang.org/docs/dart-‐up-‐ and-‐running/contents/ch02.html 40
of an expression inside a string by using ${expression}. • If the expression is an identicier, you can skip the {}. • To get the string corresponding to an object, Dart calls the object’s toString() method. https://www.dartlang.org/docs/dart-‐up-‐ and-‐running/contents/ch02.html 45
type bool: the boolean literals, true and false. • When Dart expects a boolean value, only the value true is treated as true. All other values are treated as false. • Unlike in JavaScript, values such as 1, "aString", and someObject are all treated as false. https://www.dartlang.org/docs/dart-‐up-‐ and-‐running/contents/ch02.html 46
supports top-‐level functions (such as main()), • As well as functions tied to a class or object (static and instance methods, respectively). • Functions within functions can also be created (nested or local functions). • Similarly, Dart supports top-‐level variables, • As well as variables tied to a class or object (static and instance variables).
Use 'extends' keyword to extend another class • Use 'implements' keyword to implement an interface • Every class is also an interface (implicit interface) • So you can implement a class • Use ‘abstract’ keyword to make non-‐instantiable • You can override methods but no overloading is allowed
expression API • Collections (List, Set, Map etc.) • URI • Dates and Times • Utility classes for comparing objects etc. • Iterable/Iterator https://www.dartlang.org/docs/dart-‐up-‐ and-‐running/contents/ch03.html 80
Finding DOM Elements • Creating/Manipulating DOM Elements • Adding/Replacing/Removing nodes • Manipulating CSS styles • Handling Events • HttpRequest (dynamically load JSON data or any other resource from a web server) • Websockets https://www.dartlang.org/docs/dart-‐up-‐ and-‐running/contents/ch03.html 82
programming language. • If any code blocks the thread of execution (for example, by waiting for a time-‐consuming operation or blocking on I/O) the program effectively freezes. Asynchronous operations let your program run without getting blocked. • Dart uses a Future object to perform asynchronous operations. https://www.dartlang.org/docs/tutorials/ futures/ 89
chat applicaHon. • On a single client, you will be receiving messages and displaying them to the user. • You can’t simply write a while loop because that will block execuHon, so you need to use async callbacks. • This is an ideal use case for streams: • you have one part of your code pushing data into the stream, • and another part of your code listening to the stream. • Streams are unified across Dart’s asynchronous APIs, providing a powerful way to deal with streams of data, whether that data is event objects, bytes, or your own custom classes. https://www.dartlang.org/docs/tutorials/ streams/ 90
part, and library directives help you create a modular and shareable code base. • Libraries not only provide APIs, but are a unit of privacy: – identiciers that start with an underscore (_) are visible only inside the library. • Every Dart app is a library, even if it doesn’t use a library directive. • Libraries can be distributed using packages.
fall into the following categories: • App creation and maintenance – The pub get command retrieves the packages that are listed as the dependencies for the app. – The pub upgrade command retrieves the latest versions of all those packages. • Development – The pub serve command is used to start up a development server. • Deployment – The pub build command creates the build directory, compiles the Dart code, and places the assets into the build directory. • Publication – The pub publish command to upload your package to pub.dartlang.org, so, other can view it. – The pub uploader command enables specicic users to modify and upload new versions of your package.
• Production mode – – Default runtime mode of a Dart program, optimized for speed. – Ignores assert statements and static types. • Checked mode – – Developer-‐friendly mode that helps you catch some type errors during runtime. – For example, if you assign a non-‐number to a variable declared as a num, then checked mode throws an exception. – Checked mode is helpful at development.
and high performance JS • Tree shaking • Minicication • Type Inferencing • Not just a syntax translator. Produces better optimized JS code than hand-‐written JS. • Dart Editor uses dart2js behind the scenes whenever Dart Editor compiles to JavaScript. • The pub tool's serve and build options also use dart2js.
• CSS and JavaScript collisions are a source of constant concern for library and widget developers. • Encapsulation would allow developers to write their code and know that it will work properly, even in the presence of other scripts and style sheets. • The goal of the shadow DOM is to provide functional encapsulation for these sub-‐trees. • This is achieved by keeping functional sub-‐trees separate from the document tree (and each other). • CSS rules and DOM queries do not cross the shadow boundary, and thus provide encapsulation.
is built on the latest web technologies, like Web Components and Object.observe. • Not all browsers support these features yet, so Polymer’s platform layer cills the gaps, implementing the APIs in JavaScript/Dart. • At runtime, Polymer automatically picks the fastest path – native implementation or JavaScript. hAp://www.polymer-‐project.org/ 109