Top Banner
Dart 编程语言简介 @yinhm TechParty February 25, 2012 @yinhm Dart 1/27
50

Dart intro

Dec 25, 2014

Download

Technology

yinhm .

Dart语言简介
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Dart intro

Dart编程语言简介@yinhm

TechParty

February 25, 2012

@yinhm Dart 1/27

Page 2: Dart intro

Dart: Structured WebProgramming

@yinhm Dart 2/27

Page 3: Dart intro

Dart之新

• 新的编程语言

• 新的开发工具• 新的库• 开源

• 2011年 10月公开预览版• Dart规范:0.07草案

@yinhm Dart 3/27

Page 4: Dart intro

Dart之新

• 新的编程语言• 新的开发工具

• 新的库• 开源

• 2011年 10月公开预览版• Dart规范:0.07草案

@yinhm Dart 3/27

Page 5: Dart intro

Dart之新

• 新的编程语言• 新的开发工具• 新的库

• 开源• 2011年 10月公开预览版• Dart规范:0.07草案

@yinhm Dart 3/27

Page 6: Dart intro

Dart之新

• 新的编程语言• 新的开发工具• 新的库• 开源

• 2011年 10月公开预览版• Dart规范:0.07草案

@yinhm Dart 3/27

Page 7: Dart intro

Dart 开发团队和社区生态

• Lars Bak:V8引擎作者

• Gilad Bracha:第二、三版 JAVA规范作者之一• 80+ Google工程师,部分来自 GWT团队• 少量社区成员• 讨论组:1055成员,非常活跃

@yinhm Dart 4/27

Page 8: Dart intro

Dart 开发团队和社区生态

• Lars Bak:V8引擎作者• Gilad Bracha:第二、三版 JAVA规范作者之一

• 80+ Google工程师,部分来自 GWT团队• 少量社区成员• 讨论组:1055成员,非常活跃

@yinhm Dart 4/27

Page 9: Dart intro

Dart 开发团队和社区生态

• Lars Bak:V8引擎作者• Gilad Bracha:第二、三版 JAVA规范作者之一• 80+ Google工程师,部分来自 GWT团队

• 少量社区成员• 讨论组:1055成员,非常活跃

@yinhm Dart 4/27

Page 10: Dart intro

Dart 开发团队和社区生态

• Lars Bak:V8引擎作者• Gilad Bracha:第二、三版 JAVA规范作者之一• 80+ Google工程师,部分来自 GWT团队• 少量社区成员

• 讨论组:1055成员,非常活跃

@yinhm Dart 4/27

Page 11: Dart intro

Dart 开发团队和社区生态

• Lars Bak:V8引擎作者• Gilad Bracha:第二、三版 JAVA规范作者之一• 80+ Google工程师,部分来自 GWT团队• 少量社区成员• 讨论组:1055成员,非常活跃

@yinhm Dart 4/27

Page 12: Dart intro

Web开发现状之弊端

@yinhm Dart 5/27

Page 13: Dart intro

Dart目标:结构化且灵活的Web编程语言

@yinhm Dart 6/27

Page 14: Dart intro

Dart目标:易学,对程序员来说是熟悉且自然的

@yinhm Dart 7/27

Page 15: Dart intro

Dart目标:高性能、快启动

@yinhm Dart 8/27

Page 16: Dart intro

Dart目标:适合Web上的各类设备

@yinhm Dart 9/27

Page 17: Dart intro

Dart目标:各种主流浏览器支持

@yinhm Dart 10/27

Page 18: Dart intro

Dart 编程语言

@yinhm Dart 11/27

Page 19: Dart intro

Dart 编程语言

简单无惊讶的面向对象编程语言

• Class、Interface

• 可选静态类型• Isolates• Single-threaded• first class functions

@yinhm Dart 12/27

Page 20: Dart intro

Dart 编程语言

简单无惊讶的面向对象编程语言

• Class、Interface• 可选静态类型

• Isolates• Single-threaded• first class functions

@yinhm Dart 12/27

Page 21: Dart intro

Dart 编程语言

简单无惊讶的面向对象编程语言

• Class、Interface• 可选静态类型• Isolates

• Single-threaded• first class functions

@yinhm Dart 12/27

Page 22: Dart intro

Dart 编程语言

简单无惊讶的面向对象编程语言

• Class、Interface• 可选静态类型• Isolates• Single-threaded• first class functions

@yinhm Dart 12/27

Page 23: Dart intro

传承

• 面向对象受 Smalltalk 启发

• JIT 受 Self 启发• 可选类型受 Strongtalk 启发• Isolates 设计受 Erlang 影响• 语法接近 JavaScript C

@yinhm Dart 13/27

Page 24: Dart intro

传承

• 面向对象受 Smalltalk 启发• JIT 受 Self 启发

• 可选类型受 Strongtalk 启发• Isolates 设计受 Erlang 影响• 语法接近 JavaScript C

@yinhm Dart 13/27

Page 25: Dart intro

传承

• 面向对象受 Smalltalk 启发• JIT 受 Self 启发• 可选类型受 Strongtalk 启发

• Isolates 设计受 Erlang 影响• 语法接近 JavaScript C

