Scala - What Makes the Difference - Part 1

Post on 18-May-2015

571 views 3 download

Tags:

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

What makes the difference?

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

Outline

• introduction and design principles

• a taste of Scala code

• troubles and obstacles

What is Scala?

statically typed language

that unifies object oriented

and functional programming

What is Scala?

compiles into Java bytecode

runs inside JVM

fully interoperable with Java

Scalable Language

Scalable Language

language that grows with the demands of its users

Scalable Language

• concise and expressive

• few, yet very powerful building blocks

• can be composed into complex structures

Everything is an object

• no primitive types

• functions are objects too

• unified type system

No operators, only methods

1 + 2

1.+(2)

new BigInt(4) * new BigInt(2)

Higher-order functions

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

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

Higher-kinded types

Foo[T[_]]

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) }

Scalable at Runtime

Static typing

Scalable at Runtime

JVM

Solving difficult problems

• parallelism

• concurrency

Traditional approach

• shared mutable state

• synchronization, locking

• difficult to reason about

• race conditions, deadlocks

The Scala Way

• immutability

• functional programming

• actor model

• keeping sanity

Scalability in Practice

The Ecosystem

• everything you want from Java

• native Scala solutions (Akka, Play, …)

• lively community

Academic roots

• Martin Odersky, EPFL

• strong theoretical foundation

• Programming Methods Laboratory (LAMP)

• results of research projects bring innovations to the language

Future over Past

• language innovations are more important than backwards compatibility

• Scala Improvement Process

• improvements must be general

The Scala Company

• founded in 2011 (EPFL + Akka)

• venture capital

• Typesafe Stack

• enterprise support, training, conferences, ...

• investments in tooling