scala : language of the future
TRANSCRIPT
![Page 1: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/1.jpg)
SCALA : language of the future
by Robin SyihabMindtalk: @robin
Twitter: @anvieEmail: [email protected]
![Page 2: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/2.jpg)
Scala is
a Modern Programming language.Created by Martin Odersky.Static TypingOOP + FPCompiled into bytecode and run on top of JVM.Java compatible binaries.a better Java.
![Page 3: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/3.jpg)
“If I were to pick a language to use today other than Java, it would be Scala”
~ James Gosling (father of Java).
![Page 4: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/4.jpg)
Scala is
JVM Language
![Page 5: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/5.jpg)
Java & Scala timeline
![Page 6: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/6.jpg)
JVM Languages available today
ScalaGroovyFantomClojureJRubyJythonKotlin
![Page 7: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/7.jpg)
Java & JVML timeline
![Page 8: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/8.jpg)
“The legacy of Java will be the platform, not the language.”~ Martin Fowler (OOP programming expert)
![Page 9: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/9.jpg)
Scala is
Scalable Language
![Page 10: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/10.jpg)
“No other language on the JVM seems as capable of being a
"replacement for Java" as Scala.”~ Charlies Nutter (JRuby lead)
![Page 11: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/11.jpg)
Scala in production
![Page 12: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/12.jpg)
Scala Job Trends
![Page 13: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/13.jpg)
Java vs Scala (syntax)
![Page 14: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/14.jpg)
Java
Scala
![Page 15: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/15.jpg)
Scala
Java
Singleton
![Page 16: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/16.jpg)
Scala
Java
Singleton Use
![Page 17: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/17.jpg)
Scala
Java
Regex
![Page 18: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/18.jpg)
Scala is powerful for functional
programming
![Page 19: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/19.jpg)
Scala
Java
Partitioning
![Page 20: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/20.jpg)
Scala
Java
Calculating average
![Page 21: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/21.jpg)
Scala is more than“syntactic sugar language”
![Page 23: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/23.jpg)
Scala OOP
Object inheritanceObject and method accessibility (public, protected, private).Static method.Mutable & Immutable variable.
![Page 24: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/24.jpg)
Scala OOP
![Page 25: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/25.jpg)
![Page 26: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/26.jpg)
Everything return value
![Page 27: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/27.jpg)
Traits
Like interfaces in java, butcan have implementationscan have fieldscan mix-in
![Page 28: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/28.jpg)
![Page 29: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/29.jpg)
Scala is Functional
![Page 30: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/30.jpg)
XML LiteralsScala support XML literals inside of code
![Page 31: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/31.jpg)
XML literals
![Page 32: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/32.jpg)
Lazy variable evaluation
![Page 33: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/33.jpg)
Lazy Variable Evaluation
// Use case
![Page 34: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/34.jpg)
Pattern Matching
animal match { case cat:Cat => cat.meow()
case tiger:Tiger => tiger.hoa()
}
![Page 35: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/35.jpg)
Pattern Matching
![Page 36: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/36.jpg)
Pattern Matching: data extraction
![Page 37: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/37.jpg)
Pattern Matching: data extraction + guardian
![Page 40: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/40.jpg)
Implicit definition: View bounds
![Page 41: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/41.jpg)
robin say “hello”
robin.say(“hello”)
Lenient Invocation Syntax
object method parameter
![Page 42: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/42.jpg)
Lenient Invocation Syntax
![Page 43: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/43.jpg)
h(x) = y f(x, y)⟼
Currying Function
![Page 44: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/44.jpg)
We need this simple code run robustly:+ no crash when exception happen.+ handle unicode UTF-8 correctly.+ no memory leak.
Currying Function
![Page 45: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/45.jpg)
Currying Function
![Page 47: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/47.jpg)
Partial Function
PipeliningPattern Matching
![Page 48: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/48.jpg)
Partial Function: Pipelining
Execution
![Page 49: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/49.jpg)
Partial Function: Pipelining
![Page 50: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/50.jpg)
Partial Function: Pattern Matching
Parameter
![Page 51: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/51.jpg)
Partial Function: Pattern Matching
![Page 52: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/52.jpg)
ActorConcurrent Programming
![Page 53: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/53.jpg)
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.
![Page 54: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/54.jpg)
Scala Actor Local
![Page 55: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/55.jpg)
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/
![Page 56: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/56.jpg)
Akka Actor
Support local & remote actorSelf-healing using supervisorDecentralized
Adaptive load balancing Configuration-driven
ExtensibleSmall memory footprint ~2.5 million actors per GB of HeapEvent stream easy to handle cluster state
![Page 57: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/57.jpg)
Akka Actor in production
![Page 59: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/59.jpg)
Scala testing framework
ScalatestJUnitSpec2Gatling (performance test)
![Page 60: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/60.jpg)
Specs2 Unit test
![Page 61: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/61.jpg)
Specs2 Acceptance test
![Page 62: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/62.jpg)
Specs2
![Page 63: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/63.jpg)
Ok thats sound interesting,but wait...
how with the development tools?
http://www.thetinylife.com
![Page 64: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/64.jpg)
Development tools
IDE
Scala-IDE (eclipse based)
NetBeans
IntellijIdea
Emacs (ENSIME)
Build System
Maven
SBT (Simple Build Tools)
Project generator
Giter8
JRebel (incremental development)
![Page 65: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/65.jpg)
giter8
Build Scala “hello world”application in minute
![Page 66: Scala : language of the future](https://reader031.vdocuments.mx/reader031/viewer/2022021507/58ed33071a28abfd358b466d/html5/thumbnails/66.jpg)
Thank you