SlideShare a Scribd company logo
SCALA :GOOD/BAD PARTS
Xuefeng.Wu
2014.01.07
PROGRAMMING
GOOD PARTS
bad parts?
PROGRAMMING
PARADIGM
A programming paradigm is a fundamental style of computer
programming, a way of building the structure and elements of
computer programs.
!

There are five main paradigms: imperative, functional, objectoriented, logic and symbolic programming.
PROGRAMMING
PARADIGMS
Turing Machine: Imperative Programming
Turing Machine: Object-oriented Programming
λ-calculus: Functional Programming
First-order logic: Logic Programming
PROGRAMMING
PARADIGMS
!

Turing Machine: Object-oriented Programming
λ-calculus: Functional Programming
OBJECT-ORIENTED
PROGRAMMING
An object has state (data) and behaviour (code).
is an approach to designing modular reusable software systems.
Increased understanding
Ease of maintenance
encapsulation and information hiding
Ease of evolution
inheritance and polymorphism
INCREASED
UNDERSTANDING
Less Code

write less code

Less Logic
Less new things
no surprise

solve problem
EASE OF EVOLUTION
change self and not affect others

be careful of dependence
be careful of status
change object: data and behaviour
always together?
FUNCTIONAL
PROGRAMMING
computation as the evaluation of mathematical functions
and avoids state and mutable data.
emphasises functions that produce results that
depend only on inputs and not on the program state

Increased understanding
Ease of maintenance
Ease of evolution
Effective ?

FP / OO
FP

immutable

OO

encapsulation
WHAT IS SCALA
Scala (/ˈskɑːlə/ skah-lə) is an object-functional
programming and scripting language for general software
applications, statically typed
designed to concisely express solutions in an elegant,
type-safe and lightweight (low ceremonial) manner.
Scala has full support for functional programming
(including currying, pattern matching, algebraic data
types, lazy evaluation, tail recursion, immutability, etc.).
SHOW ME YOUR CODE
Java

Scala

public class Point {




private int x;

private int y;




public Point(int x, int y) {

this.x = x;

this.y = y;

}







public
public
public
public
}

int getX() {return x;}

int getY() {return y;}

void setX(int x) {this.x = x;}

void setY(int y) {this.y = y;}


case class Point(x: Int, y: Int)

Java
List filtered = new ArrayList<Point>();

for(Point p:points){

if(p.y > 0) {

filtered.add(p);

}

}







Collections.sort(points, new
Comparator<Point>() {

public int compare(Point p0, Point p1)
{

return p1.getX() - p0.getX();

}

});

return points;

Scala

points.filter(_.y > 0).sortBy(_.x)
public boolean checkPrime(int number) {

// checks if a number between 1 and 10 is prime

switch (number) {

case 1: return true;

case 2: return true;

case 3: return true;

case 5: return true;

case 7: return true;


Java




default: return false;

}

}

businessResult match {

case OKResult(createdAccount: CreatedAccount) => Created
case FailedResult(emailAlreadyExists) => Conflict
…

case FailedResult(_) => BadRequest


Scala
}
AN INTERN
Worker: salary

Student: courses

Employee: company

Intern

trait
trait
trait
trait
class

Person

Employee extends Person

Student extends Person

Worker extends Person

Intern extends Person with Employee with Student with Worker

* Scala’s Stackable Trait Pattern
Java
public class Quicksort {

private int[] numbers;

private int number;




public void sort(int[] values) {

if (values ==null || values.length==0){

return;

}

this.numbers = values;

number = values.length;

quicksort(0, number - 1);

}




}

private void quickSort(int low, int high) {

int i = low, j = high;

int pivot = numbers[low + (high-low)/2];

while (i <= j) {

while (numbers[i] < pivot) {

i++;

}

while (numbers[j] > pivot) {

j--;

}

if (i <= j) {

exchange(i, j);

i++;

j--;

}

}

// Recursion

if (low < j)

quicksort(low, j);

if (i < high)

quicksort(i, high);

}

private void exchange(int i, int j) {

int temp = numbers[i];

numbers[i] = numbers[j];

numbers[j] = temp;

}


Scala

