• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Scala overview
 

Scala overview

on

  • 795 views

 

Statistics

Views

Total Views
795
Views on SlideShare
795
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Scala overview Scala overview Presentation Transcript

    • scala['skeilə]
      东白
    • scala?
      OOP
      FP
      DSL
    • OOP?
      数据的抽象化(data abstraction)
      继承(inheritance)
      多态(ploymorphism)
      模块化(module)
      复用(reuse)
      类型(type)
    • FP?
      lambda calculus
      lambda x . plus x x
      (lambda x . plus x x) y
      rule:
      alpha – 变量替换
      beta – 值应用
      {lisp[ML/erlang/haskell]}
      functionisvalue[hightorderfunction];
      nosideeffect; lazy evaluation;
      pattern match; currying/partial funcitons;
      tail recursion optimization; etc…
    • DSL?
      definition: Domain-Specific Languages/领域特定语言
      internal DSL
      便于用库来提供语言特性
      easy debug
      etc…
      external DSL
      easy design and write[withparser]
      newsyntax
      etc…
    • not simple?

    • base
      1.原生类型是对象的实例
      123.toByte
      "1".toInt
      true.toString
      2.函数也是值
      val compare = (x: Int, y: Int) => x > y
      compare(1, 2) // result: Boolean = false
      3.变量
      var
      Val/lazy val
      4.字面量/literals
      vali = 1234356; //Int
      val l = 123454L; // Long
      val f = 0.123; // Float
      val c = 'a' or 'u0041'; //Chaar
      val s = "string" or """ String "ssssss'""" //String
      val symbol = 'name [scala.Symbol("programming scala") //symbol
      5.Predef.scala
      一切操作都是函数
      一切操作都返回值
      }=>
    • trait
    • companion objects
    • parameterized types
      invariant/不变: C[T], C is invariant on T
      如果Tsub或Tsup是T的子类或超类,C[Tsub]或C[Tsup]都不是C[T]类
      covariant/协变: C[+T], C is covariant on T
      如果Tsub是T的子类,则C[Tsub]也是C[T]的子类
      Contravatiant/逆变: C[‐T], C is contravariant on T
      如果Tsup是T的超类,则C[Tsup]也是C[T]的子类
    • implicit and type bounds
    • function
    • functional data structures
    • pattern match & case class
    • concurrent
      1.thread
      2.java.util.concurrent
      3.event/NIO
      4.Actor ==>
      <==
    • DSL
    • herding xml in scala
    • ETC…
    • THANKS