Introduction to Scala

Manuel Bernhardt
Manuel BernhardtReactive Systems Consultant at manuel.bernhardt.io
SCALA
Java Klassentreffen 2013
Manuel Bernhardt
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in practice
• Tools & more
@elmanu Java Klassentreffen 2013 - javatraining.at
YOUR SPEAKER
• Independent software
consultant
• Web, web, web
• Java & Scala & Javascript
• Open-Source
• Delving
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in practice
• Tools & more
@elmanu Java Klassentreffen 2013 - javatraining.at
HISTORY
• Martin Odersky, EPFL
• Espresso, Pizza, GJ, Javac
• Funnel, Scala
• First Scala release in
2003
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in practice
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
• Full interoperability with Java
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
• Full interoperability with Java
• Cut down boilerplate
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
• Full interoperability with Java
• Cut down boilerplate
• Pure object orientation & functional programming
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
• Full interoperability with Java
• Cut down boilerplate
• Pure object orientation & functional programming
• Move away from null
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA DESIGN GOALS
• Full interoperability with Java
• Cut down boilerplate
• Pure object orientation & functional programming
• Move away from null
• Multi-core programming
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in practice
• Tools & more
@elmanu Java Klassentreffen 2013 - javatraining.at
WHAT PEOPLE SAY
If I were to pick a language today
other than Java, it would be Scala.
James Gosling
Father of Java
@elmanu Java Klassentreffen 2013 - javatraining.at
WHAT PEOPLE SAY
I can honestly say if someone had
shown me the Programming Scala
book by Martin Odersky, Lex Spoon
& Bill Venners back in 2003 I’d
probably have never created Groovy.
James Strachan
Creator of Groovy
@elmanu Java Klassentreffen 2013 - javatraining.at
ThoughtWorksTechRadar May 2013
http://www.thoughtworks.com/radar
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA INTHE WILD
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA INTHE WILD
etc.
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA INVIENNA
• openForce - http://openforce.com
• x-tradesoft - http://xtradesoft.com
• Delving - http://www.delving.eu
• dimocom - http://www.dimocom.com
• emarsys - http://www.emarsys.com
• Miavia - https://miavia.in
@elmanu Java Klassentreffen 2013 - javatraining.at
SCALA INVIENNA
• ScalaVienna User Group
• http://scala-vienna.org/
Next meeting: 26th
September 6 PM - Sektor 5
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in
practice
• Tools & more
@elmanu Java Klassentreffen 2013 - javatraining.at
AVOIDINGTHE BILLION-
DOLLAR MISTAKE
But I couldn't resist the
temptation to put in a null
reference, simply because it
was so easy to implement
Tony Hoare
Creator of ALGOL
@elmanu Java Klassentreffen 2013 - javatraining.at
AVOIDINGTHE BILLION-
DOLLAR MISTAKE
val maybeUser: Option[User] = User.findOneByName("bob")
// returns Some[User]
maybeUser == None // false
maybeUser.foreach { user =>
println(user.fullName)
// prints "Bob Marley" if there is a user!
}
val name = maybeUser.map(_.name).getOrElse("Unknown user")
@elmanu Java Klassentreffen 2013 - javatraining.at
CONCISENESS
public class User {
! private String name;
! private String surname;
! private String email;
! public User(String name, String surname, String email) {
! ! this.name = name;
! ! this.surname = surname;
! ! this.email = email;
! }
! public void setName(String name) {
! ! this.name = name;
! }
! public void setSurname(String surname) {
! ! this.surname = surname;
! }
! public void setEmail(String email) {
! ! this.email = email
! }
! public String getName() {
! ! return this.name;
! }
! public String getSurname() {
! ! return this.surname;
! }
! public String getEmail() {
! ! return this.surname;
! }
}
@elmanu Java Klassentreffen 2013 - javatraining.at
CONCISENESS
class User(
var name: String,
var surname: String,
var email: String)
val bob = new User("Bob", "Marley", "bob@marley.org")
// bob: User = User@5c3f1224
bob.name // res0: String = Bob
bob.name = "Bobby" // bob.name: String = Bobby
@elmanu Java Klassentreffen 2013 - javatraining.at
CONCISENESS
public class ImmutableUser {
! private final String name;
! private final String surname;
! private final String email;
! public ImmutableUser(String name, String surname, String email) {
! ! this.name = name;
! ! this.surname = surname;
! ! this.email = email;
! }
! public String getName() {
! ! return this.name;
! }
! public String getSurname() {
! ! return this.surname;
! }
! public String getEmail() {
! ! return this.surname;
! }
! @Override public int hashCode() {
! ! // yada yada yada
! }
! @Override public boolean equals(Object that) {
! ! // yada yada yada
! }
}
@elmanu Java Klassentreffen 2013 - javatraining.at
CONCISENESS
case class ImmutableUser(
name: String,
surname: String,
email: String)
val bob = ImmutableUser("Bob", "Marley", "bob@marley.org")
// hashcode and equals for free!
val namedBob = ImmutableUser(name = "Bob", surname = "Marley",
email = "email")
val bobby = bob.copy(name = "Bobby")
// returns a User with name Bobby
bob.toString // res0: String = ImmutableUser(Bob,Marley,email)
@elmanu Java Klassentreffen 2013 - javatraining.at
USEFULTYPE INFERENCE
val foo = "Bar" // foo: String = Bar
val answer = 42 // answer: Int = 42
val price = 9.99 // price: Double = 9.99
val nums = List(1, 2, 3) // nums: List[Int] = List(1, 2, 3)
val map = Map("abc" -> List(1, 2, 3))
// map: scala.collection.immutable.Map[String,List[Int]] =
Map(abc -> List(1, 2, 3))
@elmanu Java Klassentreffen 2013 - javatraining.at
EXPLICITTYPING
val foo: String = "Bar" // foo: String = Bar
val answer: Int = 42 // answer: Int = 42
val price: Double = 9.99 // price: Double = 9.99
val nums: List[Int] = List(1, 2, 3) // nums: List[Int] =
List(1, 2, 3)
val map: Map[String, List[Int]] = Map("abc" -> List(1, 2, 3))
// map: scala.collection.immutable.Map[String,List[Int]] =
Map(abc -> List(1, 2, 3))
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
users.sort(new Comparator {
public int compare(Object user1, Object user2) {
! int userAge1 = ((User) user1).getAge();
! int userAge2 = ((User) user2).getAge();
! if (userAge1 > userAge2) {
! ! return 1;
! } else if userAge1 < userAge2) {
! ! ! return -1;
! ! } else {
! ! ! return 0;
! ! }
! }
});
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
def sortByAge(user1: User, user2: User) = user1.age > user2.age
users.sortWith(sortByAge)
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
users.sortWith((user1, user2) => user1.age > user2.age)
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
users.sortWith(_.age > _.age)
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
List<User> minors = new ArrayList<User>();
List<User> majors = new ArrayList<User>();
for (User u : users) {
! if (u.getAge() < 18) {
! ! minors.add(u);
! } else {
! ! majors.add(u);
! }
}
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
val (minors, majors) = users.partition(_.age < 18)
@elmanu Java Klassentreffen 2013 - javatraining.at
COLLECTION LIBRARY &
FUNCTIONAL STYLE
val minors = users.filter(_.age < 18)
@elmanu Java Klassentreffen 2013 - javatraining.at
• Minimal language, powerful library
• Language features for extensibility
EXTENSIBLE LANGUAGE
@elmanu Java Klassentreffen 2013 - javatraining.at
DOMAIN SPECIFIC
LANGUAGES
import collection.mutable.Stack
import org.scalatest._
class ExampleSpec extends FlatSpec with Matchers {
"A Stack" should "pop values in last-in-first-out order" in {
val stack = new Stack[Int]
stack.push(1)
stack.push(2)
stack.pop() should be (2)
stack.pop() should be (1)
}
it should "throw NoSuchElementException if an empty stack is popped" in {
val emptyStack = new Stack[Int]
a [NoSuchElementException] should be thrownBy {
emptyStack.pop()
}
}
}
@elmanu Java Klassentreffen 2013 - javatraining.at
MACROS
PLAY JSON DE/SERIALIZATION
@elmanu Java Klassentreffen 2013 - javatraining.at
MACROS
PLAY JSON DE/SERIALIZATION
case class Creature(name: String, isDead: Boolean, weight: Float)
implicit val creatureReads: Reads[Creature] = (
(__  "name").read[String] and
(__  "isDead").read[Boolean] and
(__  "weight").read[Float]
)(Creature)
implicit val creatureWrites: Writes[Creature] = (
(__  "name").write[String] and
(__  "isDead").write[Boolean] and
(__  "weight").write[Float]
)(unlift(Creature.unapply))
@elmanu Java Klassentreffen 2013 - javatraining.at
MACROS
PLAY JSON DE/SERIALIZATION
import play.api.json._
implicit val creatureFormat = Json.format[Creature] // format is a macro
@elmanu Java Klassentreffen 2013 - javatraining.at
AGENDA
• History
• Why Scala?
• Scala in the wild
• The Code / Scala in practice
• Tools & more
@elmanu Java Klassentreffen 2013 - javatraining.at
IDE
• IntelliJ IDEA
• Eclipse
• SublimeText
@elmanu Java Klassentreffen 2013 - javatraining.at
SIMPLE BUILDTOOL
name := "My Project"
version := "1.0"
organization := "org.myproject"
libraryDependencies += "org.scala-tools.testing" %% "scalacheck" %
"1.8" % "test"
libraryDependencies ++= Seq(
"net.databinder" %% "dispatch-meetup" % "0.7.8",
"net.databinder" %% "dispatch-twitter" % "0.7.8"
)
javaOptions += "-Xmx256m"
logLevel in compile := Level.Warn
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS:AKKA
• Actor concurrency model based on Erlang
• “Human” design: actors talk to eachother and form hierarchies
• Much, much, much simpler to work and reason with than
threads
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS:AKKA
Source: http://prabhubuzz.wordpress.com/2012/09/28/akka-really-mountains-of-concurrency/
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS:AKKA
class Master extends Actor {
! val workers = context.actorOf(Props[Worker].withRouter(
! RoundRobinRouter(nrOfInstances = 5))
! )
! def receive = {
! ! case Start =>
! ! ! getDocumentsFromDb.foreach { document =>
! ! ! ! workers ! Process(document)
! ! ! }
! ! case Result(processed) => writeResult(processed)
! ! case Stop => children.foreach(stop)
! }
}
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS:AKKA
class Worker extends Actor {
! def receive = {
! ! case Process(doc: Document) =>
! ! ! val processed = doSomeHardWork(doc)
! ! ! sender ! Result(processed)
! }
}
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS: PLAY
• MVC framework à la Rails
• Real-time web, streams (WebSocket, ...)
• Everything is compiled
• I mean everything: CSS, JavaScripts,Templates, URLs, JSON, ...
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS: PLAY
GET /users controllers.Users.list
POST /users controllers.Users.create
PUT /users/:id/update controllers.Users.update(id: Long)
DELETE /users/:id controllers.Users.delete(id: Long)
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS: PLAY
class Users extends Controller {
def list = Action { request =>
val users = User.findAll
Ok(Json.toJson(users))
}
}
@elmanu Java Klassentreffen 2013 - javatraining.at
FRAMEWORKS: PLAY
class Users extends Controller {
def list = Action { request =>
val users = User.findAll
Ok(Json.toJson(users))
}
}
200 OK
Content-Type: application/json
@elmanu Java Klassentreffen 2013 - javatraining.at
THANKYOU!
• Questions, comments ?
• http://logician.eu
• manuel@bernhardt.io
• @elmanu
1 of 53

