SlideShare uma empresa Scribd logo
1 de 35
Baixar para ler offline
Scala
The language for Big
Data
Tzach Zohar @ Kenshoo, March/2016
Who am I
System Architect @ Kenshoo
Java backend for 10 years
Working with Scala + Spark for 2 years
https://www.linkedin.com/in/tzachzohar
Who’s Kenshoo
10-year Tel-Aviv based startup
500+ employees
Industry Leader in Digital Marketing
Heavy data shop
http://kenshoo.com/
And who are you?
Agenda
NOT the usual Scala pitch
Scala - Short Intro
Scala
Created by Martin Odersky and his research group in EPFL, 2003
Open Source
Runs on the JVM, Seamless Java Interoperability
Strongly Typed
Object Oriented
Functional
Functional Programming
From Wikipedia:
“[…] functional programming […] treats
computation as the evaluation of mathematical
functions and avoids changing-state and
mutable data”
Functional Languages
Functions are “first-class citizens”, i.e. values
Higher-Order Functions
Minimize side effects
Minimize mutability
Example: Imperative to Functional
Java / Imperative:
private static class Person {
String firstName;
String lastName;
}
private List<Person> firstNFamilies(int n, List<Person> persons) {
final List<String> familiesSoFar = new LinkedList<>();
final List<Person> result = new LinkedList<>();
for (Person p : persons) {
if (familiesSoFar.contains(p.lastName)) {
result.add(p);
} else if (familiesSoFar.size() < n) {
familiesSoFar.add(p.lastName);
result.add(p);
}
}
return result;
}
Scala / Functional:
case class Person(firstName: String, lastName: String)
def firstNFamilies(n: Int, persons: List[Person]): List[Person] = {
val firstFamilies = persons.map(p => p.lastName).distinct.take(n)
persons.filter(p => firstFamilies.contains(p.lastName))
}
Hey, won’t this look
rather similar with
Java8’s Streams +
Lambdas?
Scala + Big Data
What can a language
do for Big Data?
Language “requirements”
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery” away
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Java Interoperability
class DirectParquetOutputCommitter(outputPath: Path, context: TaskAttemptContext)
extends ParquetOutputCommitter(outputPath, context) { … }
Java class from org.apache.parquet:parquet-hadoop
Scala class from org.apache.spark:spark-core_2.10
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Scala is Interactive
Scala has a built-in REPL, extensible by Scala-based tools
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Performant
Benchmarking languages is hard and suffers from bias
Most benchmarks show Scala is at least on-par with Java,
e.g. Google’s benchmark:
Nonsense!
No Way!
RAGE!!11
Does it matter?
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Performant
Ability to scale out is more significant than per-CPU performance
http://vmturbo.com/wp-content/uploads/2015/05/ScaleUpScaleOut_sm-min.jpg
Abstracts “machinery”
away - What?
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Think about MapReduce
Hadoop’s Mapper and Reducer - code what to do, not:
How
Where
In what order
How to handle failures
Leaves these concerns for the framework to figure out
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Think about MapReduce
Hadoop’s Java API imitates Functional Programming:
Mapper and Reducer are Functions
Executed by “Higher Order Functions”
No Side Effects / Mutability
Abstracts “machinery”
away - Why?
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Functional makes concurrency easy
val numbers = 1 to 100000
val result = numbers.map(slowF)
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Functional makes concurrency easy
val numbers = 1 to 100000
val result = numbers.par.map(slowF)
Parallelizes next manipulations over available CPUs
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Functional makes distribution easy
val numbers = 1 to 100000
val result = sparkContext.parallelize(numbers).map(slowF)
Parallelizes next manipulations over scalable cluster, by
creating a Spark RDD - a Resilient Distributed Dataset
“Spark RDDs are
the ultimate Scala
collections"
-  Martin Odersky
photo: http://www.swissict-award.ch/fileadmin/award/Pressebilder/Martin_Odersky_Scala.jpg
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery”
Functional makes Resiliency easy
Pure functions are idempotent, which allows retriability
Map
Map
MapMap Map (retry)
What if we always
coded this way?
A functional language
means just that
Language “requirements”
Open Source
Strongly Typed
Java/JVM Friendly
Interactive
Performant
Abstracts “machinery” away
But “Scala is hard!”
It’s really not that scary...
From
Manuel Bernhardt's "Debunking Some Myths About Scala And Its Environment":
“I need to become a mathematician and know all about Monads before I can get
started”
“I can throw all of my object-orientation knowledge out of the window”
“There is no good IDE support for Scala”
Thank You!

