SlideShare a Scribd company logo
Reactive Web Applications
using Scala & Liftweb
Andrea Zanda
CTO & Co-founder
andrea.zanda@guidemeright.com
Riccardo Sirigu
Full Stack Dev
riccardo.sirigu@guidemeright.com
DONA ANCHE TU su Rete del Dono
#sardiniacodeweek
http://www.retedeldono.it/it/progetti/sardegna-
2050/sardinia-code-week-2015
www.guidemeright.com
Current touristic offer lacks of authenticity
There is a whole heritage of local and authentic socio-
cultural activities and experiences
Opportunity
www.guidemeright.com
www.guidemeright.com
LOCAL FRIENDGUEST
A Community Marketplace where to discover and book authentic
local experiences with a Local Friend, a local person who can earn by
sharing his local knowledge and lifestyle
www.guidemeright.com
Guest
www.guidemeright.com
• +1.5K Activities
Where are we now?
• 15 Italian Regions
• +300 active Local Friend
• +500 Experiences Booked
• € 200K of Seed Money
Which is the tech
challenge?
Reactive Manifesto
● The techniques and technologies
traditionally used in a class of
Reactive and Interactive Systems
is gaining quite a bit of attention
from the mainstream developers
community
● Recently, the Reactive Manifesto
was defined to summarise the key
traits of “Reactive Applications”
Reactive Manifesto
● Responsive: Timely react to stimuli
● Event-Driven: modular, asynchronous
● Resilent: Tolerate failures functionally
and ideally temporally
● Scalable: Gracefully scale up and
down depending on load demands
https://github.com/zaza81/lift-codeweek
@MarioBot
/codeweek banana luca
gmr-codeweek.cloudapp.net
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Scala
● Functional (style) programming
● Everything is an Object
● Run on JVM
● Practical expressivity
○ Expressive Power
○ List(1,2,3,4).map(x => x + 1)
○ What vs How
● N(Bugs) ∝ N(LOC)
○ Fewer LOC fewer bugs
○ Halstead complexity measures
Scala vs Java
● Every operator is a method call
○ 12 + 4 (12).+(4)
○ “#name” #> “david”
○ “codeWeek” indexOf “w”
● Object Equality
○ List(56,13,75) == List(56,13,75)
● Optional Types
○ NullPointerException
○ val secret: Option[String] = Some(“zbmdfbmknnaprzvds=”)
○ val secret: Option[String] = None
Scala vs Java
● Immutable data structures
scala> val even = List(2,4)
scala> 6 :: 8 :: even
res0: List[Int] = List(6,8,2,4)
● Type inference
scala> Map('a' -> 1, 'b' -> 2)
res2: scala.collection.immutable.Map[Char,Int] = Map(a -> 1, b -> 2)
Scala vs Java
class User(val email: String)
class User{
private String email;
public User(String email){
this.email = email
}
public String getEmail(){
return email;
}
}
Scala (1st class) Functions
var botMe = (name: String) => “@” + name + ”Bot”
botMe: String => String = <function1>
val names = “Riccardo” :: “Andrea” :: “Mario” :: Nil
names: List[String] = List(Riccardo, Andrea, Mario)
names.map(botMe)
res0: List[String] = List(@RiccardoBot, @AndreaBot, @MarioBot)
Objects Everywhere
Functions are Objects
(x: Int) => x * x * x
..is expanded to..
new Function1[Int, Int] {
def apply(x: Int) = x * x * x
}
Objects Everywhere
val f = (x: Int) => x * x * x
f(2)
val f = new Function1[Int, Int] {
def apply(x: Int) = x * x * x
}
f.apply(2)
Companion Objects
Companion Objects
• Same name & same source file as the class
class User extends MegaProtoUser[User] {
def getSingleton = User // reference to the companion object below
def allAccounts : List[Account] =
Account.findAll(By(Account.owner, this.id))
}
​
// Create a "companion object" to the User class (above).
// The companion object is a "singleton" object that shares the same
// name as its companion class.
object User extends User with MetaMegaProtoUser[User] {
override def dbTableName = "users"
}
Pattern Matching
• Switch case on steroids
User.findById(“000001”) match {
case Some(user) => println(user.name)
case Empty => println(“No User Found!”)
}
Scala Actors
Scala Actors
● Manual threading and locking is difficult Actor abstraction
● Concurrent processes that communicate by exchanging messages
● Actor encapsulates both state and behavior
● Fire&Forget
chatserver ! msg
Actor Model
LIFT me up
Introducing Lift
Why?
● Based on Scala
● Comet and Ajax, js abstractions
● Designer friendly templates View First
● Security
○ injections, XSS, CSRF...
○ OWASP Top 10
http://seventhings.liftweb.net/
http://lift.la/blog/lift-state-and-scaling
Reactive Web Applications with Scala & Liftweb - CodeWeek 2015
Setting the environment
+
MVVM in concrete
View Model
HTML page Scala Class (ORM)
Snippet
(MV)
CSS Selectors
“#id_element” #> <p> Element Content</p>
SHtml
“#id_text” #> SHtml.text(“text”, textVar = _) &
“#id_submit” #> SHtml.submit(“Submit”, processResult())
def processResult(): JsCmd = {
//do something
S.notice(“Work Done”)
}
Comet Actors
Comet
• Server Push
• Real time event-based systems
• Thread per request, long polling
Comet
One thread per request leads to…….. SCALABILITY ISSUES
Web container request suspension or continuation
Demo Time
follow up:
andrea.zanda@guidemeright.com
riccardo.sirigu@guidemeright.com
DONA ANCHE TU su Rete del Dono
#sardiniacodeweek
http://www.retedeldono.it/it/progetti/sardegna-
2050/sardinia-code-week-2015