Recommended

Why is Haskell so hard! (And how to deal with it?) by
Why is Haskell so hard! (And how to deal with it?)Why is Haskell so hard! (And how to deal with it?)
Why is Haskell so hard! (And how to deal with it?)Saurabh Nanda
567 views76 slides
Scala Introduction by
Scala IntroductionScala Introduction
Scala IntroductionAdrian Spender
3.2K views76 slides
[Start] Scala by
[Start] Scala[Start] Scala
[Start] Scala佑介 九岡
3.2K views86 slides
Scala For Java Programmers by
Scala For Java ProgrammersScala For Java Programmers
Scala For Java ProgrammersEnno Runne
4.6K views135 slides
Javawug bof 57 scala why now by
Javawug bof 57 scala why nowJavawug bof 57 scala why now
Javawug bof 57 scala why nowSkills Matter
616 views15 slides
Presentacion foro de análisis: a 4 años del mal gobierno del #PAN by
Presentacion foro de análisis: a 4 años del mal gobierno del #PANPresentacion foro de análisis: a 4 años del mal gobierno del #PAN
Presentacion foro de análisis: a 4 años del mal gobierno del #PANMiguel Centeno Silva
572 views52 slides

More Related Content

Viewers also liked

Catálogo de servicios para la administración pública by
Catálogo de servicios para la administración públicaCatálogo de servicios para la administración pública
Catálogo de servicios para la administración públicaPROQUAME
656 views8 slides
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso... by
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...Juez Luis Rueda
999 views20 slides
Presentació coordinació tic II by
Presentació coordinació tic IIPresentació coordinació tic II
Presentació coordinació tic IIimmavallse
285 views6 slides
abcTrader Bolsalia 2013 by
abcTrader Bolsalia 2013abcTrader Bolsalia 2013
abcTrader Bolsalia 2013Jose Manuel Garcia Suarez
445 views21 slides
La meva selecció Fotofilosofia 2013 by
La meva selecció Fotofilosofia 2013La meva selecció Fotofilosofia 2013
La meva selecció Fotofilosofia 2013jbeltran
5.1K views56 slides
LA County HIV Public Health Fellowship Program Application Form by
LA County HIV Public Health Fellowship Program Application FormLA County HIV Public Health Fellowship Program Application Form
LA County HIV Public Health Fellowship Program Application FormEric Olander
679 views2 slides

