4. "Which Programming Language would you use *now*
on top of JVM, except Java?". The answer was
surprisingly fast and very clear: - Scala.
http://www.adam-bien.com/roller/abien/entry/java_net_javaone_which_programming
12年3月1日星期四
5. I can honestly say if someone had shown me
theProgramming in Scala book by by Martin
Odersky, Lex Spoon & Bill Venners back in 2003 I'd
probably have never created Groovy.
http://macstrac.blogspot.com/2009/04/scala-as-long-term-replacement-for.html
12年3月1日星期四
26. 简化
val i = 1.2.toInt
val list = List(1, 2, 3)
12年3月1日星期四
27. 简化
val i = 1.2.toInt
val list = List(1, 2, 3)
val map = Map("Guangzhou" -> "GZ",
"Shenzhen" -> "SZ")
12年3月1日星期四
28. 简化
val i = 1.2.toInt
val list = List(1, 2, 3)
val map = Map("Guangzhou" -> "GZ",
"Shenzhen" -> "SZ")
class MyClass(x: Int, y: Int) {}
12年3月1日星期四
29. 简化
val i = 1.2.toInt
val list = List(1, 2, 3)
val map = Map("Guangzhou" -> "GZ",
"Shenzhen" -> "SZ")
class MyClass(x: Int, y: Int) {}
list.exists(_ == 2) //true
12年3月1日星期四
30. 简化
val i = 1.2.toInt
val list = List(1, 2, 3)
val map = Map("Guangzhou" -> "GZ",
"Shenzhen" -> "SZ")
class MyClass(x: Int, y: Int) {}
list.exists(_ == 2) //true
val (a, b, _) = (x, y, z)
12年3月1日星期四
41. Trait
class Animal {}
trait CanFly {
def fly {
println("fly")
}
}
class Bird extends Animal
with CanFly {}
12年3月1日星期四
42. Trait
class Animal {}
trait CanFly {
def fly {
Mixin,类似多集成
println("fly")
接口和实现⼀一起出现 }
是什么和拥有什么功能
}
class Bird extends Animal
with CanFly {}
12年3月1日星期四
43. Trait
class Fish {}
trait CanFly {
def fly {
println("fly")
}
}
val flyFish = new Fish with CanFly
12年3月1日星期四
44. Actors
val myActor = actor {
loop {
react {
case "Send" => {
println("Get")
}
}
}
}
myActor ! "Send"
12年3月1日星期四
45. 模式匹配
def matchTest(x: Any) = x match {
case 1 => "number one"
case y: Int if y > 0 => y + 1
case head :: tail => tail
case Send(a, _) => a
case ("Send", _, b: String) => b
case _ => x
}
12年3月1日星期四
62. It took about 15 hours to recreate the publishing
daemon in Clojure and get it to pass all our tests.
Today we ran a "soak test" publishing nearly
300,000 profiles in one run. The Scala code would
fail with OoM exceptions if we hit it with 50,000
profiles in one run (sometimes less).
http://groups.google.com/group/clojure/browse_thread/thread/b18f9006c068f0a0
12年3月1日星期四
63. The e-mail confirms that Yammer is moving its basic
infrastructure stack from Scala back to Java, owing
to issues with complexity and performance.
http://www.infoq.com/news/2011/11/yammer-scala
12年3月1日星期四