SlideShare a Scribd company logo
Scala in a Java 8 World
Takeaways
•  Why Scala?
•  Scala still relevant in Java 8 world?
What do we need in a
language?
Scala vs Java 8 in a Java 8 World
Developers should start thinking
about tens, hundreds, and
thousands of cores now
“
”- Intel
Parallel processing
is hard
Mutable State
public void setX(int x) {
this.x = x;
}
setX(0)
async { setX(getX()) + 1) }
async { setX(getX()) * 2) }
Scala can help
Functional
Scala vs Java 8 in a Java 8 World
Object Oriented
JVM Based
All logos owned by respective companies.
Isn’t Java 8
enough?
It’s all about
developer
productivity
class	
  Point	
  {	
  
	
  	
  	
  	
  private	
  int	
  x;	
  
	
  	
  	
  	
  private	
  int	
  y;	
  
	
  	
  
	
  	
  	
  	
  public	
  Point(int	
  x,	
  int	
  y)	
  {	
  
	
  	
  	
  	
  	
  	
  setX(x);	
  
	
  	
  	
  	
  	
  	
  setY(y);	
  
	
  	
  	
  	
  }	
  
	
  	
  
	
  	
  	
  	
  public	
  int	
  getX()	
  {	
  return	
  x;	
  }	
  
	
  	
  	
  	
  public	
  void	
  setX(int	
  x)	
  {	
  this.x	
  =	
  x;}	
  
	
  	
  	
  	
  public	
  int	
  getY()	
  {	
  return	
  y;	
  }	
  
	
  	
  	
  	
  public	
  void	
  setY(int	
  y)	
  {	
  this.y	
  =	
  y;}	
  
	
  	
  
	
  	
  	
  	
  public	
  boolean	
  equals(Object	
  other)	
  {	
  
	
  	
  	
  	
  	
  	
  if	
  (other	
  instanceof	
  Point)	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  Point	
  otherPoint	
  =	
  (Point)	
  other;	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  otherPoint.getX()	
  ==	
  getX()	
  &&	
  otherPoint.getY()	
  ==	
  getY();	
  
	
  	
  	
  	
  	
  	
  }	
  else	
  {	
  
	
  	
  	
  	
  	
  	
  	
  	
  return	
  false;	
  
	
  	
  	
  	
  	
  	
  }	
  
	
  	
  	
  	
  }	
  
	
  	
  
	
  	
  	
  	
  public	
  int	
  hashCode()	
  {	
  
	
  	
  	
  	
  	
  	
  return	
  (new	
  Integer[]	
  {getX(),	
  getY()}).hashCode();	
  
	
  	
  	
  	
  }	
  
}
case class Point(var x: Int, var y: Int)
Scala vs Java 8 in a Java 8 World
Traits
abstract class Animal {
def speak
}
trait FourLeggedAnimal {
def walk
def run
}
trait WaggingTail {
val tailLength: Int
def startTail { println("tail started") }
def stopTail { println("tail stopped") }
}
class Dog extends Animal with WaggingTail with FourLeggedAnimal {
def speak { println("Dog says 'woof'") }
def walk { println("Dog is walking") }
def run { println("Dog is running") }
}
Immutable Classes
public final class Point {
private final int x;
private final int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public int getX() { return x; }
public int getY() { return y; }
}
Java
Scala case class Point(x: Int, y: Int)	
  
Immutable Data Structures
Scala
List(1, 2, 3)
Set(1, 2, 3)
Map(("foo", 1), ("bar", 2))	
  