Viewers also liked(20)

Catálogo de servicios para la administración pública by PROQUAME
Catálogo de servicios para la administración públicaCatálogo de servicios para la administración pública
Catálogo de servicios para la administración pública
PROQUAME656 views
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso... by Juez Luis Rueda
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...
Luis Roberto Rueda, El postergado debate sobre la tenencia de drogas para uso...
Juez Luis Rueda999 views
Presentació coordinació tic II by immavallse
Presentació coordinació tic IIPresentació coordinació tic II
Presentació coordinació tic II
immavallse285 views
La meva selecció Fotofilosofia 2013 by jbeltran
La meva selecció Fotofilosofia 2013La meva selecció Fotofilosofia 2013
La meva selecció Fotofilosofia 2013
jbeltran5.1K views
LA County HIV Public Health Fellowship Program Application Form by Eric Olander
LA County HIV Public Health Fellowship Program Application FormLA County HIV Public Health Fellowship Program Application Form
LA County HIV Public Health Fellowship Program Application Form
Eric Olander679 views
Cornualles by JimmyP
CornuallesCornualles
Cornualles
JimmyP486 views
Riesgos y amenazas de la informacion. by Juan C Luna D
Riesgos y amenazas de la informacion.Riesgos y amenazas de la informacion.
Riesgos y amenazas de la informacion.
Juan C Luna D350 views
Effizienz auf Knopfdruck by d.velop AG
Effizienz auf KnopfdruckEffizienz auf Knopfdruck
Effizienz auf Knopfdruck
d.velop AG687 views
Diada Nacional - 11 Setembre 1714/2014 by Miqui Mel
Diada Nacional - 11 Setembre 1714/2014Diada Nacional - 11 Setembre 1714/2014
Diada Nacional - 11 Setembre 1714/2014
Miqui Mel764 views
Chapter 5 by kscheidy
Chapter 5Chapter 5
Chapter 5
kscheidy3.1K views
Fundamentos sentencia 7530 by Gabriel Conte
Fundamentos sentencia 7530 Fundamentos sentencia 7530
Fundamentos sentencia 7530
Gabriel Conte1.1K views
Manuscrito discapacidad auditiva by brendaj2
Manuscrito discapacidad auditivaManuscrito discapacidad auditiva
Manuscrito discapacidad auditiva
brendaj22.9K views
Presentacion de derecho romano 15082015 by solodiossalva
Presentacion de derecho romano 15082015Presentacion de derecho romano 15082015
Presentacion de derecho romano 15082015
solodiossalva452 views
Manguito rotador st naples 2009 (ph) by drnaula
Manguito rotador  st naples 2009 (ph)Manguito rotador  st naples 2009 (ph)
Manguito rotador st naples 2009 (ph)
drnaula2.7K views
SEO Attribution for Dummies - Webmarketing123 webinar slides by DemandWave
SEO Attribution for Dummies - Webmarketing123 webinar slidesSEO Attribution for Dummies - Webmarketing123 webinar slides
SEO Attribution for Dummies - Webmarketing123 webinar slides
DemandWave1.5K views

