SlideShare a Scribd company logo
Meet-up, May 28, 2015, Launchpad, Bangkok
Roland Petrasch & Brian Topping
Welcome!
SET Meet-up
Programming with Scala
Agenda
SET — Software Engineering Thailand
Programming with Scala – Prequel
(speaker: Roland Petrasch)
Type Systems / Data Types
Functional Programming
Combination of OOP and FP
Programming with Scala -
Object-Oriented meets Functional
(Speaker: Brian Topping)
Discussion
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 2
Programming
Debugging
Debugging
Programming
SET — Software Engineering Thailand
The Interest Group from & (not only) for Developers
Open Group: Members, Sponsors and Organizers welcome
Next topics: HCI Patterns, Scrum, Model-Based UID, Agile Testing,
Software Architectures & Frameworks, S.O.L.I.D. & Co., UML ...
Contact
Roland Petrasch, Professor for Software Engineering
Thammasat University, Department of Computer Science,
Rangsit Campus, Pathum Thani
roland.petrasch@cs.tu.ac.th
roland.petrasch@gmail.com
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 3
Type system
Ruleset: assign types to variables, expressions, functions
Error prevention (type errors), e.g. float calculateThrust(Position p)
Other purposes: documentation, compiler optimization
Evolution
Type safety: type checking
During compile-time (static typing), e.g. C++, C#, Java, Scala
During run-time (dynamic typing), e.g. JavaScript, Ruby, Python
Combination, e.g. C# 4.0 (dynamic)
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 4
Untyped Primitive Data Types Abstract Data Types Classes …
Assembler Fortran, Pascal, C C++, Java, C#
JavaScript: dynamic typing, implicit type conversion, type inference
var five = '5', two = 2, sth;
sth = five * two; → 10
sth = five + two; → 52
sth = five + two * 5; → 510
sth = five + two * 5 + true; → 510true
sth = five + two * 5 + true / 10; → 5100.1
sth = (five + two * 5 + true) / 10; → NaN
Sth = 10 / 0; → Infinity
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 5
Type system
Type inference: automatically deduce the type at compile time
partly or completely, e.g. var i = 5; // inferred type: int
Type inference is not only a feature of dynamically typed languages
Static/dynamic typing and strong/weak typing are orthogonal:
Many discussions about strong and weak typing, no precise definition
Weak typing: use a value of one type as if it were a value of another type,
e.g. in C: char c = 'A'; c++; c=42;
or in JavaScript: var s = 'x' + 3; // get 'x3'
Strong typing
e.g. in Java: String s = "1" + ' ' * 2 + false; // 164false
int i = '3' * 2.2; // error
Importance of „strong” and semantically rich data types
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 6
To a C programmer
strong typing means
pressing the keys
harder
Data Types
Data Types and type checking is very (!) important
Example: float calculateThrust(Position p)
2 software components:
One is providing and another one is using
the calculateThrust function
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 7
Mars Lander by Brian McMullin
Source: Defense Intelligence
Agency, DoD, USA
ThrustContolUnit
NavigationSystem
calculateThrust(Position p)Call
Germany USA
The thrust is a float. A good data type? Yes? Okay? Right?
No: Sematics (unit) not clear: Can be „newton” (metric) or
„pound-force” (non metric) → sematically poor in this case
Semantically rich data types and error prevention
„NASA lost a $125 million Mars orbiter because one
engineering team used metric units while another
used English units for a key spacecraft operation.“
(http://edition.cnn.com/TECH/space/9909/30/mars.metric/)
Example 2.0:
Thrust calculateThrust(Position p)
A new data type Thrust is needed
class Thrust {
private Unit unit;
private Value value;
public float getValue(Unit unit) …
}
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 8
Mars Polar Lander
Source: NASA
Functional programming
Declarative programming paradigm
Evaluation of functions, avoids changing-state & mutable data,
eliminate side-effects
Functions: output depends only on input → error prevention
Example for side-effect in Java
int i=0;
if (true != false || ++i==0) { }
System.out.println(i); // i is 0
Based on lambda calculus for simple semantics for computation
Anonymous Functions (→ closures), no explicit names
Functions of a single input
Example (λx.x+1) 4 → 4+1 → 5
-function
-expression computaton
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 9

Functional programming
λ-Example 2.0
(λx.x+2)((λy.y*10)4)
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 10
Alonzo Church (1903–1995),
Photo: Wikipedia
"Answer to the Ultimate Question of
Life, the Universe, and Everything“
(The Hitchhiker's Guide to the Galaxy)
Combination of object-oriented and functional paradigms
OO and FP have similarities, e.g.
Expressive power (semantics)
Encapsulation of small parts (reduction of complexity)
Data types
...
OOP: High in cohesion (class consists of data and functions) and
low in coupling (classes should be independent as far as possible)
FP: Data is only loosely coupled to functions, functions hide their
implementation, immutability, no side-effects
Multi-paradigm languages like Scala combine the features from
object-oriented and functional paradigms
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 11
Combination of Object-oriented and Functional (object-functional)
OOP & FP are orthogonal concepts, i.e. they are not contradictory, e.g.
encapsulation, inheritance, polymorphism, abstration do not imply mutability
SET Meet-up
Programming with Scala - Prequel
Roland Petrasch28.5.2015, SET Meet-up
Programming with Scala - Prequel
Slide 12
calcValue
IntegerValue
Class
calcValue
OO: Every value is an object; attributes & behavior of an object are
described by a class; objects are instances of a class)
FP: Every function is a value; and every value is an object
→ so every function is an object
This was the little prequel,
thank you for your attention
SET Meet-up
Programming with Scala - Prequel
Brian Topping
Entrepreneurial, results-oriented architect
Developer and leader with > 20 years
experience
Companies: Apple, Oracle, Nokia, AT&T,
Intel and Bloomberg.
Dozens of programming & scripting
languages, OS, and IDE

More Related Content

What's hot

Python training
Python trainingPython training
Python training
saijohn1997
 
Python Concepts
Python ConceptsPython Concepts
Python Concepts
saipreethi16
 
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013  Introduction to Parsing with ANTLR4Code Generation Cambridge 2013  Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4Oliver Zeigermann
 
KOSIMap @ DL2010
KOSIMap @ DL2010KOSIMap @ DL2010
KOSIMap @ DL2010
Quentin Reul
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Python
jyostna bodapati
 
1 cs xii_python_functions_introduction _types of func
1 cs xii_python_functions_introduction _types of func1 cs xii_python_functions_introduction _types of func
1 cs xii_python_functions_introduction _types of func
SanjayKumarMahto1
 

What's hot (7)

Python training
Python trainingPython training
Python training
 
Python Concepts
Python ConceptsPython Concepts
Python Concepts
 
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013  Introduction to Parsing with ANTLR4Code Generation Cambridge 2013  Introduction to Parsing with ANTLR4
Code Generation Cambridge 2013 Introduction to Parsing with ANTLR4
 
Slides
SlidesSlides
Slides
 
KOSIMap @ DL2010
KOSIMap @ DL2010KOSIMap @ DL2010
KOSIMap @ DL2010
 
Numeric Data types in Python
Numeric Data types in PythonNumeric Data types in Python
Numeric Data types in Python
 
1 cs xii_python_functions_introduction _types of func
1 cs xii_python_functions_introduction _types of func1 cs xii_python_functions_introduction _types of func
1 cs xii_python_functions_introduction _types of func
 

Viewers also liked

SET 3 - Introduction to Scrum
SET 3 - Introduction to ScrumSET 3 - Introduction to Scrum
SET 3 - Introduction to Scrum
Prof. Dr. Roland Petrasch
 
S.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developersS.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developers
Prof. Dr. Roland Petrasch
 
20160229 SET Meetup Internet of Things
20160229 SET Meetup Internet of Things20160229 SET Meetup Internet of Things
20160229 SET Meetup Internet of Things
Prof. Dr. Roland Petrasch
 
Průzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
Průzkum informačních portálů v souvislosti s informacemi o VŠ v HolandskuPrůzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
Průzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
MŠMT IPN KREDO
 
Cuestionario cop resuelto
Cuestionario cop resueltoCuestionario cop resuelto
Cuestionario cop resuelto
Elizabeth Morales
 
It project administrator performance appraisal
It project administrator performance appraisalIt project administrator performance appraisal
It project administrator performance appraisal
lucastorres040
 
2016 01 lettre de la pédagogie entpe
2016 01 lettre de la pédagogie entpe2016 01 lettre de la pédagogie entpe
Valorizzazione cereali minori di montagna in provincia di brescia
Valorizzazione cereali minori di montagna in provincia di bresciaValorizzazione cereali minori di montagna in provincia di brescia
Valorizzazione cereali minori di montagna in provincia di brescia
Marco Garoffolo
 
Absolutism: A case study in France
Absolutism: A case study in FranceAbsolutism: A case study in France
Absolutism: A case study in FranceColleen Skadl
 
BBR WIZER | FOOD TRENDS 2016
BBR WIZER | FOOD TRENDS 2016BBR WIZER | FOOD TRENDS 2016
BBR WIZER | FOOD TRENDS 2016
BBR Israel
 
SET Software Engineering Thailand Meeting: HCI / Usability Patterns
SET Software Engineering Thailand Meeting: HCI / Usability PatternsSET Software Engineering Thailand Meeting: HCI / Usability Patterns
SET Software Engineering Thailand Meeting: HCI / Usability Patterns
Prof. Dr. Roland Petrasch
 
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCIL
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCILGJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCIL
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCILRaj Sohanda
 
Contoh soal uas penjas ganjil 2015
Contoh soal uas penjas ganjil 2015Contoh soal uas penjas ganjil 2015
Contoh soal uas penjas ganjil 2015
maman rq
 
Giao trinh c_can_ban
Giao trinh c_can_banGiao trinh c_can_ban
Giao trinh c_can_bankatakhung89
 
Αλέκος Ξένος - Χρονολόγιο
Αλέκος Ξένος - ΧρονολόγιοΑλέκος Ξένος - Χρονολόγιο
Αλέκος Ξένος - Χρονολόγιο
stegichorus
 
Mpp04 531-l23&24 v
Mpp04 531-l23&24 vMpp04 531-l23&24 v
Mpp04 531-l23&24 vhangc301
 
Simulado 1 gabarito
Simulado 1 gabaritoSimulado 1 gabarito
Simulado 1 gabarito
PROFESSOR FABRÍCIO
 

Viewers also liked (19)

Dilek sunum
Dilek sunumDilek sunum
Dilek sunum
 
Sedat akbal
Sedat akbalSedat akbal
Sedat akbal
 
SET 3 - Introduction to Scrum
SET 3 - Introduction to ScrumSET 3 - Introduction to Scrum
SET 3 - Introduction to Scrum
 
S.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developersS.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developers
 
20160229 SET Meetup Internet of Things
20160229 SET Meetup Internet of Things20160229 SET Meetup Internet of Things
20160229 SET Meetup Internet of Things
 
Průzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
Průzkum informačních portálů v souvislosti s informacemi o VŠ v HolandskuPrůzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
Průzkum informačních portálů v souvislosti s informacemi o VŠ v Holandsku
 
Cuestionario cop resuelto
Cuestionario cop resueltoCuestionario cop resuelto
Cuestionario cop resuelto
 
It project administrator performance appraisal
It project administrator performance appraisalIt project administrator performance appraisal
It project administrator performance appraisal
 
2016 01 lettre de la pédagogie entpe
2016 01 lettre de la pédagogie entpe2016 01 lettre de la pédagogie entpe
2016 01 lettre de la pédagogie entpe
 
Valorizzazione cereali minori di montagna in provincia di brescia
Valorizzazione cereali minori di montagna in provincia di bresciaValorizzazione cereali minori di montagna in provincia di brescia
Valorizzazione cereali minori di montagna in provincia di brescia
 
Absolutism: A case study in France
Absolutism: A case study in FranceAbsolutism: A case study in France
Absolutism: A case study in France
 
BBR WIZER | FOOD TRENDS 2016
BBR WIZER | FOOD TRENDS 2016BBR WIZER | FOOD TRENDS 2016
BBR WIZER | FOOD TRENDS 2016
 
SET Software Engineering Thailand Meeting: HCI / Usability Patterns
SET Software Engineering Thailand Meeting: HCI / Usability PatternsSET Software Engineering Thailand Meeting: HCI / Usability Patterns
SET Software Engineering Thailand Meeting: HCI / Usability Patterns
 
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCIL
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCILGJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCIL
GJEPC ---- THE GEM & JEWELLERY EXPORT PROMOTION COUNCIL
 
Contoh soal uas penjas ganjil 2015
Contoh soal uas penjas ganjil 2015Contoh soal uas penjas ganjil 2015
Contoh soal uas penjas ganjil 2015
 
Giao trinh c_can_ban
Giao trinh c_can_banGiao trinh c_can_ban
Giao trinh c_can_ban
 
Αλέκος Ξένος - Χρονολόγιο
Αλέκος Ξένος - ΧρονολόγιοΑλέκος Ξένος - Χρονολόγιο
Αλέκος Ξένος - Χρονολόγιο
 
Mpp04 531-l23&24 v
Mpp04 531-l23&24 vMpp04 531-l23&24 v
Mpp04 531-l23&24 v
 
Simulado 1 gabarito
Simulado 1 gabaritoSimulado 1 gabarito
Simulado 1 gabarito
 

Similar to SET Software Engineering Thailand Meeting: Functional Programming with Scala - Prequel

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
Martin Odersky
 
ParaSail
ParaSail  ParaSail
ParaSail
AdaCore
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
Roberto Casadei
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
ppd1961
 
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
 
Devoxx
DevoxxDevoxx
Expressive Query Answering For Semantic Wikis (20min)
Expressive Query Answering For  Semantic Wikis (20min)Expressive Query Answering For  Semantic Wikis (20min)
Expressive Query Answering For Semantic Wikis (20min)
Jie Bao
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
Aapo Kyrölä
 
Basics java programing
Basics java programingBasics java programing
Basics java programing
Darshan Gohel
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesEelco Visser
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdfHiroshi Ono
 
Object Oriented Programming in Matlab
Object Oriented Programming in Matlab Object Oriented Programming in Matlab
Object Oriented Programming in Matlab
AlbanLevy
 
F# Intro for Scala Developers
F# Intro for Scala DevelopersF# Intro for Scala Developers
F# Intro for Scala Developers
fsug
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory buildingClarkTony
 
Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)
Ralf Laemmel
 
