SCALA :
language of the future
by Robin Syihab
Mindtalk: @robin
Twitter: @anvie
Email: robin@mindtalk.com
Scala is
a Modern Programming language.
Created by Martin Odersky.
Static Typing
OOP + FP
Compiled into bytecode and run on top of JVM.
Java compatible binaries.
a better Java.
“If I were to pick a language
to use today other than
Java, it would be Scala”
~ James Gosling (father of Java).
Scala is
JVM Language
Java & Scala timeline
JVM Languages available today
Scala
Groovy
Fantom
Clojure
JRuby
Jython
Kotlin
Java & JVML timeline
“The legacy of Java will be the
platform, not the language.”
~ Martin Fowler (OOP programming expert)
Scala is
Scalable Language
“No other language on the JVM
seems as capable of being a
"replacement for Java" as Scala.”
~ Charlies Nutter (JRuby lead)
Scala in production
Scala Job Trends
Java vs Scala
(syntax)
Java
Scala
Scala
Java
Singleton
Scala
Java
Singleton Use
Scala
Java
Regex
Scala is powerful for
functional
programming
Scala
Java
Partitioning
Scala
Java
Calculating average
Scala is more than
“syntactic sugar language”
Scala is OOP
http://www.ibs.ro
Scala OOP
Object inheritance
Object and method accessibility
(public, protected, private).
Static method.
Mutable & Immutable variable.
Scala OOP
Everything return value
Traits
Like interfaces in java, but
can have implementations
can have fields
can mix-in
Scala is Functional
XML Literals
Scala support XML literals inside of code
XML literals
Lazy variable evaluation
LazyVariable Evaluation
// Use case
Pattern Matching
animal match {
case cat:Cat =>
cat.meow()
case tiger:Tiger =>
tiger.hoa()
}
Pattern Matching
Pattern Matching:
data extraction
Pattern Matching:
data extraction + guardian
Implicit definition
http://www.iwallscreen.com
“robin@mindtalk.com”.md5
Implicit definition: View bounds
robin say “hello”
robin.say(“hello”)
Lenient Invocation Syntax
object method parameter
Lenient Invocation Syntax
h(x) = y f(x, y)⟼
Currying Function
We need this simple code run robustly:
+ no crash when exception happen.
+ handle unicode UTF-8 correctly.
+ no memory leak.
Currying Function
Currying Function
Partial Function
http://bertzzie.com
Partial Function
Pipelining
Pattern Matching
Partial Function: Pipelining
Execution
Partial Function: Pipelining
Partial Function: Pattern Matching
Parameter
Partial Function: Pattern Matching
Actor
Concurrent Programming
When to use Actor?
If we want to build distributed system.
Handle massive concurrent request.
Needs for build event-driven
asynchronous application.
High performance lightweight than
Thread.
Scala Actor Local
Akka Actor: Distributed
100.10.10.1
Actor A
100.10.10.2
Actor B
100.10.10.3
Actor C
100.10.10.4
Actor D
event stream
http://akka.io/
Akka Actor
Support local & remote actor
Self-healing using supervisor
Decentralized
Adaptive load balancing
Configuration-driven
Extensible
Small memory footprint ~2.5 million actors per GB of
Heap
Event stream easy to handle cluster state
Akka Actor in production
TDD in Scala
http://lostechies.com
Scala testing framework
Scalatest
JUnit
Spec2
Gatling (performance test)
Specs2 Unit test
Specs2 Acceptance test
Specs2
Ok thats sound interesting,
but wait...
how with the development tools?
http://www.thetinylife.com
Development tools
IDE
Scala-IDE
(eclipse based)
NetBeans
IntellijIdea
Emacs (ENSIME)
Build System
Maven
SBT (Simple
Build Tools)
Project generator
Giter8
JRebel (incremental
development)
giter8
Build Scala “hello world”
application in minute
Thank you

Scala : language of the future