More Related Content

PDF
Programming Android Application in Scala.
ODP
Introduction To Scala
PPT
JavaScript Data Types
PDF
JavaScript objects and functions
PDF
Scala jargon cheatsheet
PPTX
Functions and Objects in JavaScript
PDF
Scala - core features
PDF
Scala cheatsheet
Programming Android Application in Scala.
Introduction To Scala
JavaScript Data Types
JavaScript objects and functions
Scala jargon cheatsheet
Functions and Objects in JavaScript
Scala - core features
Scala cheatsheet

What's hot (19)

PDF
Few simple-type-tricks in scala
PPT
Scala uma poderosa linguagem para a jvm
PDF
An Introduction to Scala for Java Developers
PDF
javascript objects
PPTX
All about scala
PDF
Solid and Sustainable Development in Scala
PPTX
Scala on Android
PDF
Scaladroids: Developing Android Apps with Scala
PDF
JavaScript Foundations Day1
PPTX
JavaScript Basics - GameCraft Training
PDF
scala
PDF
Railroading into Scala
PDF
Starting with Scala : Frontier Developer's Meetup December 2010
PDF
JavaScript Objects
PDF
Introduction to Scala for JCConf Taiwan
PDF
Workshop Scala
PDF
Scala vs java 8
PPTX
PDF
Few simple-type-tricks in scala
Scala uma poderosa linguagem para a jvm
An Introduction to Scala for Java Developers
javascript objects
All about scala
Solid and Sustainable Development in Scala
Scala on Android
Scaladroids: Developing Android Apps with Scala
JavaScript Foundations Day1
JavaScript Basics - GameCraft Training
scala
Railroading into Scala
Starting with Scala : Frontier Developer's Meetup December 2010
JavaScript Objects
Introduction to Scala for JCConf Taiwan
Workshop Scala
Scala vs java 8
Ad

Similar to Reactive Web Applications with Scala & Liftweb - CodeWeek 2015 (20)

PDF
From polling to real time: Scala, Akka, and Websockets from scratch
PDF
Andrea Lattuada, Gabriele Petronella - Building startups on Scala
PDF
Reactive Web-Applications @ LambdaDays
PDF
The Scala Programming Language
PPTX
Scale up your thinking
PDF
Scala In The Wild
PDF
Web without framework
PDF
Play Framework and Activator
PDF
A Brief Introduction to Scala for Java Developers
PDF
Miles Sabin Introduction To Scala For Java Developers
PPTX
How and why we evolved a legacy Java web application to Scala... and we are s...
PDF
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
PPTX
Scala, Play 2.0 & Cloud Foundry
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
PDF
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
PPTX
Taxonomy of Scala
PDF
Meet scala
PDF
BCS SPA 2010 - An Introduction to Scala for Java Developers
From polling to real time: Scala, Akka, and Websockets from scratch
Andrea Lattuada, Gabriele Petronella - Building startups on Scala
Reactive Web-Applications @ LambdaDays
The Scala Programming Language
Scale up your thinking
Scala In The Wild
Web without framework
Play Framework and Activator
A Brief Introduction to Scala for Java Developers
Miles Sabin Introduction To Scala For Java Developers
How and why we evolved a legacy Java web application to Scala... and we are s...
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Scala, Play 2.0 & Cloud Foundry
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Taxonomy of Scala
Meet scala
BCS SPA 2010 - An Introduction to Scala for Java Developers
Ad

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPT
Teaching material agriculture food technology
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Sensors and Actuators in IoT Systems using pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Transforming Manufacturing operations through Intelligent Integrations
Advanced Soft Computing BINUS July 2025.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
NewMind AI Monthly Chronicles - July 2025
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Sensors and Actuators in IoT Systems using pdf

