ScaLA Journey

novice level

High level Introduction

  • Scala was created by Martin Ordersky and other fellows in 2001. It was built upon Java language.

  • Scala is static typed, light-weight, expressible language. It provides the orthogonal programming model by imperative programming and functional programming model.

  • Scala provided lambda programming from very beginning that is far before Java. 

  • Twitter is powered by Scala and leverage "netty" framework, it could reach 10 ,000 op/secs throughput. 

Why Scala?

  • More elegant language semantics.
 

  • More effective programming

  • More quicker execution speed which power by scala jit.
  • Can easily integrate with Java codes, so all your libraries and codes won't be threw out.


  • Bunch of strong and easier used libraries. For example: Twitter's key swiss knife Finagle,Big data power by Spark,  Web programming: Play 

  • Higher pay, last year scala: 120,000 $   java: 109,850 $.

FUNCTION as First class Citizen 

  • you can run the codes  in the REPL console
def square(a: Int) = a * a
println("square(2):" + square(2))
println(1 + 1)println(1. + 1)

class IntAdder(var value: Int) { def + (aValue: Int): Int = { value += aValue value }}
println(new IntAdder(2) + 2)

Type System

object Closer {
    def using(closeable: { def close(): Unit }, f: => Unit) {
      try { 
        f
      } finally { closeable.close }
    }
}
class Connection { def close() { }
def preClose() { } }
class App { def close() { }
def authenticate() { }}

object Test { def main(args: Array[String]) {
val connection = new Connection val app = new App Closer.using(connection, connection.preClose) Closer.using(app, app.authenticate) }}

"Crazy" Collection framework

  • Effectively operating  and have many built-in features

val numbers = List(1, 2, 3, 4)numbers.map(_ * 2)    // _ represents every members in Listnumbers.map((i: Int) => i * 2)   // actually define a anonymous function

def isEven((i: Int): Boolean = i % 2 == 0numbers.filter(isEven _)


LA CLOSURE

  • La closure is a function whose return value depends on one or more variables which defined outside of that function. 
def multiply(left: Int)(right: Int) = left * rightval multiply10 = multiply(10)(_)multiply10(10)
val right: Int = 10def multiply(left: Int) = left * rightmultiply(10)

Other

  • Scala is not a easy language to learn. Since it combines two orthogonal model together.

  • But leverage with fundamental features you can easily and effectively building up on application. 

  • As Java develops and evolves  further, Scala will begin much more powerful.

  • Would you want to use Scala as the first choice of your next projects? [Quick survey]

Q&A

Made with Slides.com