SlideShare a Scribd company logo
1 of 31
Download to read offline
Part 1
Scala for … you ?
Katrin Shechtman, Senior Software Engineer at BoldRadius
01
Who am I?
✤ C —> C++ —> Java —> Scala!
✤ https://ca.linkedin.com/in/
katrinshechtman!
✤ https://github.com/katrinsharp!
✤ @katrinsh!
✤ katrin.shechtman@boldradius.co
m
Who are you?
Feeling about
Scala
Java
Developer
DBA
DevOps/
SysAdmin
ETL Engineer
I don’t like it! ?? ?? ?? ??
I don’t really
care
?? ?? ?? ??
I’m curios to
know more
?? ?? ?? ??
I’m totally in
with it
?? ?? ?? ??
Let’s talk about Java!
Who is on with Java 8? Lambdas?
There will be some code examples using Java 8, 

but don’t worry, its knowledge is only nice to have 

for this presentation.
String greeting = "Hello World";
–There are so many things that compiler and I know!
String greeting = "Hello World";
–We both know that it is String, what else could it be?
greeting = "Hello World";
–Each of us also knows where the line ends..
greeting = "Hello World" .. Nice..!
But it is too simplistic. !
What about something beefy.. generics?
–The crowd
class SpecialId {!
! public String id;!
! public SpecialId(String id) {!
! ! this.id = id; !
! }!
}

List<SpecialId> list = new LinkedList<SpecialId>();

list.add(new SpecialId("1234"));
–Doesn’t compiler know that it is a list of (at least) SpecialIds?
Why not:!
list = List<SpecialId>()!
or if you populate it right away:!
list = List(new SpecialId("1234"))
– Good question, heh?
greeting = "Hello World"!
list = List(new SpecialId("1234"))
–So far so good. What about SpecialId?
class SpecialId {!
! public String id;!
! public SpecialId(String id) {!
! ! this.id = id; !
! }!
}
–What if we could just let compiler know what members the class
has and compiler will do the rest?
class SpecialId(String id)!
id = SpecialId("1234")
–Remember the compiler knows that id is type of SpecialId
greeting = "Hello World"!
class SpecialId(String id)!
list = List(new SpecialId("1234"))
–Much more concise. What else?
class Service(String name)!
class Signup(SpecialId id, Service service)!
list = List<Signup>() //populated somewhere else
–How to get map of users per service?
✤ ol’ loop over iterator. !
✤ Java 8 lambdas: 

Map<Service, List<Signup>> m = list.stream()

.collect(Collectors.groupingBy((signup) ->
signup.service));
How to get map of users per service?
Map<Service, List<Signup>> m = list.stream()

