Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SCALA ⽣生态圈 
彭洪伟 
! 
@make_dream 
! 
hwpeng@thoughtworks.com
SCALA 知多少 
2 
▫︎A. 仅仅听过该名词,或更少 
▫︎B. 了解过基本语法,有 Hello World 经验 
▫︎C. 了解⽐比较多,有项⺫⽬目经验
SCALA 起源 
3 
▫︎出⽣生⽇日期:1958 - 09 - 05 
▫︎国籍:德国 
▫︎⺟母校:苏黎世联邦理⼯工学院 
▫︎公司:Typesafe Inc. 
▫︎成就:Java 泛型、Scala、MOOC 
Martin Oders...
SCALA ⼤大事记 
4 
▫︎2001年,Scala 的设计在 EPFL 开始; 
▫︎2004年初,Java 版发布; 
▫︎2004年6⽉月,.NET 版发布; 
▫︎2006年3⽉月,Scala 2.0 Java 版发布; 
▫︎20...
YOU DON’T KNOW 
WHAT YOU DON’T 
KNOW 
As a developer, 最可怕的事情是什么? 
5
AWESOME SCALA 
6
BUILD TOOL - MAVEN 
7 
<repository> 
<id>scala-tools.org</id> 
<name>Scala-tools Maven2 Repository</name> 
<url>http://sca...
BUILD TOOL - GRADLE 
8 
apply plugin: 'scala' 
repositories { 
mavenCentral() 
} 
dependencies { 
compile 'org.scala-lang:...
BUILD TOOL - SBT 
9 
http://www.scala-sbt.org/ 
name := "hello world" 
version := "0.0.1" 
scalaVersion := "2.11.1" 
resol...
DB - SCALIKEJDBC 
10 
PostgreSQL、MySQL、H2、HSQLDB、Oracle、SQL Server… … 
val orders: List[Order] = withSQL { 
select 
.from(...
DB - SQUERYL 
11 
Postgres、Oracle、MySQL、H2、DB2、SQL Server、Derby 
def songCountByArtistId: Query[GroupWithMeasures[Long, Lo...
DB - SLICK 
12 
Derby、H2、HSQLDB、Access、MySQL、PostgreSQL、SQLite、 
Oracle、DB2 、SQL Server 
val q = coffees.filter(_.price > ...
WEB - PLAY 
13 
route 
GET /hello/:username HelloController.say(username: String) 
controller 
import play.api.mvc.{Action...
WEB - *ATRA 
14
WEB - LIFT 
15 
View First
TEST - SCALACHECK 
16 
Test 
object StringSpec extends Properties("String") { 
property("startWith") = forAll { (a: String...
TEST - SPEC2 
17 
Test 
import org.specs2.mutable._ 
class HelloWorldSpec extends Specification { 
"The 'Hello world' stri...
TEST - GATLING 
18 
class BasicSimulation extends Simulation { 
val httpConf = http.baseURL("http://tax.myhpsnet.com:8800"...
DISTRIBUTED SYSTEM 
19
BIG DATA 
20 
100x faster than Hadoop MapReduce in memory 
10x faster on disk.
REFERENCES 
21 
1. http://en.wikipedia.org/wiki/Martin_Odersky 
2. http://en.wikipedia.org/wiki/Scala_(programming_languag...
AD 
Coursera上有⼀一⻔门免费的课程叫Functional 
Programming Principles in Scala,由Scala 
的作者Martin Odersky主讲。 
22 
https://www.coursera...
Q&A
Upcoming SlideShare
Loading in …5
×

Scala 生态圈 (scala ecosystem)

1,675 views

Published on

scala 生态系统中的一些常用 frameworks,IDE,build tools,libraries。

Published in: Science

Scala 生态圈 (scala ecosystem)

  1. 1. SCALA ⽣生态圈 彭洪伟 ! @make_dream ! hwpeng@thoughtworks.com
  2. 2. SCALA 知多少 2 ▫︎A. 仅仅听过该名词,或更少 ▫︎B. 了解过基本语法,有 Hello World 经验 ▫︎C. 了解⽐比较多,有项⺫⽬目经验
  3. 3. SCALA 起源 3 ▫︎出⽣生⽇日期:1958 - 09 - 05 ▫︎国籍:德国 ▫︎⺟母校:苏黎世联邦理⼯工学院 ▫︎公司:Typesafe Inc. ▫︎成就:Java 泛型、Scala、MOOC Martin Odersky
  4. 4. SCALA ⼤大事记 4 ▫︎2001年,Scala 的设计在 EPFL 开始; ▫︎2004年初,Java 版发布; ▫︎2004年6⽉月,.NET 版发布; ▫︎2006年3⽉月,Scala 2.0 Java 版发布; ▫︎2011年5⽉月,Odersky和Jonas Bonér 创办 Typesafe; ▫︎2012年,官⽅方停⽌止维护 Scala .NET 版; ▫︎2014年,Scala 2.11.2 发布。
  5. 5. YOU DON’T KNOW WHAT YOU DON’T KNOW As a developer, 最可怕的事情是什么? 5
  6. 6. AWESOME SCALA 6
  7. 7. BUILD TOOL - MAVEN 7 <repository> <id>scala-tools.org</id> <name>Scala-tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </repository> <pluginRepository> <id>scala-tools.org</id> <name>Scala-tools Maven2 Repository</name> <url>http://scala-tools.org/repo-releases</url> </pluginRepository> <dependency> <groupId>org.scala-lang</groupId> <artifactId>scala-library</artifactId> <version>2.11.1</version> </dependency> <plugin> <groupId>org.scala-tools</groupId> <artifactId>maven-scala-plugin</artifactId> <executions> <execution> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin>
  8. 8. BUILD TOOL - GRADLE 8 apply plugin: 'scala' repositories { mavenCentral() } dependencies { compile 'org.scala-lang:scala-library:2.11.1' }
  9. 9. BUILD TOOL - SBT 9 http://www.scala-sbt.org/ name := "hello world" version := "0.0.1" scalaVersion := "2.11.1" resolvers ++= Seq ( Resolver.mavenLocal, Resolver.sonatypeRepo ("releases"), Resolver.typesafeRepo ("releases") ) libraryDependencies ++= Seq ("org.scala-lang" % "scala-compiler" % "2.11.1") addSbtPlugin ("com.typesafe.play" % "sbt-plugin" % "2.3.1")
  10. 10. DB - SCALIKEJDBC 10 PostgreSQL、MySQL、H2、HSQLDB、Oracle、SQL Server… … val orders: List[Order] = withSQL { select .from(Order as o) .innerJoin(Product as p).on(o.productId, p.id) .leftJoin(Account as a).on(o.accountId, a.id) .where.eq(o.productId, 123) .orderBy(o.id).desc .limit(4) .offset(0) }.map(Order(o, p, a)).list.apply() SELECT o.*, p.*, a.* FROM orders o INNER JOIN products p ON o.product_id = p.id LEFT JOIN accounts a ON o.account_id = a.id WHERE o.product_id = 123 ORDER BY o.id DESC LIMIT 4 OFFSET 0
  11. 11. DB - SQUERYL 11 Postgres、Oracle、MySQL、H2、DB2、SQL Server、Derby def songCountByArtistId: Query[GroupWithMeasures[Long, Long]] = from(artists, songs)((a, s) => where(a.id === s.artistId) groupBy (a.id) compute (countDistinct(s.id)) ) SELECT Artist1.id AS g0, count(DISTINCT Song2.id) AS c0 FROM Artist Artist1, Song Song2 WHERE (Artist1.id = Song2.artistId) GROUP BY Artist1.id
  12. 12. DB - SLICK 12 Derby、H2、HSQLDB、Access、MySQL、PostgreSQL、SQLite、 Oracle、DB2 、SQL Server val q = coffees.filter(_.price > 20) .sortBy(_.name.desc) .drop(10) .take(5) SELECT * FROM coffees WHERE price > 20 ORDER BY name DESC LIMIT 5 OFFSET 10
  13. 13. WEB - PLAY 13 route GET /hello/:username HelloController.say(username: String) controller import play.api.mvc.{Action, Controller} object HelloController extends Controller { def say(username: String) = Action { Ok(s"hello, $username") } }
  14. 14. WEB - *ATRA 14
  15. 15. WEB - LIFT 15 View First
  16. 16. TEST - SCALACHECK 16 Test object StringSpec extends Properties("String") { property("startWith") = forAll { (a: String, b: String) => (a + b).startsWith(a) } property("concatenate") = forAll { (a: String, b: String) => (a + b).length > a.length && (a + b).length > b.length } } Result + String.startWith: OK, passed 100 tests. ! String.concat: Falsified after 0 passed tests. > ARG_0: "" > ARG_1: "" !
  17. 17. TEST - SPEC2 17 Test import org.specs2.mutable._ class HelloWorldSpec extends Specification { "The 'Hello world' string" should { "contain 11 characters" in { "Hello world" must have size(11) } "start with 'Hello'" in { "Hello world" must startWith("Hello") } "end with 'world'" in { "Hello world" must endWith("world") } } }
  18. 18. TEST - GATLING 18 class BasicSimulation extends Simulation { val httpConf = http.baseURL("http://tax.myhpsnet.com:8800") val scn = scenario("BasicSimulation") .exec(http("get an invoice") .get("/api/invoices/d361bb03-e762-3842-b6ae-a3062d1e5cf7")) .pause(1) setUp(scn.inject(atOnceUsers(100)).protocols(httpConf)) }
  19. 19. DISTRIBUTED SYSTEM 19
  20. 20. BIG DATA 20 100x faster than Hadoop MapReduce in memory 10x faster on disk.
  21. 21. REFERENCES 21 1. http://en.wikipedia.org/wiki/Martin_Odersky 2. http://en.wikipedia.org/wiki/Scala_(programming_language) 3. http://www.infoq.com/cn/articles/scala-technology 4. https://github.com/lauris/awesome-scala 5. http://agiledon.github.io/blog/2014/01/13/testing-styles-of-scalatest/ 6. http://agiledon.github.io/blog/2014/07/20/scala-resource/
  22. 22. AD Coursera上有⼀一⻔门免费的课程叫Functional Programming Principles in Scala,由Scala 的作者Martin Odersky主讲。 22 https://www.coursera.org/course/progfun
  23. 23. Q&A

×