List<Integer> uList = Arrays.asList(1, 2, 3);
Set<Integer> set = new HashSet<>();
set.add(1);
set.add(2);
Set<Integer> uSet = Collections.unmodifiableSet(set);
Map<String, Integer> map = new HashMap<>();
map.put("foo", 1);
map.put("bar", 2);
Map<String, Integer> uMap = Collections.unmodifiableMap(map);
Java
Lambdas
Scala
peoples.filter(person => person.firstName == “Jon”)!
!
peoples.stream().filter( person -> !
person.firstName.equals(”Jon”)).collect(Collectors.toList())
Java
peoples.map(person => person.firstName)
List(1, 2, 3).reduce(_+_) // 6
List(1, 2, 3).foreach(println)
public class Person {
private String lastName;
private String firstName;
private String middleName;
private String salutation;
private String suffix;
public Person(String lastName, String firstName, String middleName,
String salutation, String suffix) {
this.lastName = lastName;
this.firstName = firstName;
this.middleName = middleName;
this.salutation = salutation;
this.suffix = suffix;
}
}
public class Person {
public static class PersonBuilder {
public PersonBuilder lastName(String newLastName) {
this.lastName = newLastName;
return this;
}
public PersonBuilder firstName(String newFirstName) {
this.firstName = newFirstName;
return this;
}
public PersonBuilder middleName(String newMiddleName) {
this.middleName = newMiddleName;
return this;
}
public PersonBuilder salutation(String newSalutation) {
this.salutation = newSalutation;
return this;
}
public PersonBuilder suffix(String newSuffix) {
this.suffix = newSuffix;
return this;
}
public Person build() { return new Person(this); }
}
}
Named and Default Parameters
case class Person(salutation: String = "Unknown", firstName: String = "Unknown”,
middleName: String = "Unknown", lastName: String = "Unknown",
suffix: String = "Unknown")
Person("Mr", "John", "M”, "Doe”, ”Sr")
Person(salutation = "Mr", firstName = "John", lastName = "Doe")
Person(firstName = "John", middleName = "M", lastName = "Doe")
Person(firstName = "John")
Person(lastName = "Doe")
Person(firstName = "John", lastName = "Doe")
Pattern Matching
def	
  parseArgument(arg	
  :	
  String)
Pattern Matching
def	
  parseArgument(arg	
  :	
  String)	
  =	
  arg	
  match	
  {	
  
}	
  
Pattern Matching
def	
  parseArgument(arg	
  :	
  String)	
  =	
  arg	
  match	
  {	
  
	
  	
  case	
  ("-­‐h"	
  |	
  "-­‐-­‐help”)	
  =>	
  displayHelp()	
  
}
Pattern Matching
def	
  parseArgument(arg	
  :	
  String)	
  =	
  arg	
  match	
  {	
  
	
  	
  case	
  ("-­‐h"	
  |	
  "-­‐-­‐help”)	
  =>	
  displayHelp()	
  
	
  	
  case	
  bad	
  =>	
  badArgument(bad)	
  
}
Pattern Matching
def	
  parseArgument(arg	
  :	
  String,	
  value:	
  Any)
Pattern Matching
def	
  parseArgument(arg	
  :	
  String,	
  value:	
  Any)	
  =	
  (arg,	
  value)	
  match	
  {	
  
}	
  
Pattern Matching
def	
  parseArgument(arg	
  :	
  String,	
  value:	
  Any)	
  =	
  (arg,	
  value)	
  match	
  {	
  
	
  	
  case	
  ("-­‐h"	
  |	
  "-­‐-­‐help",	
  null)	
  =>	
  displayHelp()	
  
	
  	
  case	
  ("-­‐l",	
  lang)	
  =>	
  setLanguageTo(lang)	
  
	
  	
  case	
  bad	
  =>	
  badArgument(bad)	
  
}
Pattern Matching
def	
  parseArgument(arg	
  :	
  String,	
  value:	
  Any)	
  =	
  (arg,	
  value)	
  match	
  {	
  
	
  	
  case	
  ("-­‐h"	
  |	
  "-­‐-­‐help",	
  null)	
  =>	
  displayHelp()	
  
	
  	
  case	
  ("-­‐l",	
  lang)	
  =>	
  setLanguageTo(lang)	
  
	
  	
  case	
  ("-­‐o"	
  |	
  "-­‐-­‐optim",	
  n	
  :	
  Int)	
  if	
  ((0	
  <	
  n)	
  &&	
  (n	
  <=	
  5))	
  =>	
  setOptimizationLevelTo(n)	
  
	
  	
  case	
  ("-­‐o"	
  |	
  "-­‐-­‐optim",	
  badLevel)	
  =>	
  badOptimizationLevel(badLevel)	
  
	
  	
  case	
  bad	
  =>	
  badArgument(bad)	
  
}
Patterns
// constant patterns
case 0 => "zero”
case true => "true”
case "hello" => "you said 'hello'”
case Nil => "an empty List"
// sequence patterns
case List(0, _, _) => "a three-element list with 0 as the first element”
case List(1, _*) => "a list beginning with 1, having any number of elements”
case Vector(1, _*) => "a vector starting with 1, having any number of elements”
// constructor patterns
case Person(first, "Alexander") => s"found an Alexander, first name = $first”
case Dog("Suka") => "found a dog named Suka”
I call it my billion-dollar mistake. It
was the invention of the null
reference in 1965.
“
”- Tony Hoare
Option
def toInt(in: String): Option[Int] = {
    try {
        Some(Integer.parseInt(in.trim))
    } catch {
        case ex: NumberFormatException => None
    }
}
toInt(someString) match {
    case Some(i) => println(i)
    case None => println("That didn't work.")
}
Collections with Option
val bag = List("1", "2", "foo", "3", "bar")
bag.map(toInt) // List[Option[Int]] = List(Some(1), Some(2), None, Some(3), None)
bag.flatMap(toInt) // List(1, 2, 3)
Summary
•  Parallel Processing made easier
•  Developer Productivity
•  Java interoperable
•  Still relevant in a Java 8 world
Ad

More Related Content

What's hot (20)

Scala
ScalaScala
Scala
Sven Efftinge
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
Susan Potter
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 
1.2 scala basics
1.2 scala basics1.2 scala basics
1.2 scala basics
futurespective
 
Functional Objects & Function and Closures
Functional Objects  & Function and ClosuresFunctional Objects  & Function and Closures
Functional Objects & Function and Closures
Sandip Kumar
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real World
osfameron
 
Beyond java8
Beyond java8Beyond java8
Beyond java8
Muhammad Durrah
 
scala
scalascala
scala
Pranav E K
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
andyrobinson8
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
intelliyole
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
Codecamp Romania
 
Hammurabi
HammurabiHammurabi
Hammurabi
Mario Fusco
 
All about scala
All about scalaAll about scala
All about scala
Yardena Meymann
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Development
vito jeng
 
Scala on Android
Scala on AndroidScala on Android
Scala on Android
Jakub Kahovec
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
intelliyole
 
Fun never stops. introduction to haskell programming language
Fun never stops. introduction to haskell programming languageFun never stops. introduction to haskell programming language
Fun never stops. introduction to haskell programming language
Pawel Szulc
 
Why Haskell
Why HaskellWhy Haskell
Why Haskell
Susan Potter
 
Stepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to ScalaStepping Up : A Brief Intro to Scala
Stepping Up : A Brief Intro to Scala
Derek Chen-Becker
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
Susan Potter
 
Scala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar ProkopecScala presentation by Aleksandar Prokopec
Scala presentation by Aleksandar Prokopec
Loïc Descotte
 
Functional Objects & Function and Closures
Functional Objects  & Function and ClosuresFunctional Objects  & Function and Closures
Functional Objects & Function and Closures
Sandip Kumar
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real World
osfameron
 
Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)Feel of Kotlin (Berlin JUG 16 Apr 2015)
Feel of Kotlin (Berlin JUG 16 Apr 2015)
intelliyole
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
Codecamp Romania
 
JavaScript Web Development
JavaScript Web DevelopmentJavaScript Web Development
JavaScript Web Development
vito jeng
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
Jonas Bonér
 
Idiomatic Kotlin
Idiomatic KotlinIdiomatic Kotlin
Idiomatic Kotlin
intelliyole
 
Fun never stops. introduction to haskell programming language
Fun never stops. introduction to haskell programming languageFun never stops. introduction to haskell programming language
Fun never stops. introduction to haskell programming language
Pawel Szulc
 

Viewers also liked (20)

Gradle: From Extreme to Mainstream
Gradle: From Extreme to MainstreamGradle: From Extreme to Mainstream
Gradle: From Extreme to Mainstream
BTI360
 
Migrating Legacy Web Applications to AngularJS
Migrating Legacy Web Applications to AngularJSMigrating Legacy Web Applications to AngularJS
Migrating Legacy Web Applications to AngularJS
BTI360
 
AWS Lambda: Coding Without Infrastructure
AWS Lambda: Coding Without InfrastructureAWS Lambda: Coding Without Infrastructure
AWS Lambda: Coding Without Infrastructure
BTI360
 
Learn to Speak AWS
Learn to Speak AWSLearn to Speak AWS
Learn to Speak AWS
BTI360
 
Scala in practice - 3 years later
Scala in practice - 3 years laterScala in practice - 3 years later
Scala in practice - 3 years later
patforna
 
A noobs lesson on solr (configuration)
A noobs lesson on solr (configuration)A noobs lesson on solr (configuration)
A noobs lesson on solr (configuration)
BTI360
 
Tackling Big Data with the Elephant in the Room
Tackling Big Data with the Elephant in the RoomTackling Big Data with the Elephant in the Room
Tackling Big Data with the Elephant in the Room
BTI360
 
Search Concepts & Tools
Search Concepts & ToolsSearch Concepts & Tools
Search Concepts & Tools
BTI360
 
Microservices a Double-Edged Sword
Microservices a Double-Edged SwordMicroservices a Double-Edged Sword
Microservices a Double-Edged Sword
BTI360
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
Graham Tackley
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
BTI360
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
Francesco Usai
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
Enno Runne
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
 
Why Not Make the Transition from Java to Scala?
Why Not Make the Transition from Java to Scala?Why Not Make the Transition from Java to Scala?
Why Not Make the Transition from Java to Scala?
BoldRadius Solutions
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
Brian Hsu
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Mohammad Hossein Rimaz
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Rahul Jain
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
Alex Payne
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim Underwood
 
Gradle: From Extreme to Mainstream
Gradle: From Extreme to MainstreamGradle: From Extreme to Mainstream
Gradle: From Extreme to Mainstream
BTI360
 
Migrating Legacy Web Applications to AngularJS
Migrating Legacy Web Applications to AngularJSMigrating Legacy Web Applications to AngularJS
Migrating Legacy Web Applications to AngularJS
BTI360
 
AWS Lambda: Coding Without Infrastructure
AWS Lambda: Coding Without InfrastructureAWS Lambda: Coding Without Infrastructure
AWS Lambda: Coding Without Infrastructure
BTI360
 
Learn to Speak AWS
Learn to Speak AWSLearn to Speak AWS
Learn to Speak AWS
BTI360
 
Scala in practice - 3 years later
Scala in practice - 3 years laterScala in practice - 3 years later
Scala in practice - 3 years later
patforna
 
A noobs lesson on solr (configuration)
A noobs lesson on solr (configuration)A noobs lesson on solr (configuration)
A noobs lesson on solr (configuration)
BTI360
 
Tackling Big Data with the Elephant in the Room
Tackling Big Data with the Elephant in the RoomTackling Big Data with the Elephant in the Room
Tackling Big Data with the Elephant in the Room
BTI360
 
Search Concepts & Tools
Search Concepts & ToolsSearch Concepts & Tools
Search Concepts & Tools
BTI360
 
Microservices a Double-Edged Sword
Microservices a Double-Edged SwordMicroservices a Double-Edged Sword
Microservices a Double-Edged Sword
BTI360
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
Graham Tackley
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
BTI360
 
Scala For Java Programmers
Scala For Java ProgrammersScala For Java Programmers
Scala For Java Programmers
Enno Runne
 
Spock Testing Framework - The Next Generation
Spock Testing Framework - The Next GenerationSpock Testing Framework - The Next Generation
Spock Testing Framework - The Next Generation
BTI360
 
Why Not Make the Transition from Java to Scala?
Why Not Make the Transition from Java to Scala?Why Not Make the Transition from Java to Scala?
Why Not Make the Transition from Java to Scala?
BoldRadius Solutions
 
Programming Android Application in Scala.
Programming Android Application in Scala.Programming Android Application in Scala.
Programming Android Application in Scala.
Brian Hsu
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Rahul Jain
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim Underwood
 
Ad

Similar to Scala vs Java 8 in a Java 8 World (20)

Scala
ScalaScala
Scala
suraj_atreya
 
Benefits of Kotlin
Benefits of KotlinBenefits of Kotlin
Benefits of Kotlin
Benjamin Waye
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
Aleksandar Prokopec
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
Daniel Blyth
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
Jesper Kamstrup Linnet
 
Scala - en bedre Java?
Scala - en bedre Java?Scala - en bedre Java?
Scala - en bedre Java?
Jesper Kamstrup Linnet
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
bpstudy
 
Scala 2013 review
Scala 2013 reviewScala 2013 review
Scala 2013 review
Sagie Davidovich
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
HamletDRC
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
Paulo Morgado
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
Paulo Morgado
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
William Narmontas
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
Ashal aka JOKER
 
Scala introduction
Scala introductionScala introduction
Scala introduction
Yardena Meymann
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
2.1 recap from-day_one
2.1 recap from-day_one2.1 recap from-day_one
2.1 recap from-day_one
futurespective
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
Thomas Kaiser
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
Scala in a Java 8 World
Scala in a Java 8 WorldScala in a Java 8 World
Scala in a Java 8 World
Daniel Blyth
 
Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?Scala - en bedre og mere effektiv Java?
Scala - en bedre og mere effektiv Java?
Jesper Kamstrup Linnet
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
HamletDRC
 
ハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使うハイブリッド言語Scalaを使う
ハイブリッド言語Scalaを使う
bpstudy
 
Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)Groovy Ast Transformations (greach)
Groovy Ast Transformations (greach)
HamletDRC
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
Paulo Morgado
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
William Narmontas
 
여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language여자개발자모임터 6주년 개발 세미나 - Scala Language
여자개발자모임터 6주년 개발 세미나 - Scala Language
Ashal aka JOKER
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
2.1 recap from-day_one
2.1 recap from-day_one2.1 recap from-day_one
2.1 recap from-day_one
futurespective
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
Thomas Kaiser
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
Ad

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
Transcript: #StandardsGoals for 2025: Standards & certification roundup - Tec...
BookNet Canada
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
AI EngineHost Review: Revolutionary USA Datacenter-Based Hosting with NVIDIA ...
SOFTTECHHUB
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 

Scala vs Java 8 in a Java 8 World

  • 1. Scala in a Java 8 World
  • 2. Takeaways •  Why Scala? •  Scala still relevant in Java 8 world?
  • 3. What do we need in a language?
  • 5. Developers should start thinking about tens, hundreds, and thousands of cores now “ ”- Intel
  • 7. Mutable State public void setX(int x) { this.x = x; } setX(0) async { setX(getX()) + 1) } async { setX(getX()) * 2) }
  • 13. All logos owned by respective companies.
  • 16. class  Point  {          private  int  x;          private  int  y;              public  Point(int  x,  int  y)  {              setX(x);              setY(y);          }              public  int  getX()  {  return  x;  }          public  void  setX(int  x)  {  this.x  =  x;}          public  int  getY()  {  return  y;  }          public  void  setY(int  y)  {  this.y  =  y;}              public  boolean  equals(Object  other)  {              if  (other  instanceof  Point)  {                  Point  otherPoint  =  (Point)  other;                  return  otherPoint.getX()  ==  getX()  &&  otherPoint.getY()  ==  getY();              }  else  {                  return  false;              }          }              public  int  hashCode()  {              return  (new  Integer[]  {getX(),  getY()}).hashCode();          }   }
  • 17. case class Point(var x: Int, var y: Int)
  • 19. Traits abstract class Animal { def speak } trait FourLeggedAnimal { def walk def run } trait WaggingTail { val tailLength: Int def startTail { println("tail started") } def stopTail { println("tail stopped") } } class Dog extends Animal with WaggingTail with FourLeggedAnimal { def speak { println("Dog says 'woof'") } def walk { println("Dog is walking") } def run { println("Dog is running") } }
  • 20. Immutable Classes public final class Point { private final int x; private final int y; public Point(int x, int y) { this.x = x; this.y = y; } public int getX() { return x; } public int getY() { return y; } } Java Scala case class Point(x: Int, y: Int)  
  • 21. Immutable Data Structures Scala List(1, 2, 3) Set(1, 2, 3) Map(("foo", 1), ("bar", 2))   List<Integer> uList = Arrays.asList(1, 2, 3); Set<Integer> set = new HashSet<>(); set.add(1); set.add(2); Set<Integer> uSet = Collections.unmodifiableSet(set); Map<String, Integer> map = new HashMap<>(); map.put("foo", 1); map.put("bar", 2); Map<String, Integer> uMap = Collections.unmodifiableMap(map); Java
  • 22. Lambdas Scala peoples.filter(person => person.firstName == “Jon”)! ! peoples.stream().filter( person -> ! person.firstName.equals(”Jon”)).collect(Collectors.toList()) Java peoples.map(person => person.firstName) List(1, 2, 3).reduce(_+_) // 6 List(1, 2, 3).foreach(println)
  • 23. public class Person { private String lastName; private String firstName; private String middleName; private String salutation; private String suffix; public Person(String lastName, String firstName, String middleName, String salutation, String suffix) { this.lastName = lastName; this.firstName = firstName; this.middleName = middleName; this.salutation = salutation; this.suffix = suffix; } }
  • 24. public class Person { public static class PersonBuilder { public PersonBuilder lastName(String newLastName) { this.lastName = newLastName; return this; } public PersonBuilder firstName(String newFirstName) { this.firstName = newFirstName; return this; } public PersonBuilder middleName(String newMiddleName) { this.middleName = newMiddleName; return this; } public PersonBuilder salutation(String newSalutation) { this.salutation = newSalutation; return this; } public PersonBuilder suffix(String newSuffix) { this.suffix = newSuffix; return this; } public Person build() { return new Person(this); } } }
  • 25. Named and Default Parameters case class Person(salutation: String = "Unknown", firstName: String = "Unknown”, middleName: String = "Unknown", lastName: String = "Unknown", suffix: String = "Unknown") Person("Mr", "John", "M”, "Doe”, ”Sr") Person(salutation = "Mr", firstName = "John", lastName = "Doe") Person(firstName = "John", middleName = "M", lastName = "Doe") Person(firstName = "John") Person(lastName = "Doe") Person(firstName = "John", lastName = "Doe")
  • 27. Pattern Matching def  parseArgument(arg  :  String)  =  arg  match  {   }  
  • 28. Pattern Matching def  parseArgument(arg  :  String)  =  arg  match  {      case  ("-­‐h"  |  "-­‐-­‐help”)  =>  displayHelp()   }
  • 29. Pattern Matching def  parseArgument(arg  :  String)  =  arg  match  {      case  ("-­‐h"  |  "-­‐-­‐help”)  =>  displayHelp()      case  bad  =>  badArgument(bad)   }
  • 30. Pattern Matching def  parseArgument(arg  :  String,  value:  Any)
  • 31. Pattern Matching def  parseArgument(arg  :  String,  value:  Any)  =  (arg,  value)  match  {   }  
  • 32. Pattern Matching def  parseArgument(arg  :  String,  value:  Any)  =  (arg,  value)  match  {      case  ("-­‐h"  |  "-­‐-­‐help",  null)  =>  displayHelp()      case  ("-­‐l",  lang)  =>  setLanguageTo(lang)      case  bad  =>  badArgument(bad)   }
  • 33. Pattern Matching def  parseArgument(arg  :  String,  value:  Any)  =  (arg,  value)  match  {      case  ("-­‐h"  |  "-­‐-­‐help",  null)  =>  displayHelp()      case  ("-­‐l",  lang)  =>  setLanguageTo(lang)      case  ("-­‐o"  |  "-­‐-­‐optim",  n  :  Int)  if  ((0  <  n)  &&  (n  <=  5))  =>  setOptimizationLevelTo(n)      case  ("-­‐o"  |  "-­‐-­‐optim",  badLevel)  =>  badOptimizationLevel(badLevel)      case  bad  =>  badArgument(bad)   }
  • 34. Patterns // constant patterns case 0 => "zero” case true => "true” case "hello" => "you said 'hello'” case Nil => "an empty List" // sequence patterns case List(0, _, _) => "a three-element list with 0 as the first element” case List(1, _*) => "a list beginning with 1, having any number of elements” case Vector(1, _*) => "a vector starting with 1, having any number of elements” // constructor patterns case Person(first, "Alexander") => s"found an Alexander, first name = $first” case Dog("Suka") => "found a dog named Suka”
  • 35. I call it my billion-dollar mistake. It was the invention of the null reference in 1965. “ ”- Tony Hoare
  • 36. Option def toInt(in: String): Option[Int] = {     try {         Some(Integer.parseInt(in.trim))     } catch {         case ex: NumberFormatException => None     } } toInt(someString) match {     case Some(i) => println(i)     case None => println("That didn't work.") }
  • 37. Collections with Option val bag = List("1", "2", "foo", "3", "bar") bag.map(toInt) // List[Option[Int]] = List(Some(1), Some(2), None, Some(3), None) bag.flatMap(toInt) // List(1, 2, 3)
  • 38. Summary •  Parallel Processing made easier •  Developer Productivity •  Java interoperable •  Still relevant in a Java 8 world