def quickSort[T <: Ordered[T]](list: List[T]):
List[T] = {

list match {

case Nil => Nil

case x::xs =>

val (before, after) = xs partition (_ < x)

quickSort(before) ++ (x :: quickSort(after))

}

}
ENDLESS
scalaz

Haskell

sealed trait KiloGram
def KiloGram[A](a: A): A @@ KiloGram = Tag[A, KiloGram](a)
val mass = KiloGram(20.0)
2 * mass
res: Double = 40.0

case class KiloGram(value: Double)
val mass = KiloGram(20.0)
2 * mass.value
A NUMBER OF
COMPLAINTS
Compile Times - TDD
Libraries and the Community invocation syntax & terrible
documentation
Magic Syntax - ∼, — !!
Everything is a Type - HTTP
request/response cycle.
‘Local’ Type Inference - Scala can’t
perform full type inference across
your program
LEARN CURL

MOOC :Functional Programming Principles in Scala
INCOMPATIBLE
orm

PK

Storm

lime
KILLER
Scala the good and bad parts
Scala the good and bad parts

More Related Content

What's hot

Comparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value TypesComparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value Types
Péter Verhás
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
SadhanaParameswaran
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
SadhanaParameswaran
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
SadhanaParameswaran
 
Lambdas
LambdasLambdas
Lambdas
malliksunkara
 
java token
java tokenjava token
java token
Jadavsejal
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8
JavaBrahman
 
Object Oriented Programming : Part 2
Object Oriented Programming : Part 2Object Oriented Programming : Part 2
Object Oriented Programming : Part 2
Madhavan Malolan
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Hitesh Kumar
 
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and AkkaGeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNightHyderabad
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
brainsmartlabsedu
 
Java principles
Java principlesJava principles
Java principles
Adel Jaffan
 
C++ to java
C++ to javaC++ to java
C++ to java
Ajmal Ak
 
P 3 object_oriented_programming
P 3 object_oriented_programmingP 3 object_oriented_programming
P 3 object_oriented_programming
Irfan Wahyudin
 
Java tokens
Java tokensJava tokens
Java tokens
shalinikarunakaran1
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
Sujit Majety
 
Javascript for Intermediates
Javascript for IntermediatesJavascript for Intermediates
Javascript for Intermediates
Ankit Agrawal
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
HuffPost Code
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
Ryan Riley
 

What's hot (20)

Comparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value TypesComparing Golang and understanding Java Value Types
Comparing Golang and understanding Java Value Types
 
Learn To Code: Diving deep into java
Learn To Code: Diving deep into javaLearn To Code: Diving deep into java
Learn To Code: Diving deep into java
 
Final keyword
Final keywordFinal keyword
Final keyword
 
Learn To Code: Introduction to c
Learn To Code: Introduction to cLearn To Code: Introduction to c
Learn To Code: Introduction to c
 
Learn To Code: Introduction to java
Learn To Code: Introduction to javaLearn To Code: Introduction to java
Learn To Code: Introduction to java
 
Lambdas
LambdasLambdas
Lambdas
 
java token
java tokenjava token
java token
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8
 
Object Oriented Programming : Part 2
Object Oriented Programming : Part 2Object Oriented Programming : Part 2
Object Oriented Programming : Part 2
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and AkkaGeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
 
Java principles
Java principlesJava principles
Java principles
 
C++ to java
C++ to javaC++ to java
C++ to java
 
P 3 object_oriented_programming
P 3 object_oriented_programmingP 3 object_oriented_programming
P 3 object_oriented_programming
 
Java tokens
Java tokensJava tokens
Java tokens
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Javascript for Intermediates
Javascript for IntermediatesJavascript for Intermediates
Javascript for Intermediates
 
An Intro to Scala for PHP Developers
An Intro to Scala for PHP DevelopersAn Intro to Scala for PHP Developers
An Intro to Scala for PHP Developers
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 

Viewers also liked

Why Scala Is Taking Over the Big Data World
Why Scala Is Taking Over the Big Data WorldWhy Scala Is Taking Over the Big Data World
Why Scala Is Taking Over the Big Data World
Dean Wampler
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
Martin Odersky
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
Marius Soutier
 
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
 
Advanced Functional Programming in Scala
Advanced Functional Programming in ScalaAdvanced Functional Programming in Scala
Advanced Functional Programming in Scala
Patrick Nicolas
 
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
 