Similar to Introduction to Scala

Scala - Java2Days Sofia by
Scala - Java2Days SofiaScala - Java2Days Sofia
Scala - Java2Days SofiaManuel Bernhardt
3K views61 slides
Workshop Scala by
Workshop ScalaWorkshop Scala
Workshop ScalaBert Van Vreckem
1.4K views116 slides
Intro to scala by
Intro to scalaIntro to scala
Intro to scalaJoe Zulli
330 views17 slides
1.1 motivation by
1.1 motivation1.1 motivation
1.1 motivationwpgreenway
177 views12 slides
Scala introduction by
Scala introductionScala introduction
Scala introductionMohan Rao Pusarla
588 views29 slides
Scala for Java Developers (Silicon Valley Code Camp 13) by
Scala for Java Developers (Silicon Valley Code Camp 13)Scala for Java Developers (Silicon Valley Code Camp 13)
Scala for Java Developers (Silicon Valley Code Camp 13)Ramnivas Laddad
9.6K views58 slides

Similar to Introduction to Scala(20)

Intro to scala by Joe Zulli
Intro to scalaIntro to scala
Intro to scala
Joe Zulli330 views
1.1 motivation by wpgreenway
1.1 motivation1.1 motivation
1.1 motivation
wpgreenway177 views
Scala for Java Developers (Silicon Valley Code Camp 13) by Ramnivas Laddad
Scala for Java Developers (Silicon Valley Code Camp 13)Scala for Java Developers (Silicon Valley Code Camp 13)
Scala for Java Developers (Silicon Valley Code Camp 13)
Ramnivas Laddad9.6K views
Scala uma poderosa linguagem para a jvm by Isaias Barroso
Scala   uma poderosa linguagem para a jvmScala   uma poderosa linguagem para a jvm
Scala uma poderosa linguagem para a jvm
Isaias Barroso1.8K views
BCS SPA 2010 - An Introduction to Scala for Java Developers by Miles Sabin
BCS SPA 2010 - An Introduction to Scala for Java DevelopersBCS SPA 2010 - An Introduction to Scala for Java Developers
BCS SPA 2010 - An Introduction to Scala for Java Developers
Miles Sabin682 views
An Introduction to Scala for Java Developers by Miles Sabin
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
Miles Sabin1.5K views
Scala overview by Steve Min
Scala overviewScala overview
Scala overview
Steve Min3.7K views