Reactive Web Applications with Scala & Liftweb - CodeWeek 2015

  • 1. Reactive Web Applications using Scala & Liftweb Andrea Zanda CTO & Co-founder [email protected] Riccardo Sirigu Full Stack Dev [email protected]
  • 2. DONA ANCHE TU su Rete del Dono #sardiniacodeweek http://www.retedeldono.it/it/progetti/sardegna- 2050/sardinia-code-week-2015
  • 3. www.guidemeright.com Current touristic offer lacks of authenticity There is a whole heritage of local and authentic socio- cultural activities and experiences Opportunity
  • 5. www.guidemeright.com LOCAL FRIENDGUEST A Community Marketplace where to discover and book authentic local experiences with a Local Friend, a local person who can earn by sharing his local knowledge and lifestyle
  • 7. www.guidemeright.com • +1.5K Activities Where are we now? • 15 Italian Regions • +300 active Local Friend • +500 Experiences Booked • € 200K of Seed Money
  • 8. Which is the tech challenge?
  • 9. Reactive Manifesto ● The techniques and technologies traditionally used in a class of Reactive and Interactive Systems is gaining quite a bit of attention from the mainstream developers community ● Recently, the Reactive Manifesto was defined to summarise the key traits of “Reactive Applications”
  • 10. Reactive Manifesto ● Responsive: Timely react to stimuli ● Event-Driven: modular, asynchronous ● Resilent: Tolerate failures functionally and ideally temporally ● Scalable: Gracefully scale up and down depending on load demands
  • 14. Scala ● Functional (style) programming ● Everything is an Object ● Run on JVM ● Practical expressivity ○ Expressive Power ○ List(1,2,3,4).map(x => x + 1) ○ What vs How ● N(Bugs) ∝ N(LOC) ○ Fewer LOC fewer bugs ○ Halstead complexity measures
  • 15. Scala vs Java ● Every operator is a method call ○ 12 + 4 (12).+(4) ○ “#name” #> “david” ○ “codeWeek” indexOf “w” ● Object Equality ○ List(56,13,75) == List(56,13,75) ● Optional Types ○ NullPointerException ○ val secret: Option[String] = Some(“zbmdfbmknnaprzvds=”) ○ val secret: Option[String] = None
  • 16. Scala vs Java ● Immutable data structures scala> val even = List(2,4) scala> 6 :: 8 :: even res0: List[Int] = List(6,8,2,4) ● Type inference scala> Map('a' -> 1, 'b' -> 2) res2: scala.collection.immutable.Map[Char,Int] = Map(a -> 1, b -> 2)
  • 17. Scala vs Java class User(val email: String) class User{ private String email; public User(String email){ this.email = email } public String getEmail(){ return email; } }
  • 18. Scala (1st class) Functions var botMe = (name: String) => “@” + name + ”Bot” botMe: String => String = <function1> val names = “Riccardo” :: “Andrea” :: “Mario” :: Nil names: List[String] = List(Riccardo, Andrea, Mario) names.map(botMe) res0: List[String] = List(@RiccardoBot, @AndreaBot, @MarioBot)
  • 19. Objects Everywhere Functions are Objects (x: Int) => x * x * x ..is expanded to.. new Function1[Int, Int] { def apply(x: Int) = x * x * x }
  • 20. Objects Everywhere val f = (x: Int) => x * x * x f(2) val f = new Function1[Int, Int] { def apply(x: Int) = x * x * x } f.apply(2)
  • 22. Companion Objects • Same name & same source file as the class class User extends MegaProtoUser[User] { def getSingleton = User // reference to the companion object below def allAccounts : List[Account] = Account.findAll(By(Account.owner, this.id)) } ​ // Create a "companion object" to the User class (above). // The companion object is a "singleton" object that shares the same // name as its companion class. object User extends User with MetaMegaProtoUser[User] { override def dbTableName = "users" }
  • 23. Pattern Matching • Switch case on steroids User.findById(“000001”) match { case Some(user) => println(user.name) case Empty => println(“No User Found!”) }
  • 25. Scala Actors ● Manual threading and locking is difficult Actor abstraction ● Concurrent processes that communicate by exchanging messages ● Actor encapsulates both state and behavior ● Fire&Forget chatserver ! msg Actor Model
  • 27. Introducing Lift Why? ● Based on Scala ● Comet and Ajax, js abstractions ● Designer friendly templates View First ● Security ○ injections, XSS, CSRF... ○ OWASP Top 10 http://seventhings.liftweb.net/ http://lift.la/blog/lift-state-and-scaling
  • 30. MVVM in concrete View Model HTML page Scala Class (ORM) Snippet (MV)
  • 31. CSS Selectors “#id_element” #> <p> Element Content</p>
  • 32. SHtml “#id_text” #> SHtml.text(“text”, textVar = _) & “#id_submit” #> SHtml.submit(“Submit”, processResult()) def processResult(): JsCmd = { //do something S.notice(“Work Done”) }
  • 34. Comet • Server Push • Real time event-based systems • Thread per request, long polling
  • 35. Comet One thread per request leads to…….. SCALABILITY ISSUES Web container request suspension or continuation
  • 38. DONA ANCHE TU su Rete del Dono #sardiniacodeweek http://www.retedeldono.it/it/progetti/sardegna- 2050/sardinia-code-week-2015