Mais conteúdo relacionado

Destaque

Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in Scala
Roberto Casadei
 
Paris stormusergroup intrudocution
Paris stormusergroup intrudocutionParis stormusergroup intrudocution
Paris stormusergroup intrudocution
Paris_Storm_UG
 

Destaque (20)

Symantec: Cassandra Data Modelling techniques in action
Symantec: Cassandra Data Modelling techniques in actionSymantec: Cassandra Data Modelling techniques in action
Symantec: Cassandra Data Modelling techniques in action
 
Apache spark Intro
Apache spark IntroApache spark Intro
Apache spark Intro
 
BDX 2016 - Arnon rotem gal-oz @ appsflyer
BDX 2016 - Arnon rotem gal-oz @ appsflyerBDX 2016 - Arnon rotem gal-oz @ appsflyer
BDX 2016 - Arnon rotem gal-oz @ appsflyer
 
Micro apps across 3 continents using React js
Micro apps across 3 continents using React js Micro apps across 3 continents using React js
Micro apps across 3 continents using React js
 
Data analysis scala_spark
Data analysis scala_sparkData analysis scala_spark
Data analysis scala_spark
 
BDX 2016 - Kevin lyons & yakir buskilla @ eXelate
BDX 2016 - Kevin lyons & yakir buskilla  @ eXelate BDX 2016 - Kevin lyons & yakir buskilla  @ eXelate
BDX 2016 - Kevin lyons & yakir buskilla @ eXelate
 
Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala story
 
Practical Aggregate Programming in Scala
Practical Aggregate Programming in ScalaPractical Aggregate Programming in Scala
Practical Aggregate Programming in Scala
 
Accelerating scale from startups to enterprise by Peter bakas
Accelerating scale from startups to enterprise by Peter bakasAccelerating scale from startups to enterprise by Peter bakas
Accelerating scale from startups to enterprise by Peter bakas
 
Universitélang scala tools
Universitélang scala toolsUniversitélang scala tools
Universitélang scala tools
 
Maven c'est bien, SBT c'est mieux
Maven c'est bien, SBT c'est mieuxMaven c'est bien, SBT c'est mieux
Maven c'est bien, SBT c'est mieux
 
Les monades Scala, Java 8
Les monades Scala, Java 8Les monades Scala, Java 8
Les monades Scala, Java 8
 
Université des langages scala
Université des langages   scalaUniversité des langages   scala
Université des langages scala
 
Six years of Scala and counting
Six years of Scala and countingSix years of Scala and counting
Six years of Scala and counting
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Lagom, reactive framework
Lagom, reactive frameworkLagom, reactive framework
Lagom, reactive framework
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010
 
Scala in Action - Heiko Seeburger
Scala in Action - Heiko SeeburgerScala in Action - Heiko Seeburger
Scala in Action - Heiko Seeburger
 
Paris stormusergroup intrudocution
Paris stormusergroup intrudocutionParis stormusergroup intrudocution
Paris stormusergroup intrudocution
 

Semelhante a BDX 2016 - Tzach zohar @ kenshoo

Learn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemtsLearn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemts
siddharth30121
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
Zaiyang Li
 

Semelhante a BDX 2016 - Tzach zohar @ kenshoo (20)

Donald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New TricksDonald Ferguson - Old Programmers Can Learn New Tricks
Donald Ferguson - Old Programmers Can Learn New Tricks
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac x
 
Functional programming is the most extreme programming
Functional programming is the most extreme programmingFunctional programming is the most extreme programming
Functional programming is the most extreme programming
 
