Scala overview

  • 551 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
551
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
2
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. scala['skeilə]
    东白
  • 2. scala?
    OOP
    FP
    DSL
  • 3. OOP?
    数据的抽象化(data abstraction)
    继承(inheritance)
    多态(ploymorphism)
    模块化(module)
    复用(reuse)
    类型(type)
  • 4. 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…
  • 5. DSL?
    definition: Domain-Specific Languages/领域特定语言
    internal DSL
    便于用库来提供语言特性
    easy debug
    etc…
    external DSL
    easy design and write[withparser]
    newsyntax
    etc…
  • 6. not simple?

  • 7. 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
    一切操作都是函数
    一切操作都返回值
    }=>
  • 8.
  • 9. trait
  • 10. companion objects
  • 11. 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]的子类
  • 12. implicit and type bounds
  • 13. function
  • 14. functional data structures
  • 15. pattern match & case class
  • 16. concurrent
    1.thread
    2.java.util.concurrent
    3.event/NIO
    4.Actor ==>
    <==
  • 17. DSL
  • 18. herding xml in scala
  • 19. ETC…
  • 20. THANKS