@yinhm Dart 13/27

Page 26: Dart intro

传承

• 面向对象受 Smalltalk 启发• JIT 受 Self 启发• 可选类型受 Strongtalk 启发• Isolates 设计受 Erlang 影响

• 语法接近 JavaScript C

@yinhm Dart 13/27

Page 27: Dart intro

传承

• 面向对象受 Smalltalk 启发• JIT 受 Self 启发• 可选类型受 Strongtalk 启发• Isolates 设计受 Erlang 影响• 语法接近 JavaScript C

@yinhm Dart 13/27

Page 28: Dart intro

可选类型

• 动态类型,类似 JavaScript

• 静态类型• 不导致程序编译或运行失败(除非开发时设置为 checked模式)

• 提高易读性• 机器友好:IDE补全,效验• 更早检测到错误

@yinhm Dart 14/27

Page 29: Dart intro

可选类型

• 动态类型,类似 JavaScript• 静态类型

• 不导致程序编译或运行失败(除非开发时设置为 checked模式)

• 提高易读性• 机器友好:IDE补全,效验• 更早检测到错误

@yinhm Dart 14/27

Page 30: Dart intro

可选类型

• 动态类型,类似 JavaScript• 静态类型

• 不导致程序编译或运行失败(除非开发时设置为 checked模式)

• 提高易读性• 机器友好:IDE补全,效验• 更早检测到错误

@yinhm Dart 14/27

Page 31: Dart intro

来点代码

@yinhm Dart 15/27

Page 32: Dart intro

Classes and interfacesi n t e r f a c e Shape {

num pe r ime t e r ( ) ;}

c l a s s Rec tang l e implements Shape {f i n a l num he igh t , width ;Rec tang l e (num t h i s . he i gh t , num t h i s . w idth ) ;

// Compact c o n s t r u c t o r s yn tax .num pe r ime t e r ( ) => 2* he i g h t + 2*width ;

// Shor t f u n c t i o n s yn tax .}

c l a s s Square ex t end s Rec tang l e {Square (num s i z e ) : s upe r ( s i z e , s i z e ) ;

}

@yinhm Dart 16/27

Page 33: Dart intro

Optional types

c l a s s Po in t {va r x , y ;Po in t ( t h i s . x , t h i s . y ) ;s c a l e ( f a c t o r ) => new Po in t ( x* f a c t o r , y* f a c t o r ) ;d i s t a n c e ( ) => Math . s q r t ( x*x + y*y ) ;

}

main ( ) {va r a = new Po in t ( 2 , 3 ) . s c a l e ( 1 0 ) ;p r i n t ( a . d i s t a n c e ( ) ) ;

}

@yinhm Dart 17/27

Page 34: Dart intro

Static types

c l a s s Po in t {num x , y ;Po in t (num t h i s . x , num t h i s . y ) ;Po in t s c a l e (num f a c t o r ) => new Po in t ( x* f a c t o r , y* f a c t o r ) ;num d i s t a n c e ( ) => Math . s q r t ( x*x + y*y ) ;

}

vo i d main ( ) {Po in t a = new Po in t ( 2 , 3 ) . s c a l e ( 1 0 ) ;p r i n t ( a . d i s t a n c e ( ) ) ;

}

@yinhm Dart 18/27

Page 35: Dart intro

如何使用?

@yinhm Dart 19/27

Page 36: Dart intro

推荐:编译成 JavaScript方式

sdk/bin/frogc test.dart

@yinhm Dart 20/27

Page 37: Dart intro

Dashboard

http://try.dartlang.org/

@yinhm Dart 21/27

Page 38: Dart intro

Dart VM

sdk/bin/dart test.dart

@yinhm Dart 22/27

Page 39: Dart intro

浏览器运行,可回退至 JSMIME type: application/dart

http://www.dartlang.org/dartium/index.html

@yinhm Dart 23/27

Page 40: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue

• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 41: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap

• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 42: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String

• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 43: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String

• Pattern: String, RegExp• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 44: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 45: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...

• dom, html• io, json

@yinhm Dart 24/27

Page 46: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html

• io, json

@yinhm Dart 24/27

Page 47: Dart intro

自带库

• Dart Core 常见数据结构接口• Iterable, Collection:, List, Set, Queue• Map: HashMap, LinkedHashMap• Comparable: Date, Duration, String• Hashable: num, String• Pattern: String, RegExp

• core实现:Array, Collections, EventLoop...• dom, html• io, json

@yinhm Dart 24/27

Page 48: Dart intro

Questions?

@yinhm Dart 25/27

Page 49: Dart intro

Links

• Dart官网: http://www.dartlang.org/• Intro to Dart• Dart: a new programming language for structured web• A Walk on the Dart Side• Dart Technical Overview

@yinhm Dart 26/27

Page 50: Dart intro

About

Created in LATEX using the beamer class, TeX Live and Emacs.

Published under the Creative Commons Attribution 3.0 Licensehttp://creativecommons.org/licenses/by/3.0/

by @yinhmhttp://yinhm.appspot.com

Document version February 25, 2012

@yinhm Dart 27/27