Viewers also liked (7)

Why Scala Is Taking Over the Big Data World
Why Scala Is Taking Over the Big Data WorldWhy Scala Is Taking Over the Big Data World
Why Scala Is Taking Over the Big Data World
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Intro to Apache Spark
Intro to Apache SparkIntro to Apache Spark
Intro to Apache Spark
 
Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)Pragmatic Real-World Scala (short version)
Pragmatic Real-World Scala (short version)
 
Advanced Functional Programming in Scala
Advanced Functional Programming in ScalaAdvanced Functional Programming in Scala
Advanced Functional Programming in Scala
 
Why Scala?
Why Scala?Why Scala?
Why Scala?
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 

Similar to Scala the good and bad parts

Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
RichardWarburton
 
Simplifying Software Correctness
Simplifying Software CorrectnessSimplifying Software Correctness
Simplifying Software Correctness
Caleb Callaway
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
Janie Clayton
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
parveen837153
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
Sohail Shaghasi
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
Janie Clayton
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
Aapo Kyrölä
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
Narendran Solai Sridharan
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
Kent Huang
 
Minds-on DDD
Minds-on DDDMinds-on DDD
Minds-on DDD
Paulo Gandra de Sousa
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
RichardWarburton
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Make Mannan
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
Bansilal Haudakari
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
Yuan Wang
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software Architecture
Jayaram Sankaranarayanan
 
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptxjava sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
ZakiyaSultana7
 
Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987
乐群 陈
 
L04 Software Design Examples
L04 Software Design ExamplesL04 Software Design Examples
L04 Software Design Examples
Ólafur Andri Ragnarsson
 
Vendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptxVendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptx
Guillaume Saint Etienne
 
Write codeforhumans
Write codeforhumansWrite codeforhumans
Write codeforhumans
Narendran R
 

Similar to Scala the good and bad parts (20)

Twins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional ProgrammingTwins: Object Oriented Programming and Functional Programming
Twins: Object Oriented Programming and Functional Programming
 
Simplifying Software Correctness
Simplifying Software CorrectnessSimplifying Software Correctness
Simplifying Software Correctness
 
Thinking In Swift
Thinking In SwiftThinking In Swift
Thinking In Swift
 
Unit I Advanced Java Programming Course
Unit I   Advanced Java Programming CourseUnit I   Advanced Java Programming Course
Unit I Advanced Java Programming Course
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Robots in Swift
Robots in SwiftRobots in Swift
Robots in Swift
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
 