Why Functional Programming So Hard?
Why Functional Programming So Hard?Why Functional Programming So Hard?
Why Functional Programming So Hard?
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about java
 
Jruby
JrubyJruby
Jruby
 
Java seminar
Java seminarJava seminar
Java seminar
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
A Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShiftA Happy Cloud Friendly Java Developer with OpenShift
A Happy Cloud Friendly Java Developer with OpenShift
 
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdfSulthan's_JAVA_Material_for_B.Sc-CS.pdf
Sulthan's_JAVA_Material_for_B.Sc-CS.pdf
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Proyect of english
Proyect of englishProyect of english
Proyect of english
 
Learn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemtsLearn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemts
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
 
What is java?-Saurabh Upadhyay
What is java?-Saurabh UpadhyayWhat is java?-Saurabh Upadhyay
What is java?-Saurabh Upadhyay
 
Technology Stack Discussion
Technology Stack DiscussionTechnology Stack Discussion
Technology Stack Discussion
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
SemTech 2010: Pelorus Platform
SemTech 2010: Pelorus PlatformSemTech 2010: Pelorus Platform
SemTech 2010: Pelorus Platform
 

Mais de Ido Shilon (9)

Production ready big ml workflows from zero to hero daniel marcous @ waze
Production ready big ml workflows from zero to hero daniel marcous @ wazeProduction ready big ml workflows from zero to hero daniel marcous @ waze
Production ready big ml workflows from zero to hero daniel marcous @ waze
 
Why ml and ai are the future of gaming david sachs @ tomobox
Why ml and ai are the future of gaming david sachs @ tomoboxWhy ml and ai are the future of gaming david sachs @ tomobox
Why ml and ai are the future of gaming david sachs @ tomobox
 
Deep learning at nmc devin jones
Deep learning at nmc devin jones Deep learning at nmc devin jones
Deep learning at nmc devin jones
 
Blind spots in big data erez koren @ forter
Blind spots in big data erez koren @ forterBlind spots in big data erez koren @ forter
Blind spots in big data erez koren @ forter
 
Using druid for interactive count distinct queries at scale @ nmc
Using druid  for interactive count distinct queries at scale @ nmcUsing druid  for interactive count distinct queries at scale @ nmc
Using druid for interactive count distinct queries at scale @ nmc
 
BDX 2016- Monal daxini @ Netflix
BDX 2016-  Monal daxini  @ NetflixBDX 2016-  Monal daxini  @ Netflix
BDX 2016- Monal daxini @ Netflix
 
BDX 2016 - Tal sliwowicz @ taboola
BDX 2016 - Tal sliwowicz @ taboolaBDX 2016 - Tal sliwowicz @ taboola
BDX 2016 - Tal sliwowicz @ taboola
 
Scaling to 1 million users v1
Scaling to 1 million users v1Scaling to 1 million users v1
Scaling to 1 million users v1
 
Couchbase@live person meetup july 22nd
Couchbase@live person meetup   july 22ndCouchbase@live person meetup   july 22nd
Couchbase@live person meetup july 22nd
 

Último

Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
shivangimorya083
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Call Girls In Delhi Whatsup 9873940964 Enjoy Unlimited Pleasure
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
SofiyaSharma5
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 

Último (20)

Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
@9999965857 🫦 Sexy Desi Call Girls Laxmi Nagar 💓 High Profile Escorts Delhi 🫶
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
✂️ 👅 Independent Andheri Escorts With Room Vashi Call Girls 💃 9004004663
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
'Future Evolution of the Internet' delivered by Geoff Huston at Everything Op...
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 

