SlideShare a Scribd company logo
Functional Programming with 
Jan Köhnlein & Sven Efftinge
Functional programming is like 
describing your problem to a mathematician. 
Imperative programming is like 
giving instructions to an idiot.
Imperative vs Functional 
State Changes vs No State Change 
How? vs What?
2 Important Principles
#1 : No Side-Effects
Haskell is a purely-functional programming language
Most other functional programming languages 
are more relaxed, i.e. non-pure.
Most other functional programming languages 
are more relaxed, i.e. non-pure. 
But still embrace immutability!
Why Immutability? 
Thread-Safety 
Easy to test, construct and use 
Good Map keys and Set members 
Code is easier to read and understand
Java and 
Immutability
The beauty of 
java.lang.String 
Thread-Safety 
Easy to test, construct and use 
Good Map keys and 
Set members 
Code is easier to read 
and understand
"Classes should be immutable 
unless there's a very good reason 
to make them mutable...” 
(Joshua Bloch)
"When you create immutable classes, 
entire categories of problems simply 
disappear.” 
(javapractices.com)
How to build an 
immutable data type in Java? 
make everything final 
create constructor for fields 
implement hashcode 
implement equals
writing Immutable code in Java 
is tedious & error-prone
Immutability in 
final by default 
val vs. var 
immutable collection literals 
everything is an expression 
@Pure 
@Data
First Exercise 
Immutable Data Types
2 Important Principles
#2 : First-Class Functions
#2 : First-Class Functions 
passing functions as arguments 
higher-order functions 
lambdas
An Example
Functional programming with Xtend
@Data class Movie { 
String title 
int year 
double rating 
long numberOfVotes 
ImmutableSet<String> categories 
}
What’s the best drama of the 70ies?
The imperative way
Functional programming with Xtend
Functional programming with Xtend
The functional way
Java 8 
Lambdas
Lambdas
Functional programming with Xtend
Second Exercise 
In The Movies
Use the force, Duke! 
www.xtend-lang.org

More Related Content

PDF
Xtext Webinar
PDF
Xtend - better java with -less- noise
PDF
Grooming with Groovy
PPTX
Scala - the good, the bad and the very ugly
PPTX
Programming Paradigm & Languages
PDF
Internal domain-specific languages
PDF
Metaprogramming with javascript
PDF
Functional programming with Java 8
Xtext Webinar
Xtend - better java with -less- noise
Grooming with Groovy
Scala - the good, the bad and the very ugly
Programming Paradigm & Languages
Internal domain-specific languages
Metaprogramming with javascript
Functional programming with Java 8

What's hot (20)

PDF
Core Java Tutorial
PPT
C++ to java
PDF
Swift Tutorial Part 2. The complete guide for Swift programming language
PDF
Scala the good and bad parts
PPT
Introduction to java
PPTX
Introduction to functional programming with java 8
PDF
Swift Programming Language
PPT
00 intro to java
PPTX
Advanced Javascript
PPTX
Functional programming in TypeScript
PDF
Functional programming in scala
PDF
Functional Programming in Java
PPTX
JavaScript (without DOM)
PDF
Kotlin & arrow: the functional way
PPTX
Functional programming principles and Java 8
PPTX
JavaScript Basics
PPTX
Kotlin L → ∞
PDF
Eclipse and Java 8 - Eclipse Day India 2013
PDF
Clojure presentation
PPT
Web development basics (Part-4)
Core Java Tutorial
C++ to java
Swift Tutorial Part 2. The complete guide for Swift programming language
Scala the good and bad parts
Introduction to java
Introduction to functional programming with java 8
Swift Programming Language
00 intro to java
Advanced Javascript
Functional programming in TypeScript
Functional programming in scala
Functional Programming in Java
JavaScript (without DOM)
Kotlin & arrow: the functional way
Functional programming principles and Java 8
JavaScript Basics
Kotlin L → ∞
Eclipse and Java 8 - Eclipse Day India 2013
Clojure presentation
Web development basics (Part-4)
Ad

Similar to Functional programming with Xtend (20)

