4. History
2003 - Released in EPFL
2008 - ‘Programming in Scala’
2010 - Version 2.8
2011 - Typesafe Inc. founded
2012 - First course on Coursera
2013 - Version 2.10
5. Recipe
● Take Java-like syntax
● Remove specifics and
unnecessary limitations
● Mix in functional features*
6. Complexity
● About 40 reserved words
● Only 2 namespaces vs. 4 in Java (fields, methods,
packages, types)
● Methods instead of operators
● No primitives (AnyVal)
23. Imperative example
def concat(list: List[Any]): String = {
val iter = list.iterator
var result = ""
while (iter.hasNext) {
result += iter.next
}
result
}
54. Try
def parse(js: Js): String
def store(name: String): Int
for {
name <- Try(parse(json))
id <- Try(store(name))
} yield id
scala.util
Failure[+T]
scala.util
Success[+T]
scala.util
Try[+T]
55. Future
def query(q: String): List[String]
val resF = Future { query(q) }
resF.onSuccess {
case list => …
}
resF.onFailure {
case ex => …
}
scala.concurrent
Future[+T]
56. Future
def query(q: String): List[String]
def store(l: List[String]): Int
queryF.onSuccess {
case list => {
val storeF = Future { store(list) }
storeF.onSuccess { case id => … }
}
}
scala.concurrent
Future[+T]
57. Future
val resultsF = Future{ query("WTF") }
for {
results <- resultsF
id <- Future{ store(results) }
} yield id
scala.concurrent
Future[+T]
58. Wait... there’s more!
● object-oriented programming
● arcane things
● actors
● ecosystem
● tools and frameworks
59. The book
● Suited for people with no prior
experience in Scala
● Includes functional programming tutorial
● Focuses on Play 2.5
● ScalikeJDBC, MacWire, Akka
● Webpack, Sass, React, EcmaScript 6