.collect(Collectors.

groupingBy((signup) -> signup.service));
–What really matters here is collection (list), action (grouping by)
and mapping function.
So why not to focus on what really matters?!
m = list.groupingBy(signup -> signup.service)
–Why not?
greeting = "Hello World"!
class SpecialId(String id)!
list = List(new SpecialId(“1234"))!
m = list.groupingBy(signup -> signup.service)
–This looks like more succinct language syntax.
Welcome to Scala -
JavaVM based and functional
language
val greeting = "Hello World"!
case class SpecialId(String id)!
case class Signup(id: SpecialId, service: Service)!
val signupList = 

List(Signup(SpecialId("1234"), Service("service1")), …)!
val m = signupList.groupBy(signup => signup.service)
Scala in a nutshell
✤ Statically typed + type inference.!
✤ Immutability: val vs var . !
✤ Built-in support for better equals, hashCode and
toString in case classes.!
✤ Object Oriented: no primitives, classes, inheritance,
traits mix-ins.
Part 1 (spot part 2 for other Scala features)
Statically typed w/ type inference
✤ Statically typed:

val shouldBeString: String = 12 

//type mismatch; found : Int(12) required: String

def reminder(fraction: Int, denom: Int): Int = {

fraction % denom

} !
✤ Type inference:

val willBeInt = 12

def reminder(fraction: Int, denom: Int) = fraction % denom
Scala in a nutshell
✤ Statically typed + type inference.!
✤ Immutability: val vs var . !
✤ Built-in support for better equals, hashCode and
toString in case classes.!
✤ Object Oriented: no primitives, classes, inheritance,
traits mix-ins.
Part 1 (spot part 2 for other Scala features)
Immutability
✤ Mutable vs immutable:

val str1 = "immutable string"

var str2 = "I can change"

str1 = "Compilation error..." //reassignment to val

str2 = "Now I'm different, no problem”!
✤ Mutable variable vs mutable collection:

var mutableList = List("1", "2")

mutableList = mutableList :+ "3"

val mutableList2 = MutableList("1", "2")

mutableList2 += “3"!
✤ Everything is expression:

val isSomething = if(cond) true else false
Scala in a nutshell
✤ Statically typed + type inference.!
✤ Immutability: val vs var . !
✤ Built-in support for better equals, hashCode and
toString in case classes.!
✤ Object Oriented: no primitives, classes, inheritance,
traits mix-ins.
Part 1 (spot part 2 for other Scala features)
Remember Signup case class?
✤ toString():

println(Signup(SpecialId("1"), Service("s1")))

will print Signup(SpecialId(1),Service(s1))!
✤ equals(): 

val signup = Signup(SpecialId("1"), Service(“s1"))

val signup2 = Signup(SpecialId("1"), Service("s1"))

signup == signup2 // will return true
Scala in a nutshell
✤ Statically typed + type inference.!
✤ Immutability: val vs var . !
✤ Built-in support for better equals, hashCode and
toString in case classes.!
✤ Object Oriented: no primitives, classes, inheritance,
traits mix-ins.
Part 1 (spot part 2 for other Scala features)
Object Oriented
✤ No primitives: Int, Boolean etc!
✤ Traits - interfaces with methods!
✤ Classes and case classes!
✤ Single inheritance, multiple mix-ins
trait Fruit {!
! def isGreen: Boolean!
! def isLowCalories = false!
} !
trait Size {!
! def size: String!
} !
trait Apple extends Fruit {!
! val isLowCalories = isGreen!
} !
class GreenApple(name: String) extends Apple {!
! val isGreen = true!
}!
case class MyFavoriteFruit(name: String) extends
GreenApple(name) with Size {!
! def size = "very big"!
}!
MyFavoriteFruit("smith")
Scala in a nutshell
✤ Statically typed + type inference.!
✤ Immutability: val vs var . !
✤ Built-in support for better equals, hashCode and
toString in case classes.!
✤ Object Oriented: no primitives, classes, inheritance,
traits mix-ins.
Part 1 (spot part 2 for other Scala features)
See you next part! Meanwhile..
✤ Functional Programming Principles 

with Martin Odersky:

https://www.coursera.org/course/progfun!
✤ Learn Scala for Java Developers by Toby Weston:
http://www.amazon.com/Learn-Scala-Java-
Developers-Weston-ebook/dp/B00WIQKR9I!
✤ How to learn Scala by BoldRadius: 

http://guides.co/guide/how-to-learn-scala

More Related Content

Viewers also liked

Functional Programming - Worth the Effort
Functional Programming - Worth the EffortFunctional Programming - Worth the Effort
Functional Programming - Worth the EffortBoldRadius Solutions
 
Empirics of standard deviation
Empirics of standard deviationEmpirics of standard deviation
Empirics of standard deviationAdebanji Ayeni
 
What Are For Expressions in Scala?
What Are For Expressions in Scala?What Are For Expressions in Scala?
What Are For Expressions in Scala?BoldRadius Solutions
 
String Interpolation in Scala | BoldRadius
String Interpolation in Scala | BoldRadiusString Interpolation in Scala | BoldRadius
String Interpolation in Scala | BoldRadiusBoldRadius Solutions
 
Curriculum
CurriculumCurriculum
Curriculumthipik
 
Cold drawn guide rail, Elevator guide Rail India
Cold drawn guide rail, Elevator guide Rail IndiaCold drawn guide rail, Elevator guide Rail India
Cold drawn guide rail, Elevator guide Rail IndiaN Liftee
 
Scala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadiusScala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadiusBoldRadius Solutions
 
Punishment Driven Development #agileinthecity
Punishment Driven Development   #agileinthecityPunishment Driven Development   #agileinthecity
Punishment Driven Development #agileinthecityLouise Elliott
 
How You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionHow You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionBoldRadius Solutions
 
scientific method and the research process
scientific method and the research processscientific method and the research process
scientific method and the research processAdebanji Ayeni
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldBTI360
 
GSLV MARK 3
GSLV MARK 3GSLV MARK 3
GSLV MARK 3APOORVA
 

Viewers also liked (20)

Functional Programming - Worth the Effort
Functional Programming - Worth the EffortFunctional Programming - Worth the Effort
Functional Programming - Worth the Effort
 
Empirics of standard deviation
Empirics of standard deviationEmpirics of standard deviation
Empirics of standard deviation
 
What Are For Expressions in Scala?
What Are For Expressions in Scala?What Are For Expressions in Scala?
What Are For Expressions in Scala?
 
String Interpolation in Scala | BoldRadius
String Interpolation in Scala | BoldRadiusString Interpolation in Scala | BoldRadius
String Interpolation in Scala | BoldRadius
 
Presentation1
Presentation1Presentation1
Presentation1
 
Code Brevity in Scala
Code Brevity in ScalaCode Brevity in Scala
Code Brevity in Scala
 
Test
TestTest
Test
 
Scala: Collections API
Scala: Collections APIScala: Collections API
Scala: Collections API
 
Pattern Matching in Scala
Pattern Matching in ScalaPattern Matching in Scala
Pattern Matching in Scala
 
Curriculum
CurriculumCurriculum
Curriculum
 
Cold drawn guide rail, Elevator guide Rail India
Cold drawn guide rail, Elevator guide Rail IndiaCold drawn guide rail, Elevator guide Rail India
Cold drawn guide rail, Elevator guide Rail India
 
Scala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadiusScala Days Highlights | BoldRadius
Scala Days Highlights | BoldRadius
 
Earth moon 1
Earth moon 1Earth moon 1
Earth moon 1
 
Punishment Driven Development #agileinthecity
Punishment Driven Development   #agileinthecityPunishment Driven Development   #agileinthecity
Punishment Driven Development #agileinthecity
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Immutability in Scala
Immutability in ScalaImmutability in Scala
Immutability in Scala
 
How You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in ProductionHow You Convince Your Manager To Adopt Scala.js in Production
How You Convince Your Manager To Adopt Scala.js in Production
 
scientific method and the research process
scientific method and the research processscientific method and the research process
scientific method and the research process
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
GSLV MARK 3
GSLV MARK 3GSLV MARK 3
GSLV MARK 3
 

Similar to Why Not Make the Transition from Java to Scala?

Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scalascalaconfjp
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSAlberto Paro
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsScala Italy
 
Functional Principles for OO Developers
Functional Principles for OO DevelopersFunctional Principles for OO Developers
Functional Principles for OO Developersjessitron
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + ScalaShouheng Yi
 
楽々Scalaプログラミング
楽々Scalaプログラミング楽々Scalaプログラミング
楽々ScalaプログラミングTomoharu ASAMI
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik ErlandsonDatabricks
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Raffi Krikorian
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationM Sajid R
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghStuart Roebuck
 
Scala introduction
Scala introductionScala introduction
Scala introductionvito jeng
 
2019 hashiconf consul-templaterb
2019 hashiconf consul-templaterb2019 hashiconf consul-templaterb
2019 hashiconf consul-templaterbPierre Souchay
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScriptStalin Thangaraj
 

Similar to Why Not Make the Transition from Java to Scala? (20)

Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
[Start] Scala
[Start] Scala[Start] Scala
[Start] Scala
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala active record
Scala active recordScala active record
Scala active record
 
Functional Principles for OO Developers
Functional Principles for OO DevelopersFunctional Principles for OO Developers
Functional Principles for OO Developers
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + Scala
 
楽々Scalaプログラミング
楽々Scalaプログラミング楽々Scalaプログラミング
楽々Scalaプログラミング
 
Apache Spark for Library Developers with William Benton and Erik Erlandson
 Apache Spark for Library Developers with William Benton and Erik Erlandson Apache Spark for Library Developers with William Benton and Erik Erlandson
Apache Spark for Library Developers with William Benton and Erik Erlandson
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 
Scio
ScioScio
Scio
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
2019 hashiconf consul-templaterb
2019 hashiconf consul-templaterb2019 hashiconf consul-templaterb
2019 hashiconf consul-templaterb
 
Introduction to CoffeeScript
Introduction to CoffeeScriptIntroduction to CoffeeScript
Introduction to CoffeeScript
 

More from BoldRadius Solutions

Introduction to the Typesafe Reactive Platform
Introduction to the Typesafe Reactive PlatformIntroduction to the Typesafe Reactive Platform
Introduction to the Typesafe Reactive PlatformBoldRadius Solutions
 
Towards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayTowards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayBoldRadius Solutions
 
Domain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureDomain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureBoldRadius Solutions
 
How To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaHow To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaBoldRadius Solutions
 
Scala Days 2014: Pitching Typesafe
Scala Days 2014: Pitching TypesafeScala Days 2014: Pitching Typesafe
Scala Days 2014: Pitching TypesafeBoldRadius Solutions
 
Demonstrating Case Classes in Scala
Demonstrating Case Classes in ScalaDemonstrating Case Classes in Scala
Demonstrating Case Classes in ScalaBoldRadius Solutions
 

More from BoldRadius Solutions (8)

Introduction to the Typesafe Reactive Platform
Introduction to the Typesafe Reactive PlatformIntroduction to the Typesafe Reactive Platform
Introduction to the Typesafe Reactive Platform
 
Towards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The BayTowards Reliable Lookups - Scala By The Bay
Towards Reliable Lookups - Scala By The Bay
 
Introduction to the Actor Model
Introduction to the Actor ModelIntroduction to the Actor Model
Introduction to the Actor Model
 
Domain Driven Design Through Onion Architecture
Domain Driven Design Through Onion ArchitectureDomain Driven Design Through Onion Architecture
Domain Driven Design Through Onion Architecture
 
What are Sealed Classes in Scala?
What are Sealed Classes in Scala?What are Sealed Classes in Scala?
What are Sealed Classes in Scala?
 
How To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaHow To Use Higher Order Functions in Scala
How To Use Higher Order Functions in Scala
 
Scala Days 2014: Pitching Typesafe
Scala Days 2014: Pitching TypesafeScala Days 2014: Pitching Typesafe
Scala Days 2014: Pitching Typesafe
 
Demonstrating Case Classes in Scala
Demonstrating Case Classes in ScalaDemonstrating Case Classes in Scala
Demonstrating Case Classes in Scala
 

Recently uploaded

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 

Recently uploaded (20)

Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 

Why Not Make the Transition from Java to Scala?

  • 1. Part 1 Scala for … you ? Katrin Shechtman, Senior Software Engineer at BoldRadius
  • 2. 01 Who am I? ✤ C —> C++ —> Java —> Scala! ✤ https://ca.linkedin.com/in/ katrinshechtman! ✤ https://github.com/katrinsharp! ✤ @katrinsh! ✤ katrin.shechtman@boldradius.co m
  • 3. Who are you? Feeling about Scala Java Developer DBA DevOps/ SysAdmin ETL Engineer I don’t like it! ?? ?? ?? ?? I don’t really care ?? ?? ?? ?? I’m curios to know more ?? ?? ?? ?? I’m totally in with it ?? ?? ?? ??
  • 4. Let’s talk about Java! Who is on with Java 8? Lambdas? There will be some code examples using Java 8, 
 but don’t worry, its knowledge is only nice to have 
 for this presentation.
  • 5. String greeting = "Hello World"; –There are so many things that compiler and I know!
  • 6. String greeting = "Hello World"; –We both know that it is String, what else could it be?
  • 7. greeting = "Hello World"; –Each of us also knows where the line ends..
  • 8. greeting = "Hello World" .. Nice..! But it is too simplistic. ! What about something beefy.. generics? –The crowd
  • 9. class SpecialId {! ! public String id;! ! public SpecialId(String id) {! ! ! this.id = id; ! ! }! }
 List<SpecialId> list = new LinkedList<SpecialId>();
 list.add(new SpecialId("1234")); –Doesn’t compiler know that it is a list of (at least) SpecialIds?
  • 10. Why not:! list = List<SpecialId>()! or if you populate it right away:! list = List(new SpecialId("1234")) – Good question, heh?
  • 11. greeting = "Hello World"! list = List(new SpecialId("1234")) –So far so good. What about SpecialId?
  • 12. class SpecialId {! ! public String id;! ! public SpecialId(String id) {! ! ! this.id = id; ! ! }! } –What if we could just let compiler know what members the class has and compiler will do the rest?
  • 13. class SpecialId(String id)! id = SpecialId("1234") –Remember the compiler knows that id is type of SpecialId
  • 14. greeting = "Hello World"! class SpecialId(String id)! list = List(new SpecialId("1234")) –Much more concise. What else?
  • 15. class Service(String name)! class Signup(SpecialId id, Service service)! list = List<Signup>() //populated somewhere else –How to get map of users per service?
  • 16. ✤ ol’ loop over iterator. ! ✤ Java 8 lambdas: 
 Map<Service, List<Signup>> m = list.stream()
 .collect(Collectors.groupingBy((signup) -> signup.service)); How to get map of users per service?
  • 17. Map<Service, List<Signup>> m = list.stream()
 .collect(Collectors.
 groupingBy((signup) -> signup.service)); –What really matters here is collection (list), action (grouping by) and mapping function.
  • 18. So why not to focus on what really matters?! m = list.groupingBy(signup -> signup.service) –Why not?
  • 19. greeting = "Hello World"! class SpecialId(String id)! list = List(new SpecialId(“1234"))! m = list.groupingBy(signup -> signup.service) –This looks like more succinct language syntax.
  • 20. Welcome to Scala - JavaVM based and functional language val greeting = "Hello World"! case class SpecialId(String id)! case class Signup(id: SpecialId, service: Service)! val signupList = 
 List(Signup(SpecialId("1234"), Service("service1")), …)! val m = signupList.groupBy(signup => signup.service)
  • 21. Scala in a nutshell ✤ Statically typed + type inference.! ✤ Immutability: val vs var . ! ✤ Built-in support for better equals, hashCode and toString in case classes.! ✤ Object Oriented: no primitives, classes, inheritance, traits mix-ins. Part 1 (spot part 2 for other Scala features)
  • 22. Statically typed w/ type inference ✤ Statically typed:
 val shouldBeString: String = 12 
 //type mismatch; found : Int(12) required: String
 def reminder(fraction: Int, denom: Int): Int = {
 fraction % denom
 } ! ✤ Type inference:
 val willBeInt = 12
 def reminder(fraction: Int, denom: Int) = fraction % denom
  • 23. Scala in a nutshell ✤ Statically typed + type inference.! ✤ Immutability: val vs var . ! ✤ Built-in support for better equals, hashCode and toString in case classes.! ✤ Object Oriented: no primitives, classes, inheritance, traits mix-ins. Part 1 (spot part 2 for other Scala features)
  • 24. Immutability ✤ Mutable vs immutable:
 val str1 = "immutable string"
 var str2 = "I can change"
 str1 = "Compilation error..." //reassignment to val
 str2 = "Now I'm different, no problem”! ✤ Mutable variable vs mutable collection:
 var mutableList = List("1", "2")
 mutableList = mutableList :+ "3"
 val mutableList2 = MutableList("1", "2")
 mutableList2 += “3"! ✤ Everything is expression:
 val isSomething = if(cond) true else false
  • 25. Scala in a nutshell ✤ Statically typed + type inference.! ✤ Immutability: val vs var . ! ✤ Built-in support for better equals, hashCode and toString in case classes.! ✤ Object Oriented: no primitives, classes, inheritance, traits mix-ins. Part 1 (spot part 2 for other Scala features)
  • 26. Remember Signup case class? ✤ toString():
 println(Signup(SpecialId("1"), Service("s1")))
 will print Signup(SpecialId(1),Service(s1))! ✤ equals(): 
 val signup = Signup(SpecialId("1"), Service(“s1"))
 val signup2 = Signup(SpecialId("1"), Service("s1"))
 signup == signup2 // will return true
  • 27. Scala in a nutshell ✤ Statically typed + type inference.! ✤ Immutability: val vs var . ! ✤ Built-in support for better equals, hashCode and toString in case classes.! ✤ Object Oriented: no primitives, classes, inheritance, traits mix-ins. Part 1 (spot part 2 for other Scala features)
  • 28. Object Oriented ✤ No primitives: Int, Boolean etc! ✤ Traits - interfaces with methods! ✤ Classes and case classes! ✤ Single inheritance, multiple mix-ins
  • 29. trait Fruit {! ! def isGreen: Boolean! ! def isLowCalories = false! } ! trait Size {! ! def size: String! } ! trait Apple extends Fruit {! ! val isLowCalories = isGreen! } ! class GreenApple(name: String) extends Apple {! ! val isGreen = true! }! case class MyFavoriteFruit(name: String) extends GreenApple(name) with Size {! ! def size = "very big"! }! MyFavoriteFruit("smith")
  • 30. Scala in a nutshell ✤ Statically typed + type inference.! ✤ Immutability: val vs var . ! ✤ Built-in support for better equals, hashCode and toString in case classes.! ✤ Object Oriented: no primitives, classes, inheritance, traits mix-ins. Part 1 (spot part 2 for other Scala features)
  • 31. See you next part! Meanwhile.. ✤ Functional Programming Principles 
 with Martin Odersky:
 https://www.coursera.org/course/progfun! ✤ Learn Scala for Java Developers by Toby Weston: http://www.amazon.com/Learn-Scala-Java- Developers-Weston-ebook/dp/B00WIQKR9I! ✤ How to learn Scala by BoldRadius: 
 http://guides.co/guide/how-to-learn-scala