Minds-on DDD
Minds-on DDDMinds-on DDD
Minds-on DDD
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
 
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org)  (usef...
Lab manual object oriented technology (it 303 rgpv) (usefulsearch.org) (usef...
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Beyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software ArchitectureBeyond PITS, Functional Principles for Software Architecture
Beyond PITS, Functional Principles for Software Architecture
 
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptxjava sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
java sql hibernate and springsDAKSHAYINI 3BR19EE026.pptx
 
Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987Compiler2016 by abcdabcd987
Compiler2016 by abcdabcd987
 
L04 Software Design Examples
L04 Software Design ExamplesL04 Software Design Examples
L04 Software Design Examples
 
Vendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptxVendredi Tech_ la programmation fonctionnelle.pptx
Vendredi Tech_ la programmation fonctionnelle.pptx
 
Write codeforhumans
Write codeforhumansWrite codeforhumans
Write codeforhumans
 

Recently uploaded

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 

Recently uploaded (20)

Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 

Scala the good and bad parts

  • 3. PROGRAMMING PARADIGM A programming paradigm is a fundamental style of computer programming, a way of building the structure and elements of computer programs. ! There are five main paradigms: imperative, functional, objectoriented, logic and symbolic programming.
  • 4. PROGRAMMING PARADIGMS Turing Machine: Imperative Programming Turing Machine: Object-oriented Programming λ-calculus: Functional Programming First-order logic: Logic Programming
  • 5. PROGRAMMING PARADIGMS ! Turing Machine: Object-oriented Programming λ-calculus: Functional Programming
  • 6. OBJECT-ORIENTED PROGRAMMING An object has state (data) and behaviour (code). is an approach to designing modular reusable software systems. Increased understanding Ease of maintenance encapsulation and information hiding Ease of evolution inheritance and polymorphism
  • 7. INCREASED UNDERSTANDING Less Code write less code Less Logic Less new things no surprise solve problem
  • 8. EASE OF EVOLUTION change self and not affect others be careful of dependence be careful of status change object: data and behaviour always together?
  • 9. FUNCTIONAL PROGRAMMING computation as the evaluation of mathematical functions and avoids state and mutable data. emphasises functions that produce results that depend only on inputs and not on the program state Increased understanding Ease of maintenance Ease of evolution Effective ? FP / OO
  • 11. WHAT IS SCALA Scala (/ˈskɑːlə/ skah-lə) is an object-functional programming and scripting language for general software applications, statically typed designed to concisely express solutions in an elegant, type-safe and lightweight (low ceremonial) manner. Scala has full support for functional programming (including currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.).
  • 12. SHOW ME YOUR CODE
  • 13. Java Scala public class Point {
 
 private int x;
 private int y;
 
 public Point(int x, int y) {
 this.x = x;
 this.y = y;
 }
 
 
 public public public public } int getX() {return x;}
 int getY() {return y;}
 void setX(int x) {this.x = x;}
 void setY(int y) {this.y = y;}
 case class Point(x: Int, y: Int)

  • 14. Java List filtered = new ArrayList<Point>();
 for(Point p:points){
 if(p.y > 0) {
 filtered.add(p);
 }
 }
 
 
 Collections.sort(points, new Comparator<Point>() {
 public int compare(Point p0, Point p1) {
 return p1.getX() - p0.getX();
 }
 });
 return points; Scala points.filter(_.y > 0).sortBy(_.x)
  • 15. public boolean checkPrime(int number) {
 // checks if a number between 1 and 10 is prime
 switch (number) {
 case 1: return true;
 case 2: return true;
 case 3: return true;
 case 5: return true;
 case 7: return true;
 Java 
 default: return false;
 }
 } businessResult match {
 case OKResult(createdAccount: CreatedAccount) => Created case FailedResult(emailAlreadyExists) => Conflict …
 case FailedResult(_) => BadRequest
 Scala }
  • 16. AN INTERN Worker: salary Student: courses Employee: company Intern trait trait trait trait class Person
 Employee extends Person
 Student extends Person
 Worker extends Person
 Intern extends Person with Employee with Student with Worker * Scala’s Stackable Trait Pattern
  • 17. Java public class Quicksort {
 private int[] numbers;
 private int number;
 
 public void sort(int[] values) {
 if (values ==null || values.length==0){
 return;
 }
 this.numbers = values;
 number = values.length;
 quicksort(0, number - 1);
 }
 
 } private void quickSort(int low, int high) {
 int i = low, j = high;
 int pivot = numbers[low + (high-low)/2];
 while (i <= j) {
 while (numbers[i] < pivot) {
 i++;
 }
 while (numbers[j] > pivot) {
 j--;
 }
 if (i <= j) {
 exchange(i, j);
 i++;
 j--;
 }
 }
 // Recursion
 if (low < j)
 quicksort(low, j);
 if (i < high)
 quicksort(i, high);
 }
 private void exchange(int i, int j) {
 int temp = numbers[i];
 numbers[i] = numbers[j];
 numbers[j] = temp;
 }
 Scala def quickSort[T <: Ordered[T]](list: List[T]): List[T] = {
 list match {
 case Nil => Nil
 case x::xs =>
 val (before, after) = xs partition (_ < x)
 quickSort(before) ++ (x :: quickSort(after))
 }
 }
  • 18. ENDLESS scalaz Haskell sealed trait KiloGram def KiloGram[A](a: A): A @@ KiloGram = Tag[A, KiloGram](a) val mass = KiloGram(20.0) 2 * mass res: Double = 40.0 case class KiloGram(value: Double) val mass = KiloGram(20.0) 2 * mass.value
  • 19. A NUMBER OF COMPLAINTS Compile Times - TDD Libraries and the Community invocation syntax & terrible documentation Magic Syntax - ∼, — !! Everything is a Type - HTTP request/response cycle. ‘Local’ Type Inference - Scala can’t perform full type inference across your program
  • 20. LEARN CURL MOOC :Functional Programming Principles in Scala
  • 22.
  • 23.