SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Dart 编程语言简介
        @yinhm

        TechParty


   February 25, 2012




     @yinhm   Dart   1/27
Dart: Structured Web
    Programming




       @yinhm   Dart   2/27
Dart 之新


• 新的编程语言




           @yinhm   Dart   3/27
Dart 之新


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




           @yinhm   Dart   3/27
Dart 之新


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




           @yinhm   Dart   3/27
Dart 之新


• 新的编程语言
• 新的开发工具
• 新的库
• 开源
   • 2011 年 10 月公开预览版
   • Dart 规范:0.07 草案




                 @yinhm   Dart   3/27
Dart 开发团队和社区生态


• Lars Bak:V8 引擎作者




                @yinhm   Dart   4/27
Dart 开发团队和社区生态


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




                @yinhm   Dart   4/27
Dart 开发团队和社区生态


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




                @yinhm   Dart   4/27
Dart 开发团队和社区生态


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




                @yinhm   Dart   4/27
Dart 开发团队和社区生态


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




                @yinhm   Dart   4/27
Web 开发现状之弊端




   @yinhm   Dart   5/27
Dart 目标:结构化且灵活的 Web
        编程语言




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




      @yinhm   Dart   7/27
Dart 目标:高性能、快启动




     @yinhm   Dart   8/27
Dart 目标:适合 Web 上的各类设
          备




        @yinhm   Dart   9/27
Dart 目标:各种主流浏览器支持




      @yinhm   Dart   10/27
Dart 编程语言




  @yinhm   Dart   11/27
Dart 编程语言


  简单无惊讶的面向对象编程语言
• Class、Interface




                    @yinhm   Dart   12/27
Dart 编程语言


  简单无惊讶的面向对象编程语言
• Class、Interface
• 可选静态类型




                    @yinhm   Dart   12/27
Dart 编程语言


  简单无惊讶的面向对象编程语言
• Class、Interface
• 可选静态类型
• Isolates




                    @yinhm   Dart   12/27
Dart 编程语言


  简单无惊讶的面向对象编程语言
• Class、Interface
• 可选静态类型
• Isolates
• Single-threaded
• first class functions




                         @yinhm   Dart   12/27
传承


• 面向对象受 Smalltalk 启发




                @yinhm   Dart   13/27
传承


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




                  @yinhm   Dart   13/27
传承


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




                  @yinhm   Dart   13/27
传承


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




                   @yinhm   Dart   13/27
传承


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




                   @yinhm   Dart   13/27
可选类型


• 动态类型,类似 JavaScript




                @yinhm   Dart   14/27
可选类型


• 动态类型,类似 JavaScript
• 静态类型
   • 不导致程序编译或运行失败(除非开发时设置为 checked 模
     式)
   • 提高易读性
   • 机器友好:IDE 补全,效验
   • 更早检测到错误




              @yinhm   Dart   14/27
可选类型


• 动态类型,类似 JavaScript
• 静态类型
   • 不导致程序编译或运行失败(除非开发时设置为 checked 模
     式)
   • 提高易读性
   • 机器友好:IDE 补全,效验
   • 更早检测到错误




              @yinhm   Dart   14/27
来点代码




@yinhm   Dart   15/27
Classes and interfaces
i n t e r f a c e Shape {
   num p e r i m e t e r ( ) ;
}

c l a s s R e c t a n g l e i m p l e m e n t s Shape {
    f i n a l num h e i g h t , w i d t h ;
    R e c t a n g l e (num t h i s . h e i g h t , num t h i s . w i d t h ) ;
// Compact c o n s t r u c t o r s y n t a x .
    num p e r i m e t e r ( ) => 2* h e i g h t + 2* w i d t h ;
// S h o r t f u n c t i o n s y n t a x .
}

c l a s s Square extends Rectangle {
    S q u a r e (num s i z e ) : s u p e r ( s i z e , s i z e ) ;
}

                                 @yinhm    Dart   16/27
Optional types

c l a s s Point {
    var x , y ;
    Point ( t h i s . x , t h i s . y ) ;
    s c a l e ( f a c t o r ) => new P o i n 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 ( ) {
  v a r a = new P o i n t ( 2 , 3 ) . s c a l e ( 1 0 ) ;
  print (a . distance ());
}




                                 @yinhm    Dart   17/27
Static types

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

v o i d main ( ) {
    P o i n t a = new P o i n t ( 2 , 3 ) . s c a l e ( 1 0 ) ;
    print (a . distance ());
}




                                @yinhm    Dart   18/27
如何使用?




 @yinhm   Dart   19/27
推荐:编译成 JavaScript 方式

      sdk/bin/frogc test.dart




           @yinhm   Dart   20/27
Dashboard

http://try.dartlang.org/




      @yinhm   Dart   21/27
Dart VM

sdk/bin/dart test.dart




    @yinhm   Dart   22/27
浏览器运行,可回退至 JS
MIME type: application/dart

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




                @yinhm   Dart   23/27
自带库

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




                         @yinhm   Dart   24/27
自带库

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




                         @yinhm   Dart   24/27
自带库

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




                         @yinhm   Dart   24/27
自带库

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




                         @yinhm   Dart   24/27
自带库

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




                         @yinhm   Dart   24/27
自带库

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

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




                         @yinhm   Dart   24/27
自带库

• 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




                         @yinhm   Dart   24/27
自带库

• 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
Questions?




  @yinhm   Dart   25/27
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
About


        Created in L TEX using the beamer class, TeX Live and Emacs.
                   A



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

                                by @yinhm
                        http://yinhm.appspot.com


                    Document version February 25, 2012




                           @yinhm        Dart    27/27

Mais conteúdo relacionado

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Dart intro