SlideShare a Scribd company logo
Full Stack Scala
Scala in the backend and frontend!
Ramnivas Laddad
Founder, Paya Labs
@ramnivas
@ramnivas
• Spring framework and Cloud Foundry
contributor
• Main interests
• Scala and functional programming
• Cloud computing
• Author of books and articles
• AspectJ in Action (1st and 2nd edition)
• Speaker at many professional conferences
• JavaOne, ScalaDays, JavaPolis, SpringOne, Software
Development, No Fluff Just Stuff, OSCON etc.
A Quick Demo
High-level Architecture
API Server Static Page Server
html, js, css,
…
GET, PUT, POST,
DELETE
{
"name" : ...
}
Backend Stack
API Server
API Server Static Page Server
html, js, css,
…
GET, PUT, POST,
DELETE
{
"name" : ...
}
API Server
API Server Static Page Server
html, js, css,
…
GET, PUT, POST,
DELETE
{
"name" : ...
}
Backend Structure
Backend Structure
Database
Backend Structure
DatabaseSendgrid
Backend Structure
DatabaseSendgridS3
Backend Structure
DatabaseSendgridS3
Backend Structure
DatabaseSendgridS3
Backend Structure
DatabaseSendgridS3
Backend Structure
Database
Data Access Layer
SendgridS3
Backend Structure
Database
Data Access Layer
SendgridS3
Talk by Rob Norris
Programs asValues: JDBC Programming with Doobie
Backend Structure
Database
Data Access Layer
SendgridS3
Backend Structure
Database
Data Access Layer
SendgridS3
Apache
Commons
Backend Structure
Database
Data Access Layer
SendgridS3
Apache
Commons
AWS
SDK
Backend Structure
Database
Data Access Layer
Service Layer
SendgridS3
Apache
Commons
AWS
SDK
Backend Structure
Database
Data Access Layer
Service Layer
HTTP Layer
SendgridS3
Apache
Commons
AWS
SDK
Frontend Stack
High-level Architecture
Static Page Server
html, js, css,
…
API Server
GET, PUT, POST,
DELETE
{
"name" : ...
}
High-level Architecture
Static Page Server
html, js, css,
…
API Server
GET, PUT, POST,
DELETE
{
"name" : ...
}
Serving static contents
var express = require('express');
var fs = require('fs');
var app = express();
var port = process.env.PORT || 4000;
var devMode = process.env.SERVE_MODE != "SERVE_PROD";
var serveInfo = { dir: __dirname + ‘/dev-bin', maxAge: 0}
if (!devMode) {
var oneHour = 60*60*1000;
serveInfo = { dir: __dirname + ‘/prod-bin', maxAge: oneHour}
}
app.use(express.static(serveInfo.dir, { maxAge: serveInfo.maxAge }));
app.get('*', function(request, response, next) {
response.sendFile(serveInfo.dir + '/index.html');
});
app.listen(port, function() {
console.log("Started on " + port + " (dev mode = " + devMode + ")n");
});
High-level Architecture
API Server Static Page Server
html, js, css,
…
GET, PUT, POST,
DELETE
{
"name" : ...
}
High-level Architecture
API Server Static Page Server
html, js, css,
…
GET, PUT, POST,
DELETE
{
"name" : ...
}
Why Scala.js?
Why Scala.js?
Why Scala.js
Scala!
Why Scala.js
StaticTypes
Why Scala.js
Functional Programming
Why Scala.js
Isomorphism
Why Scala.js
Maturity!
Why Scala.js
Eco-system
UI Framework
Choosing a UI Framework
Choosing a UI Framework
Simple
Mental Model
Choosing a UI Framework
Simple
Mental Model
Immutable
Data
Choosing a UI Framework
Simple
Mental Model
Functional
programming
Immutable
Data
Choosing a UI Framework
Simple
Mental Model
Mobile
Functional
programming
Immutable
Data
Choosing a UI Framework
Simple
Mental Model
Mobile
Functional
programming
Immutable
Data
Isomorphism
Choosing a UI Framework
Simple
Mental Model
CommunityMobile
Functional
programming
Immutable
Data
Isomorphism
Choosing a UI Framework
Simple
Mental Model
CommunityMobile
Functional
programming
Immutable
Data
Isomorphism
What is React?
• “A JavaScript library for building user interfaces” by
Facebook
• Focuses just on the UI
• Uses virtual DOM
• One-way data-flow
Frontend Overview
Frontend Overview
Router
Frontend Overview
Router
Frontend Overview
Router Flux
Component
Frontend Overview
Router Flux
Component
Frontend Overview
Router
Store
Flux
Component
Frontend Overview
Router
Store
Flux
Component
Frontend Overview
Router
Store
Flux
Component
Rest Client
Frontend Overview
Router
Store
Flux
Component
Rest Client
Frontend Overview
Router
Store
Flux
Component
Rest Client
Frontend Overview
Router
Store
Flux
Component
Rest Client
Frontend Overview
ComponentRouter
Store
Flux
Component
Rest Client
Frontend Overview
ComponentRouter
Store
Flux
Component
Rest Client
Scala.js with React
• Statically-typed wrapper around React
• Fluent, builder API to create components
• Well-implemented router (v2)
scalajs-react
Simple Mental Model
View
PropertiesState
Composition
Composition
Composition
Composition
Composition
Real World Composition
Real World Composition
Real World Composition
Mostly Immutable
ComponentRouter
Store
Flux
Component
Rest Client
Taking advantage of immutability
def shouldComponentUpdate(scope: ScopeType,
nextProps: P,
nextState: S) = {
scope.props != nextProps ||
scope.state != nextState
}
Flux
Flux Component
object ArtistRegistrationWrapper extends
FluxComponent[String, ArtistEditDto](Seq(ArtistStore, InstrumentStore)) {
def onArtistChange(artist: ArtistEditDto): Unit = {
ArtistUpdated(artist).dispatch()
}
...
def element(props: String) = {
...
div(
ArtistRegistration(
ArtistRegistrationProps(
artist, allInstruments, onArtistChange,
onArtistCoverPhotoChange, onArtistProfilsePhotoChange)
)
)
}
}
Component
object ArtistRegistration extends
Component[ArtistRegistrationProps] {
def element(props: ArtistRegistrationProps): ReactTag = {
div(…)
}
}
Responding to events
override def receive = {
case ArtistUpdated(newValue) =>
artist = newValue
emitChange()
case ArtistSaved =>
save()
emitChange()
...
No sweat undo/redo
trait CompositionStore extends AbstractStore {
val compositionStack = new UndoStack[Composition]()
override def receive = {
case NewComposition =>
compositionStack.clear()
loaded()
case LoadComposition(c) =>
compositionStack.clear()
compositionStack.push(c)
loaded()
case UpdateComposition(c) =>
compositionStack.push(c)
emitChange()
case UndoComposition =>
compositionStack.undo()
emitChange()
case RedoComposition =>
compositionStack.redo()
emitChange()
...
}
Mobile: React Native
Mobile: React Native
https://facebook.github.io/react-native
Mobile: React Native
https://github.com/chandu0101/scalajs-react-native
https://facebook.github.io/react-native
Using external components
Bridging Native React Components
• Problem:
• You got to use components developed in the
wild
• Requires significant boilerplate to make it work
from scalajs-react
• Solution: Some macro magic!
Bridging Native React Components
• Problem:
• You got to use components developed in the
wild
• Requires significant boilerplate to make it work
from scalajs-react
• Solution: Some macro magic!
github.com/payalabs/scalajs-react-bridge
Example Bridge Component
case class TagsInput(id: js.UndefOr[String] = js.undefined,
className: js.UndefOr[String] = js.undefined,
ref: js.UndefOr[String] = js.undefined,
key: js.UndefOr[Any] = js.undefined,
defaultValue: js.UndefOr[Seq[String]] = js.undefined,
value: js.UndefOr[Array[String]] = js.undefined,
placeholder: js.UndefOr[String] = js.undefined,
onChange: js.UndefOr[js.Array[String] => Unit] = js.undefined,
validate: js.UndefOr[String => Boolean] = js.undefined,
transform: js.UndefOr[String => String] = js.undefined)
extends ReactBridgeComponent
UsingTagsInput
div(
TagsInput(
defaultValue = Seq(“foo","bar"),
onChange = printSequence _
)
)
Using MDL in React
• Problem:
• Components need to be “upgraded”
• Solution:
• React wrapper component around a ReactTag
• Upgrades element upon mounting
• Implicits to avoid noise
Using MDL in React
• Problem:
• Components need to be “upgraded”
• Solution:
• React wrapper component around a ReactTag
• Upgrades element upon mounting
• Implicits to avoid noise
github.com/payalabs/scalajs-react-mdl
Example MDL Use
a(className := "mdl-button mdl-js-button
mdl-button--raised mdl-button—colored
mdl-js-ripple-effect",
onClick --> saveAction())("Save").material
Example MDL Use
a(className := "mdl-button mdl-js-button
mdl-button--raised mdl-button—colored
mdl-js-ripple-effect",
onClick --> saveAction())("Save").material
Things on the Horizon
• GraphQL?
• Stitch?
• Relay?
• Falcor?
?
Ramnivas Laddad
@ramnivas

More Related Content

What's hot (20)

PPTX
Flask & Flask-restx
ammaraslam18
 
PDF
Scala Matsuri 2017
Yoshitaka Fujii
 
PDF
Scala in a wild enterprise
Rafael Bagmanov
 
PDF
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Lucidworks
 
PDF
Benchmarking at Parse
Travis Redman
 
PDF
Making connected apps with BaaS (Droidcon Bangalore 2014)
Varun Torka
 
PDF
State of integration with Apache Camel (ApacheCon 2019)
Claus Ibsen
 
PDF
Composable and streamable Play apps
Yevgeniy Brikman
 
PDF
REST APIs with Spring
Joshua Long
 
PDF
Creating Modular Test-Driven SPAs with Spring and AngularJS
Gunnar Hillert
 
PPTX
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
PPTX
Containerless in the Cloud with AWS Lambda
Ryan Cuprak
 
PDF
Reactive programming on Android
Tomáš Kypta
 
PDF
DOSUG Taking Apache Camel For A Ride
Matthew McCullough
 
PDF
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Codemotion
 
PDF
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
elliando dias
 
PDF
Apache spark with akka couchbase code by bhawani
Bhawani N Prasad
 
ODP
An Overview of Node.js
Ayush Mishra
 
PPTX
Testing in Scala. Adform Research
Vasil Remeniuk
 
PDF
Interactive Kafka Streams
confluent
 
Flask & Flask-restx
ammaraslam18
 
Scala Matsuri 2017
Yoshitaka Fujii
 
Scala in a wild enterprise
Rafael Bagmanov
 
Airbnb Search Architecture: Presented by Maxim Charkov, Airbnb
Lucidworks
 
Benchmarking at Parse
Travis Redman
 
Making connected apps with BaaS (Droidcon Bangalore 2014)
Varun Torka
 
State of integration with Apache Camel (ApacheCon 2019)
Claus Ibsen
 
Composable and streamable Play apps
Yevgeniy Brikman
 
REST APIs with Spring
Joshua Long
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Gunnar Hillert
 
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Reactivesummit
 
Containerless in the Cloud with AWS Lambda
Ryan Cuprak
 
Reactive programming on Android
Tomáš Kypta
 
DOSUG Taking Apache Camel For A Ride
Matthew McCullough
 
Tomer Elmalem - GraphQL APIs: REST in Peace - Codemotion Milan 2017
Codemotion
 
Easy Enterprise Integration Patterns with Apache Camel, ActiveMQ and ServiceMix
elliando dias
 
Apache spark with akka couchbase code by bhawani
Bhawani N Prasad
 
An Overview of Node.js
Ayush Mishra
 
Testing in Scala. Adform Research
Vasil Remeniuk
 
Interactive Kafka Streams
confluent
 

Similar to Full Stack Scala (20)

PDF
An Overview of the React Ecosystem
FITC
 
PPTX
Hands on react native
Jay Nagar
 
PDF
GraphQL
Cédric GILLET
 
PDF
An Intense Overview of the React Ecosystem
Rami Sayar
 
PPTX
One code Web, iOS, Android
Artem Marchenko
 
PPTX
Relay: Seamless Syncing for React (VanJS)
Brooklyn Zelenka
 
PPTX
Alberto Paro - Hands on Scala.js
Scala Italy
 
PPTX
Scala Italy 2015 - Hands On ScalaJS
Alberto Paro
 
PDF
TPSE Thailand 2015 - Rethinking Web with React and Flux
Jirat Kijlerdpornpailoj
 
PDF
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
Pavel Chertorogov
 
PDF
React native
Liran Ben Haim
 
PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
PDF
Web without framework
Nicolas Jorand
 
PPTX
Human scaling on the front end
Rudy Rigot
 
PDF
React Native Components Building Blocks for Dynamic Apps.pdf
Gargi Raghav
 
PDF
Intro to GraphQL
Charles Burgess
 
PDF
Sexy React Stack
KMS Technology
 
PDF
Andrea Lattuada, Gabriele Petronella - Building startups on Scala
Scala Italy
 
PPTX
Kotlin REST & GraphQL API
Sean O'Brien
 
PPTX
React.js at Cortex
Geoff Harcourt
 
An Overview of the React Ecosystem
FITC
 
Hands on react native
Jay Nagar
 
An Intense Overview of the React Ecosystem
Rami Sayar
 
One code Web, iOS, Android
Artem Marchenko
 
Relay: Seamless Syncing for React (VanJS)
Brooklyn Zelenka
 
Alberto Paro - Hands on Scala.js
Scala Italy
 
Scala Italy 2015 - Hands On ScalaJS
Alberto Paro
 
TPSE Thailand 2015 - Rethinking Web with React and Flux
Jirat Kijlerdpornpailoj
 
React, GraphQL и Relay - вполне себе нормальный компонентный подход (nodkz)
Pavel Chertorogov
 
React native
Liran Ben Haim
 
GraphQL: The Missing Link Between Frontend and Backend Devs
Sashko Stubailo
 
Web without framework
Nicolas Jorand
 
Human scaling on the front end
Rudy Rigot
 
React Native Components Building Blocks for Dynamic Apps.pdf
Gargi Raghav
 
Intro to GraphQL
Charles Burgess
 
Sexy React Stack
KMS Technology
 
Andrea Lattuada, Gabriele Petronella - Building startups on Scala
Scala Italy
 
Kotlin REST & GraphQL API
Sean O'Brien
 
React.js at Cortex
Geoff Harcourt
 
Ad

Recently uploaded (20)

PDF
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
PPTX
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
PPTX
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
PPT
introductio to computers by arthur janry
RamananMuthukrishnan
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
PDF
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
PPTX
internet básico presentacion es una red global
70965857
 
PPTX
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
PPTX
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
PPT
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
PDF
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
PPTX
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
PPTX
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
PPTX
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
PPTX
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
PDF
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
PPT
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
PDF
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
PPT
introduction to networking with basics coverage
RamananMuthukrishnan
 
Apple_Environmental_Progress_Report_2025.pdf
yiukwong
 
ONLINE BIRTH CERTIFICATE APPLICATION SYSYTEM PPT.pptx
ShyamasreeDutta
 
Presentation3gsgsgsgsdfgadgsfgfgsfgagsfgsfgzfdgsdgs.pptx
SUB03
 
introductio to computers by arthur janry
RamananMuthukrishnan
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
Azure_DevOps introduction for CI/CD and Agile
henrymails
 
internet básico presentacion es una red global
70965857
 
法国巴黎第二大学本科毕业证{Paris 2学费发票Paris 2成绩单}办理方法
Taqyea
 
原版西班牙莱昂大学毕业证(León毕业证书)如何办理
Taqyea
 
Computer Securityyyyyyyy - Chapter 2.ppt
SolomonSB
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
AI_MOD_1.pdf artificial intelligence notes
shreyarrce
 
一比一原版(LaTech毕业证)路易斯安那理工大学毕业证如何办理
Taqyea
 
Optimization_Techniques_ML_Presentation.pptx
farispalayi
 
sajflsajfljsdfljslfjslfsdfas;fdsfksadfjlsdflkjslgfs;lfjlsajfl;sajfasfd.pptx
theknightme
 
英国假毕业证诺森比亚大学成绩单GPA修改UNN学生卡网上可查学历成绩单
Taqyea
 
𝐁𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓
hokimamad0
 
Agilent Optoelectronic Solutions for Mobile Application
andreashenniger2
 
Build Fast, Scale Faster: Milvus vs. Zilliz Cloud for Production-Ready AI
Zilliz
 
introduction to networking with basics coverage
RamananMuthukrishnan
 
Ad

Full Stack Scala