More from Manuel Bernhardt

Is there anybody out there? Reactive Systems Hamburg by
Is there anybody out there? Reactive Systems HamburgIs there anybody out there? Reactive Systems Hamburg
Is there anybody out there? Reactive Systems HamburgManuel Bernhardt
339 views75 slides
Is there anybody out there? Scala Days Berlin 2018 by
Is there anybody out there? Scala Days Berlin 2018Is there anybody out there? Scala Days Berlin 2018
Is there anybody out there? Scala Days Berlin 2018Manuel Bernhardt
427 views74 slides
Is there anybody out there? by
Is there anybody out there?Is there anybody out there?
Is there anybody out there?Manuel Bernhardt
340 views62 slides
Is there anybody out there? by
Is there anybody out there?Is there anybody out there?
Is there anybody out there?Manuel Bernhardt
447 views67 slides
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017 by
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 20178 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017Manuel Bernhardt
1.2K views69 slides
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware of by
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware ofScala Days Copenhagen - 8 Akka anti-patterns you'd better be aware of
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware ofManuel Bernhardt
3.6K views67 slides

More from Manuel Bernhardt(18)

Is there anybody out there? Reactive Systems Hamburg by Manuel Bernhardt
Is there anybody out there? Reactive Systems HamburgIs there anybody out there? Reactive Systems Hamburg
Is there anybody out there? Reactive Systems Hamburg
Manuel Bernhardt339 views
Is there anybody out there? Scala Days Berlin 2018 by Manuel Bernhardt
Is there anybody out there? Scala Days Berlin 2018Is there anybody out there? Scala Days Berlin 2018
Is there anybody out there? Scala Days Berlin 2018
Manuel Bernhardt427 views
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017 by Manuel Bernhardt
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 20178 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017
8 akka anti-patterns you'd better be aware of - Reactive Summit Austin 2017
Manuel Bernhardt1.2K views
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware of by Manuel Bernhardt
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware ofScala Days Copenhagen - 8 Akka anti-patterns you'd better be aware of
Scala Days Copenhagen - 8 Akka anti-patterns you'd better be aware of
Manuel Bernhardt3.6K views
8 Akka anti-patterns you'd better be aware of by Manuel Bernhardt
8 Akka anti-patterns you'd better be aware of8 Akka anti-patterns you'd better be aware of
8 Akka anti-patterns you'd better be aware of
Manuel Bernhardt4.4K views
Beyond the buzzword: a reactive web-appliction in practice by Manuel Bernhardt
Beyond the buzzword: a reactive web-appliction in practiceBeyond the buzzword: a reactive web-appliction in practice
Beyond the buzzword: a reactive web-appliction in practice
Manuel Bernhardt613 views
Beyond the Buzzword - a reactive application in practice by Manuel Bernhardt
Beyond the Buzzword - a reactive application in practiceBeyond the Buzzword - a reactive application in practice
Beyond the Buzzword - a reactive application in practice
Manuel Bernhardt492 views
3 things you must know to think reactive - Geecon Kraków 2015 by Manuel Bernhardt
3 things you must know to think reactive - Geecon Kraków 20153 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 2015
Manuel Bernhardt4.2K views
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM by Manuel Bernhardt
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Manuel Bernhardt1.4K views
Back to the futures, actors and pipes: using Akka for large-scale data migration by Manuel Bernhardt
Back to the futures, actors and pipes: using Akka for large-scale data migrationBack to the futures, actors and pipes: using Akka for large-scale data migration
Back to the futures, actors and pipes: using Akka for large-scale data migration
Manuel Bernhardt13K views
Project Phoenix - From PHP to the Play Framework in 3 months by Manuel Bernhardt
Project Phoenix - From PHP to the Play Framework in 3 monthsProject Phoenix - From PHP to the Play Framework in 3 months
Project Phoenix - From PHP to the Play Framework in 3 months
Manuel Bernhardt2.6K views
Tips and tricks for setting up a Play 2 project by Manuel Bernhardt
Tips and tricks for setting up a Play 2 projectTips and tricks for setting up a Play 2 project
Tips and tricks for setting up a Play 2 project
Manuel Bernhardt5.4K views

