Scala - What Makes the Difference - Part 1

22
What makes the difference? Vlastimil Menčík, Jakub Janeček, Karel Smutný

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 of Scala - What Makes the Difference - Part 1

Page 1: Scala - What Makes the Difference - Part 1

What makes the difference?

Vlastimil Menčík, Jakub Janeček, Karel Smutný

Page 2: Scala - What Makes the Difference - Part 1

Outline

• introduction and design principles

• a taste of Scala code

• troubles and obstacles

Page 3: Scala - What Makes the Difference - Part 1

What is Scala?

statically typed language

that unifies object oriented

and functional programming

Page 4: Scala - What Makes the Difference - Part 1

What is Scala?

compiles into Java bytecode

runs inside JVM

fully interoperable with Java

Page 5: Scala - What Makes the Difference - Part 1

Scalable Language

Page 6: Scala - What Makes the Difference - Part 1

Scalable Language

language that grows with the demands of its users

Page 7: Scala - What Makes the Difference - Part 1

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

Everything is an object

• no primitive types

• functions are objects too

• unified type system

Page 9: Scala - What Makes the Difference - Part 1

No operators, only methods

1 + 2

1.+(2)

new BigInt(4) * new BigInt(2)

Page 10: Scala - What Makes the Difference - Part 1

Higher-order functions

List(1, 2, 3) map (n => n + 1)

withConnection { c => c.prepareStatement(...) ...}

Page 11: Scala - What Makes the Difference - Part 1

Higher-kinded types

Foo[T[_]]

Page 12: Scala - What Makes the Difference - Part 1

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

Scalable at Runtime

Static typing

Page 14: Scala - What Makes the Difference - Part 1

Scalable at Runtime

JVM

Page 15: Scala - What Makes the Difference - Part 1

Solving difficult problems

• parallelism

• concurrency

Page 16: Scala - What Makes the Difference - Part 1

Traditional approach

• shared mutable state

• synchronization, locking

• difficult to reason about

• race conditions, deadlocks

Page 17: Scala - What Makes the Difference - Part 1

The Scala Way

• immutability

• functional programming

• actor model

• keeping sanity

Page 18: Scala - What Makes the Difference - Part 1

Scalability in Practice

Page 19: Scala - What Makes the Difference - Part 1

The Ecosystem

• everything you want from Java

• native Scala solutions (Akka, Play, …)

• lively community

Page 20: Scala - What Makes the Difference - Part 1

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

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

The Scala Company

• founded in 2011 (EPFL + Akka)

• venture capital

• Typesafe Stack

• enterprise support, training, conferences, ...

• investments in tooling