BDX 2016 - Tzach zohar @ kenshoo

  • 1. Scala The language for Big Data Tzach Zohar @ Kenshoo, March/2016
  • 2. Who am I System Architect @ Kenshoo Java backend for 10 years Working with Scala + Spark for 2 years https://www.linkedin.com/in/tzachzohar
  • 3. Who’s Kenshoo 10-year Tel-Aviv based startup 500+ employees Industry Leader in Digital Marketing Heavy data shop http://kenshoo.com/
  • 4. And who are you?
  • 5. Agenda NOT the usual Scala pitch
  • 7. Scala Created by Martin Odersky and his research group in EPFL, 2003 Open Source Runs on the JVM, Seamless Java Interoperability Strongly Typed Object Oriented Functional
  • 8. Functional Programming From Wikipedia: “[…] functional programming […] treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data”
  • 9. Functional Languages Functions are “first-class citizens”, i.e. values Higher-Order Functions Minimize side effects Minimize mutability
  • 10. Example: Imperative to Functional Java / Imperative: private static class Person { String firstName; String lastName; } private List<Person> firstNFamilies(int n, List<Person> persons) { final List<String> familiesSoFar = new LinkedList<>(); final List<Person> result = new LinkedList<>(); for (Person p : persons) { if (familiesSoFar.contains(p.lastName)) { result.add(p); } else if (familiesSoFar.size() < n) { familiesSoFar.add(p.lastName); result.add(p); } } return result; } Scala / Functional: case class Person(firstName: String, lastName: String) def firstNFamilies(n: Int, persons: List[Person]): List[Person] = { val firstFamilies = persons.map(p => p.lastName).distinct.take(n) persons.filter(p => firstFamilies.contains(p.lastName)) }
  • 11. Hey, won’t this look rather similar with Java8’s Streams + Lambdas?
  • 12. Scala + Big Data
  • 13. What can a language do for Big Data?
  • 14. Language “requirements” Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” away
  • 15. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Java Interoperability class DirectParquetOutputCommitter(outputPath: Path, context: TaskAttemptContext) extends ParquetOutputCommitter(outputPath, context) { … } Java class from org.apache.parquet:parquet-hadoop Scala class from org.apache.spark:spark-core_2.10
  • 16. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Scala is Interactive Scala has a built-in REPL, extensible by Scala-based tools
  • 17. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Performant Benchmarking languages is hard and suffers from bias Most benchmarks show Scala is at least on-par with Java, e.g. Google’s benchmark: Nonsense! No Way! RAGE!!11
  • 19. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Performant Ability to scale out is more significant than per-CPU performance http://vmturbo.com/wp-content/uploads/2015/05/ScaleUpScaleOut_sm-min.jpg
  • 21. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Think about MapReduce Hadoop’s Mapper and Reducer - code what to do, not: How Where In what order How to handle failures Leaves these concerns for the framework to figure out
  • 22. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Think about MapReduce Hadoop’s Java API imitates Functional Programming: Mapper and Reducer are Functions Executed by “Higher Order Functions” No Side Effects / Mutability
  • 24. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Functional makes concurrency easy val numbers = 1 to 100000 val result = numbers.map(slowF)
  • 25. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Functional makes concurrency easy val numbers = 1 to 100000 val result = numbers.par.map(slowF) Parallelizes next manipulations over available CPUs
  • 26. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Functional makes distribution easy val numbers = 1 to 100000 val result = sparkContext.parallelize(numbers).map(slowF) Parallelizes next manipulations over scalable cluster, by creating a Spark RDD - a Resilient Distributed Dataset
  • 27. “Spark RDDs are the ultimate Scala collections" -  Martin Odersky photo: http://www.swissict-award.ch/fileadmin/award/Pressebilder/Martin_Odersky_Scala.jpg
  • 28. Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” Functional makes Resiliency easy Pure functions are idempotent, which allows retriability Map Map MapMap Map (retry)
  • 29. What if we always coded this way?
  • 31. Language “requirements” Open Source Strongly Typed Java/JVM Friendly Interactive Performant Abstracts “machinery” away
  • 32. But “Scala is hard!”
  • 33.
  • 34. It’s really not that scary... From Manuel Bernhardt's "Debunking Some Myths About Scala And Its Environment": “I need to become a mathematician and know all about Monads before I can get started” “I can throw all of my object-orientation knowledge out of the window” “There is no good IDE support for Scala”