GATE, HLT and Machine Learning, Sheffield, July 2003
GATE, HLT and Machine Learning, Sheffield, July 2003GATE, HLT and Machine Learning, Sheffield, July 2003
GATE, HLT and Machine Learning, Sheffield, July 2003butest
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
Jimin Hsieh
 

Similar to SET Software Engineering Thailand Meeting: Functional Programming with Scala - Prequel (20)

Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
ParaSail
ParaSail  ParaSail
ParaSail
 
Programming in Scala: Notes
Programming in Scala: NotesProgramming in Scala: Notes
Programming in Scala: Notes
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
Scala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentationScala - The Simple Parts, SFScala presentation
Scala - The Simple Parts, SFScala presentation
 
Devoxx
DevoxxDevoxx
Devoxx
 
Expressive Query Answering For Semantic Wikis (20min)
Expressive Query Answering For  Semantic Wikis (20min)Expressive Query Answering For  Semantic Wikis (20min)
Expressive Query Answering For Semantic Wikis (20min)
 
About Functional Programming
About Functional ProgrammingAbout Functional Programming
About Functional Programming
 
Basics java programing
Basics java programingBasics java programing
Basics java programing
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
scalaliftoff2009.pdf
scalaliftoff2009.pdfscalaliftoff2009.pdf
scalaliftoff2009.pdf
 