Recently uploaded

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...Bernd Ruecker
50 views69 slides
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineShapeBlue
154 views19 slides
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...The Digital Insurer
40 views52 slides
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
130 views29 slides
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...ShapeBlue
128 views20 slides
DRBD Deep Dive - Philipp Reisner - LINBIT by
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBITShapeBlue
110 views21 slides

Recently uploaded(20)

iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online by ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue154 views
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... by The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc130 views
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or... by ShapeBlue
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
Zero to Cloud Hero: Crafting a Private Cloud from Scratch with XCP-ng, Xen Or...
ShapeBlue128 views
DRBD Deep Dive - Philipp Reisner - LINBIT by ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue110 views
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue75 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... by ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue121 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue191 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Digital Personal Data Protection (DPDP) Practical Approach For CISOs by Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash103 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue97 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue114 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE67 views
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue by ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue149 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue134 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue by ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue68 views
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit... by ShapeBlue
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
Transitioning from VMware vCloud to Apache CloudStack: A Path to Profitabilit...
ShapeBlue86 views

Introduction to Scala

  • 2. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice • Tools & more
  • 3. @elmanu Java Klassentreffen 2013 - javatraining.at YOUR SPEAKER • Independent software consultant • Web, web, web • Java & Scala & Javascript • Open-Source • Delving
  • 4. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice • Tools & more
  • 5. @elmanu Java Klassentreffen 2013 - javatraining.at HISTORY • Martin Odersky, EPFL • Espresso, Pizza, GJ, Javac • Funnel, Scala • First Scala release in 2003
  • 6. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice
  • 7. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS
  • 8. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS • Full interoperability with Java
  • 9. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS • Full interoperability with Java • Cut down boilerplate
  • 10. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS • Full interoperability with Java • Cut down boilerplate • Pure object orientation & functional programming
  • 11. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS • Full interoperability with Java • Cut down boilerplate • Pure object orientation & functional programming • Move away from null
  • 12. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA DESIGN GOALS • Full interoperability with Java • Cut down boilerplate • Pure object orientation & functional programming • Move away from null • Multi-core programming
  • 13. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice • Tools & more
  • 14. @elmanu Java Klassentreffen 2013 - javatraining.at WHAT PEOPLE SAY If I were to pick a language today other than Java, it would be Scala. James Gosling Father of Java
  • 15. @elmanu Java Klassentreffen 2013 - javatraining.at WHAT PEOPLE SAY I can honestly say if someone had shown me the Programming Scala book by Martin Odersky, Lex Spoon & Bill Venners back in 2003 I’d probably have never created Groovy. James Strachan Creator of Groovy
  • 16. @elmanu Java Klassentreffen 2013 - javatraining.at ThoughtWorksTechRadar May 2013 http://www.thoughtworks.com/radar
  • 17. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA INTHE WILD
  • 18. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA INTHE WILD etc.
  • 19. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA INVIENNA • openForce - http://openforce.com • x-tradesoft - http://xtradesoft.com • Delving - http://www.delving.eu • dimocom - http://www.dimocom.com • emarsys - http://www.emarsys.com • Miavia - https://miavia.in
  • 20. @elmanu Java Klassentreffen 2013 - javatraining.at SCALA INVIENNA • ScalaVienna User Group • http://scala-vienna.org/ Next meeting: 26th September 6 PM - Sektor 5
  • 21. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice • Tools & more
  • 22. @elmanu Java Klassentreffen 2013 - javatraining.at AVOIDINGTHE BILLION- DOLLAR MISTAKE But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement Tony Hoare Creator of ALGOL
  • 23. @elmanu Java Klassentreffen 2013 - javatraining.at AVOIDINGTHE BILLION- DOLLAR MISTAKE val maybeUser: Option[User] = User.findOneByName("bob") // returns Some[User] maybeUser == None // false maybeUser.foreach { user => println(user.fullName) // prints "Bob Marley" if there is a user! } val name = maybeUser.map(_.name).getOrElse("Unknown user")
  • 24. @elmanu Java Klassentreffen 2013 - javatraining.at CONCISENESS public class User { ! private String name; ! private String surname; ! private String email; ! public User(String name, String surname, String email) { ! ! this.name = name; ! ! this.surname = surname; ! ! this.email = email; ! } ! public void setName(String name) { ! ! this.name = name; ! } ! public void setSurname(String surname) { ! ! this.surname = surname; ! } ! public void setEmail(String email) { ! ! this.email = email ! } ! public String getName() { ! ! return this.name; ! } ! public String getSurname() { ! ! return this.surname; ! } ! public String getEmail() { ! ! return this.surname; ! } }
  • 25. @elmanu Java Klassentreffen 2013 - javatraining.at CONCISENESS class User( var name: String, var surname: String, var email: String) val bob = new User("Bob", "Marley", "bob@marley.org") // bob: User = User@5c3f1224 bob.name // res0: String = Bob bob.name = "Bobby" // bob.name: String = Bobby
  • 26. @elmanu Java Klassentreffen 2013 - javatraining.at CONCISENESS public class ImmutableUser { ! private final String name; ! private final String surname; ! private final String email; ! public ImmutableUser(String name, String surname, String email) { ! ! this.name = name; ! ! this.surname = surname; ! ! this.email = email; ! } ! public String getName() { ! ! return this.name; ! } ! public String getSurname() { ! ! return this.surname; ! } ! public String getEmail() { ! ! return this.surname; ! } ! @Override public int hashCode() { ! ! // yada yada yada ! } ! @Override public boolean equals(Object that) { ! ! // yada yada yada ! } }
  • 27. @elmanu Java Klassentreffen 2013 - javatraining.at CONCISENESS case class ImmutableUser( name: String, surname: String, email: String) val bob = ImmutableUser("Bob", "Marley", "bob@marley.org") // hashcode and equals for free! val namedBob = ImmutableUser(name = "Bob", surname = "Marley", email = "email") val bobby = bob.copy(name = "Bobby") // returns a User with name Bobby bob.toString // res0: String = ImmutableUser(Bob,Marley,email)
  • 28. @elmanu Java Klassentreffen 2013 - javatraining.at USEFULTYPE INFERENCE val foo = "Bar" // foo: String = Bar val answer = 42 // answer: Int = 42 val price = 9.99 // price: Double = 9.99 val nums = List(1, 2, 3) // nums: List[Int] = List(1, 2, 3) val map = Map("abc" -> List(1, 2, 3)) // map: scala.collection.immutable.Map[String,List[Int]] = Map(abc -> List(1, 2, 3))
  • 29. @elmanu Java Klassentreffen 2013 - javatraining.at EXPLICITTYPING val foo: String = "Bar" // foo: String = Bar val answer: Int = 42 // answer: Int = 42 val price: Double = 9.99 // price: Double = 9.99 val nums: List[Int] = List(1, 2, 3) // nums: List[Int] = List(1, 2, 3) val map: Map[String, List[Int]] = Map("abc" -> List(1, 2, 3)) // map: scala.collection.immutable.Map[String,List[Int]] = Map(abc -> List(1, 2, 3))
  • 30. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE users.sort(new Comparator { public int compare(Object user1, Object user2) { ! int userAge1 = ((User) user1).getAge(); ! int userAge2 = ((User) user2).getAge(); ! if (userAge1 > userAge2) { ! ! return 1; ! } else if userAge1 < userAge2) { ! ! ! return -1; ! ! } else { ! ! ! return 0; ! ! } ! } });
  • 31. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE def sortByAge(user1: User, user2: User) = user1.age > user2.age users.sortWith(sortByAge)
  • 32. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE users.sortWith((user1, user2) => user1.age > user2.age)
  • 33. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE users.sortWith(_.age > _.age)
  • 34. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE List<User> minors = new ArrayList<User>(); List<User> majors = new ArrayList<User>(); for (User u : users) { ! if (u.getAge() < 18) { ! ! minors.add(u); ! } else { ! ! majors.add(u); ! } }
  • 35. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE val (minors, majors) = users.partition(_.age < 18)
  • 36. @elmanu Java Klassentreffen 2013 - javatraining.at COLLECTION LIBRARY & FUNCTIONAL STYLE val minors = users.filter(_.age < 18)
  • 37. @elmanu Java Klassentreffen 2013 - javatraining.at • Minimal language, powerful library • Language features for extensibility EXTENSIBLE LANGUAGE
  • 38. @elmanu Java Klassentreffen 2013 - javatraining.at DOMAIN SPECIFIC LANGUAGES import collection.mutable.Stack import org.scalatest._ class ExampleSpec extends FlatSpec with Matchers { "A Stack" should "pop values in last-in-first-out order" in { val stack = new Stack[Int] stack.push(1) stack.push(2) stack.pop() should be (2) stack.pop() should be (1) } it should "throw NoSuchElementException if an empty stack is popped" in { val emptyStack = new Stack[Int] a [NoSuchElementException] should be thrownBy { emptyStack.pop() } } }
  • 39. @elmanu Java Klassentreffen 2013 - javatraining.at MACROS PLAY JSON DE/SERIALIZATION
  • 40. @elmanu Java Klassentreffen 2013 - javatraining.at MACROS PLAY JSON DE/SERIALIZATION case class Creature(name: String, isDead: Boolean, weight: Float) implicit val creatureReads: Reads[Creature] = ( (__ "name").read[String] and (__ "isDead").read[Boolean] and (__ "weight").read[Float] )(Creature) implicit val creatureWrites: Writes[Creature] = ( (__ "name").write[String] and (__ "isDead").write[Boolean] and (__ "weight").write[Float] )(unlift(Creature.unapply))
  • 41. @elmanu Java Klassentreffen 2013 - javatraining.at MACROS PLAY JSON DE/SERIALIZATION import play.api.json._ implicit val creatureFormat = Json.format[Creature] // format is a macro
  • 42. @elmanu Java Klassentreffen 2013 - javatraining.at AGENDA • History • Why Scala? • Scala in the wild • The Code / Scala in practice • Tools & more
  • 43. @elmanu Java Klassentreffen 2013 - javatraining.at IDE • IntelliJ IDEA • Eclipse • SublimeText
  • 44. @elmanu Java Klassentreffen 2013 - javatraining.at SIMPLE BUILDTOOL name := "My Project" version := "1.0" organization := "org.myproject" libraryDependencies += "org.scala-tools.testing" %% "scalacheck" % "1.8" % "test" libraryDependencies ++= Seq( "net.databinder" %% "dispatch-meetup" % "0.7.8", "net.databinder" %% "dispatch-twitter" % "0.7.8" ) javaOptions += "-Xmx256m" logLevel in compile := Level.Warn
  • 45. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS:AKKA • Actor concurrency model based on Erlang • “Human” design: actors talk to eachother and form hierarchies • Much, much, much simpler to work and reason with than threads
  • 46. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS:AKKA Source: http://prabhubuzz.wordpress.com/2012/09/28/akka-really-mountains-of-concurrency/
  • 47. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS:AKKA class Master extends Actor { ! val workers = context.actorOf(Props[Worker].withRouter( ! RoundRobinRouter(nrOfInstances = 5)) ! ) ! def receive = { ! ! case Start => ! ! ! getDocumentsFromDb.foreach { document => ! ! ! ! workers ! Process(document) ! ! ! } ! ! case Result(processed) => writeResult(processed) ! ! case Stop => children.foreach(stop) ! } }
  • 48. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS:AKKA class Worker extends Actor { ! def receive = { ! ! case Process(doc: Document) => ! ! ! val processed = doSomeHardWork(doc) ! ! ! sender ! Result(processed) ! } }
  • 49. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS: PLAY • MVC framework à la Rails • Real-time web, streams (WebSocket, ...) • Everything is compiled • I mean everything: CSS, JavaScripts,Templates, URLs, JSON, ...
  • 50. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS: PLAY GET /users controllers.Users.list POST /users controllers.Users.create PUT /users/:id/update controllers.Users.update(id: Long) DELETE /users/:id controllers.Users.delete(id: Long)
  • 51. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS: PLAY class Users extends Controller { def list = Action { request => val users = User.findAll Ok(Json.toJson(users)) } }
  • 52. @elmanu Java Klassentreffen 2013 - javatraining.at FRAMEWORKS: PLAY class Users extends Controller { def list = Action { request => val users = User.findAll Ok(Json.toJson(users)) } } 200 OK Content-Type: application/json
  • 53. @elmanu Java Klassentreffen 2013 - javatraining.at THANKYOU! • Questions, comments ? • http://logician.eu • manuel@bernhardt.io • @elmanu