PDF
Haskell Tour (Part 1)
PPTX
Why functional programming in C# & F#
PDF
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
PDF
Metaprogramming JavaScript
PPTX
Unit1 introduction to Java
PPTX
Introduction to Java.pptx sjskmdkdmdkdmdkdkd
PPTX
About Functional Programming
PPTX
Functional Programming In Jdk8
PPTX
Modern_2.pptx for java
PPTX
Java programming language
PDF
Unit 1 Core Java for Compter Science 3rd
DOCX
Class notes(week 2) on basic concepts of oop-2
PPTX
LECTURE 2 -Object oriented Java Basics.pptx
PDF
Class notes(week 2) on basic concepts of oop-2
KEY
Introduction to Ruby
PDF
Java Simplified: Understanding Programming Basics
DOCX
Mit4021 c# and .net
PPTX
JAVA-java-basic and introduction.module.pptx
Haskell Tour (Part 1)
Why functional programming in C# & F#
PJ_M01_C01_PPT_Introduction to Object Oriented Programming Using Java.pdf
Metaprogramming JavaScript
Unit1 introduction to Java
Introduction to Java.pptx sjskmdkdmdkdmdkdkd
About Functional Programming
Functional Programming In Jdk8
Modern_2.pptx for java
Java programming language
Unit 1 Core Java for Compter Science 3rd
Class notes(week 2) on basic concepts of oop-2
LECTURE 2 -Object oriented Java Basics.pptx
Class notes(week 2) on basic concepts of oop-2
Introduction to Ruby
Java Simplified: Understanding Programming Basics
Mit4021 c# and .net
JAVA-java-basic and introduction.module.pptx
Ad

More from Sven Efftinge (20)

PDF
Parsing Expression With Xtext
PDF
Language Engineering With Xtext
PDF
Future of Xtext
PDF
Auto-GWT : Better GWT Programming with Xtend
PDF
Codegeneration With Xtend
KEY
Gwt and Xtend
KEY
Domain Specific Languages (EclipseCon 2012)
KEY
Xtend @ EclipseCon 2012
KEY
Eclipse Xtend
PDF
This Is Not Your Father's Java
KEY
Getting the most out of Java [Nordic Coding-2010]
PDF
Xtext at MDD Day 2010
PDF
Dependency Injection for Eclipse developers
PDF
Xtext Webinar
KEY
Challenges In Dsl Design
KEY
Code Generation in Agile Projects
KEY
Xtext Eclipse Con
KEY
Generic Editor
PDF
Eclipse Banking Day
PDF
Bessere Softwareentwicklung (Itemis Wintercon)
Parsing Expression With Xtext
Language Engineering With Xtext
Future of Xtext
Auto-GWT : Better GWT Programming with Xtend
Codegeneration With Xtend
Gwt and Xtend
Domain Specific Languages (EclipseCon 2012)
Xtend @ EclipseCon 2012
Eclipse Xtend
This Is Not Your Father's Java
Getting the most out of Java [Nordic Coding-2010]
Xtext at MDD Day 2010
Dependency Injection for Eclipse developers
Xtext Webinar
Challenges In Dsl Design
Code Generation in Agile Projects
Xtext Eclipse Con
Generic Editor
Eclipse Banking Day
Bessere Softwareentwicklung (Itemis Wintercon)

Recently uploaded (20)

PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PDF
medical staffing services at VALiNTRY
PDF
How to Confidently Manage Project Budgets
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
System and Network Administration Chapter 2
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Become an Agentblazer Champion Challenge Kickoff
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Presentation of Computer CLASS 2 .pptx
PDF
AI in Product Development-omnex systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
medical staffing services at VALiNTRY
How to Confidently Manage Project Budgets
Materi_Pemrograman_Komputer-Looping.pptx
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
Materi-Enum-and-Record-Data-Type (1).pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
The Role of Automation and AI in EHS Management for Data Centers.pdf
ManageIQ - Sprint 268 Review - Slide Deck
System and Network Administration Chapter 2
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
PTS Company Brochure 2025 (1).pdf.......
Become an Agentblazer Champion Challenge Kickoff
Understanding Forklifts - TECH EHS Solution
Presentation of Computer CLASS 2 .pptx
AI in Product Development-omnex systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

Functional programming with Xtend