Object Oriented Programming in Matlab
Object Oriented Programming in Matlab Object Oriented Programming in Matlab
Object Oriented Programming in Matlab
 
F# Intro for Scala Developers
F# Intro for Scala DevelopersF# Intro for Scala Developers
F# Intro for Scala Developers
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
 
Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)Metaprograms and metadata (as part of the the PTT lecture)
Metaprograms and metadata (as part of the the PTT lecture)
 
GATE, HLT and Machine Learning, Sheffield, July 2003
GATE, HLT and Machine Learning, Sheffield, July 2003GATE, HLT and Machine Learning, Sheffield, July 2003
GATE, HLT and Machine Learning, Sheffield, July 2003
 
Introduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf TaiwanIntroduction to Scala for JCConf Taiwan
Introduction to Scala for JCConf Taiwan
 

Recently uploaded

Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 

Recently uploaded (20)

Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 

SET Software Engineering Thailand Meeting: Functional Programming with Scala - Prequel

  • 1. Meet-up, May 28, 2015, Launchpad, Bangkok Roland Petrasch & Brian Topping Welcome!
  • 2. SET Meet-up Programming with Scala Agenda SET — Software Engineering Thailand Programming with Scala – Prequel (speaker: Roland Petrasch) Type Systems / Data Types Functional Programming Combination of OOP and FP Programming with Scala - Object-Oriented meets Functional (Speaker: Brian Topping) Discussion Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 2 Programming Debugging Debugging Programming
  • 3. SET — Software Engineering Thailand The Interest Group from & (not only) for Developers Open Group: Members, Sponsors and Organizers welcome Next topics: HCI Patterns, Scrum, Model-Based UID, Agile Testing, Software Architectures & Frameworks, S.O.L.I.D. & Co., UML ... Contact Roland Petrasch, Professor for Software Engineering Thammasat University, Department of Computer Science, Rangsit Campus, Pathum Thani roland.petrasch@cs.tu.ac.th roland.petrasch@gmail.com Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 3
  • 4. Type system Ruleset: assign types to variables, expressions, functions Error prevention (type errors), e.g. float calculateThrust(Position p) Other purposes: documentation, compiler optimization Evolution Type safety: type checking During compile-time (static typing), e.g. C++, C#, Java, Scala During run-time (dynamic typing), e.g. JavaScript, Ruby, Python Combination, e.g. C# 4.0 (dynamic) SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 4 Untyped Primitive Data Types Abstract Data Types Classes … Assembler Fortran, Pascal, C C++, Java, C#
  • 5. JavaScript: dynamic typing, implicit type conversion, type inference var five = '5', two = 2, sth; sth = five * two; → 10 sth = five + two; → 52 sth = five + two * 5; → 510 sth = five + two * 5 + true; → 510true sth = five + two * 5 + true / 10; → 5100.1 sth = (five + two * 5 + true) / 10; → NaN Sth = 10 / 0; → Infinity SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 5
  • 6. Type system Type inference: automatically deduce the type at compile time partly or completely, e.g. var i = 5; // inferred type: int Type inference is not only a feature of dynamically typed languages Static/dynamic typing and strong/weak typing are orthogonal: Many discussions about strong and weak typing, no precise definition Weak typing: use a value of one type as if it were a value of another type, e.g. in C: char c = 'A'; c++; c=42; or in JavaScript: var s = 'x' + 3; // get 'x3' Strong typing e.g. in Java: String s = "1" + ' ' * 2 + false; // 164false int i = '3' * 2.2; // error Importance of „strong” and semantically rich data types SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 6 To a C programmer strong typing means pressing the keys harder
  • 7. Data Types Data Types and type checking is very (!) important Example: float calculateThrust(Position p) 2 software components: One is providing and another one is using the calculateThrust function SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 7 Mars Lander by Brian McMullin Source: Defense Intelligence Agency, DoD, USA ThrustContolUnit NavigationSystem calculateThrust(Position p)Call Germany USA The thrust is a float. A good data type? Yes? Okay? Right? No: Sematics (unit) not clear: Can be „newton” (metric) or „pound-force” (non metric) → sematically poor in this case
  • 8. Semantically rich data types and error prevention „NASA lost a $125 million Mars orbiter because one engineering team used metric units while another used English units for a key spacecraft operation.“ (http://edition.cnn.com/TECH/space/9909/30/mars.metric/) Example 2.0: Thrust calculateThrust(Position p) A new data type Thrust is needed class Thrust { private Unit unit; private Value value; public float getValue(Unit unit) … } SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 8 Mars Polar Lander Source: NASA
  • 9. Functional programming Declarative programming paradigm Evaluation of functions, avoids changing-state & mutable data, eliminate side-effects Functions: output depends only on input → error prevention Example for side-effect in Java int i=0; if (true != false || ++i==0) { } System.out.println(i); // i is 0 Based on lambda calculus for simple semantics for computation Anonymous Functions (→ closures), no explicit names Functions of a single input Example (λx.x+1) 4 → 4+1 → 5 -function -expression computaton SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 9 
  • 10. Functional programming λ-Example 2.0 (λx.x+2)((λy.y*10)4) SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 10 Alonzo Church (1903–1995), Photo: Wikipedia "Answer to the Ultimate Question of Life, the Universe, and Everything“ (The Hitchhiker's Guide to the Galaxy)
  • 11. Combination of object-oriented and functional paradigms OO and FP have similarities, e.g. Expressive power (semantics) Encapsulation of small parts (reduction of complexity) Data types ... OOP: High in cohesion (class consists of data and functions) and low in coupling (classes should be independent as far as possible) FP: Data is only loosely coupled to functions, functions hide their implementation, immutability, no side-effects Multi-paradigm languages like Scala combine the features from object-oriented and functional paradigms SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 11
  • 12. Combination of Object-oriented and Functional (object-functional) OOP & FP are orthogonal concepts, i.e. they are not contradictory, e.g. encapsulation, inheritance, polymorphism, abstration do not imply mutability SET Meet-up Programming with Scala - Prequel Roland Petrasch28.5.2015, SET Meet-up Programming with Scala - Prequel Slide 12 calcValue IntegerValue Class calcValue OO: Every value is an object; attributes & behavior of an object are described by a class; objects are instances of a class) FP: Every function is a value; and every value is an object → so every function is an object
  • 13. This was the little prequel, thank you for your attention SET Meet-up Programming with Scala - Prequel Brian Topping Entrepreneurial, results-oriented architect Developer and leader with > 20 years experience Companies: Apple, Oracle, Nokia, AT&T, Intel and Bloomberg. Dozens of programming & scripting languages, OS, and IDE