scala - what makes the difference - part 1
DESCRIPTION
Part one of the "Scala - What Makes the Difference" presentation about Scala, its basic concepts, motivations and advantages by Vlastimil Menčík. The presentation was held at Faculty of Information Technology in Prague on April 8th.TRANSCRIPT
![Page 1: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/1.jpg)
What makes the difference?
Vlastimil Menčík, Jakub Janeček, Karel Smutný
![Page 2: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/2.jpg)
Outline
• introduction and design principles
• a taste of Scala code
• troubles and obstacles
![Page 3: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/3.jpg)
What is Scala?
statically typed language
that unifies object oriented
and functional programming
![Page 4: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/4.jpg)
What is Scala?
compiles into Java bytecode
runs inside JVM
fully interoperable with Java
![Page 5: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/5.jpg)
Scalable Language
![Page 6: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/6.jpg)
Scalable Language
language that grows with the demands of its users
![Page 7: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/7.jpg)
Scalable Language
• concise and expressive
• few, yet very powerful building blocks
• can be composed into complex structures
![Page 8: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/8.jpg)
Everything is an object
• no primitive types
• functions are objects too
• unified type system
![Page 9: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/9.jpg)
No operators, only methods
1 + 2
1.+(2)
new BigInt(4) * new BigInt(2)
![Page 10: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/10.jpg)
Higher-order functions
List(1, 2, 3) map (n => n + 1)
withConnection { c => c.prepareStatement(...) ...}
![Page 11: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/11.jpg)
Higher-kinded types
Foo[T[_]]
![Page 12: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/12.jpg)
Internal DSLs
"A Stack" should "maintain LIFO order" in { val stack = new Stack[Int] stack.push(1) stack.push(2) stack.pop() should equal (2) stack.pop() should equal (1) }
![Page 13: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/13.jpg)
Scalable at Runtime
Static typing
![Page 14: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/14.jpg)
Scalable at Runtime
JVM
![Page 15: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/15.jpg)
Solving difficult problems
• parallelism
• concurrency
![Page 16: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/16.jpg)
Traditional approach
• shared mutable state
• synchronization, locking
• difficult to reason about
• race conditions, deadlocks
![Page 17: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/17.jpg)
The Scala Way
• immutability
• functional programming
• actor model
• keeping sanity
![Page 18: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/18.jpg)
Scalability in Practice
![Page 19: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/19.jpg)
The Ecosystem
• everything you want from Java
• native Scala solutions (Akka, Play, …)
• lively community
![Page 20: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/20.jpg)
Academic roots
• Martin Odersky, EPFL
• strong theoretical foundation
• Programming Methods Laboratory (LAMP)
• results of research projects bring innovations to the language
![Page 21: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/21.jpg)
Future over Past
• language innovations are more important than backwards compatibility
• Scala Improvement Process
• improvements must be general
![Page 22: Scala - What Makes the Difference - Part 1](https://reader033.vdocuments.site/reader033/viewer/2022052900/5559e9c4d8b42a34498b515c/html5/thumbnails/22.jpg)
The Scala Company
• founded in 2011 (EPFL + Akka)
• venture capital
• Typesafe Stack
• enterprise support, training, conferences, ...
• investments in tooling