SlideShare a Scribd company logo
Introduction to Functional
Programming and Clojure
@sdaas
What to Expect …
• Look at programming in a different way
– Immutable data
– A world without for-loops
• Understand basics of functional programming
– In the context of Clojure
• A POV on why to consider a functional
programming style in your current project
• And why Clojure might be a good choice
What NOT to Expect …
• NOT a deep dive into all aspects of the Clojure
programming language
• NOT about installation, debugging,
performance, etc. of Clojure
• NO bashing of Java or any other language
• NO bashing of Object-Oriented Design
Don’t forget Java yet …
• FP is a programming paradigm or style
• Some languages lend themselves better to
functional programming
– Clojure, Haskell, Erlang
• Most languages support FP to some extent
– Java 8
– JavaScript
– Python
Functional Programming Concepts
• More like Mathematical Functions
– vs. Subroutines/procedures
• Support higher order functions
• Pure functions – with no side effects
• Recursion is favored over iteration
• Lazy Evaluation
• Referential Transparency
– Once defined, a “variable” never changes value
What is Clojure ?
• Created by Rich Hickey
• Immutable and Functional Programming style
• Lisp that runs on the JVM
• Interoperates with Java
• Power of Functional Programming meets the
Richness of Java Ecosystem
Clojure Syntax
Functions
Lists
• Collection of heterogeneous values
• Operations on lists never modify the original
list. They always return a copy.
• This “immutability” of data structure is a big
deal in Functional Programing.
• Two fundamental operators – first, & rest
• Every data structure and function is built up
using these two operators
Lists
Building Blocks – first & rest
• Favoring recursion over iteration
• Do you see the bomb in the nth-element ?
Tail recursion is your friend
Map, Filter, and Reduce
Composition
• FP encourages you to compose small/simpler
function to create complex functions
What does this code do ?
Sum of square of all odd numbers ..
• How testable and maintainable is this code ?
• Modify this for odd numbers that aren’t multiples of 7 ?
• How would this work for infinitely long data ?
Functional Version …
Find the first 20 prime numbers
Laziness is good ...
• Iterate : returns lazy sequence of f(x) f(f(x)) etc ..
• take : returns a lazy sequence of first n from collection
• Map and filter can work on lazy sequences
• Check out the call to java.lang.Math.sqrt
Hash Maps
Reading a CSV File …
FROM
Smith,John,45,90210
Frank,Peter,25,90110
Bond,James,38,90110
TO
{:zip 90210, :age 45, :fname "John", :lname "Smith"}
{:zip 90110, :age 25, :fname "Peter", :lname "Frank"}
{:zip 90110, :age 38, :fname "James", :lname "Bond"}
12 lines of Clojure Code …
What the %$*&^ was that ?
In Summary …
• FP concepts can be used to create concise,
highly modular, and composable code
• Java 8 and JavaScript have good support for FP
concepts
• Clojure interoperates well with Java, and could
be a good way to experiment with FP without
abandoning the Java ecosystem
Questions ?
Please give your feedback at
http://bit.ly/introfp
Resources
• The SICP Book “Structure and Interpretation of
Computer Programs”
• Paul Graham’s Blogs
• Clojure Home page (clojure.org)
• Clojure for the Brave and True (braveclojure.com)
• www.slideshare.net/SoumendraDaas/present
ations
• www.github.com/sdaas/clojure-talk
• https://medium.com/@sdaas/functionally-
speaking-f4dba2a1c7ee

More Related Content

PPTX
Oop is not Dead
PPTX
Textual programming in key stage 3
ODP
PPTX
Not Everything Is An Object
PDF
Learning to Translate with Joey NMT
PPTX
Break Free with Managed Functional Programming: An Introduction to F#
PPTX
Break Free with Managed Functional Programming: An Introduction to F#
Oop is not Dead
Textual programming in key stage 3
Not Everything Is An Object
Learning to Translate with Joey NMT
Break Free with Managed Functional Programming: An Introduction to F#
Break Free with Managed Functional Programming: An Introduction to F#

What's hot (20)

PDF
Erlang workshopdrammen
PPTX
Basics of functional Programming by Siddharth Kulkarni
PPTX
Natural Language to Visualization by Neural Machine Translation
ODP
ANTLR4 and its testing
PDF
Technical screening .Net Developer
PPTX
C# 8 e além
PPTX
Java presentation
ODP
Using ANTLR on real example - convert "string combined" queries into paramete...
PPTX
Craft of coding
PDF
OOPS Advanced
PPT
Functional OOP, Clojure style
PDF
Xtext Webinar
PPTX
Fine tuning large LMs
PDF
Object Oriented Programming : Part 2
PDF
Writing readable Clojure code
PDF
Why Functional Programming and Clojure - LightningTalk
PDF
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
PDF
Implementing DSLs in practice
PPT
Class9
PDF
Internal domain-specific languages
Erlang workshopdrammen
Basics of functional Programming by Siddharth Kulkarni
Natural Language to Visualization by Neural Machine Translation
ANTLR4 and its testing
Technical screening .Net Developer
C# 8 e além
Java presentation
Using ANTLR on real example - convert "string combined" queries into paramete...
Craft of coding
OOPS Advanced
Functional OOP, Clojure style
Xtext Webinar
Fine tuning large LMs
Object Oriented Programming : Part 2
Writing readable Clojure code
Why Functional Programming and Clojure - LightningTalk
Elixir Brasil 2019 - Quality: A Panacéia para seu código Elixir
Implementing DSLs in practice
Class9
Internal domain-specific languages
Ad

Similar to Introduction to Functional Programming and Clojure (20)

PDF
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
PPTX
The joy of functional programming
PDF
Booting into functional programming
PDF
Are High Level Programming Languages for Multicore and Safety Critical Conver...
PDF
Functional Python Webinar from October 22nd, 2014
PPTX
F# for startups v2
PPTX
The Road to Lambda - Mike Duigou
KEY
Java Closures
PDF
JSR 335 / java 8 - update reference
PPTX
F# for startups
PDF
The Rise of Functional Programming
PDF
Fp for the oo programmer
PDF
Clojure - An Introduction for Lisp Programmers
PDF
Software Craftmanship - Cours Polytech
PDF
Functional Programming for Busy Object Oriented Programmers
PDF
FP Days: Down the Clojure Rabbit Hole
PPTX
Functional-style control flow in F#
PPTX
10 Sets of Best Practices for Java 8
KEY
Polyglot and Functional Programming (OSCON 2012)
PPTX
Lec 01 introduction
"Introduction to F#" - South Dakota Code Camp, November 5, 2011
The joy of functional programming
Booting into functional programming
Are High Level Programming Languages for Multicore and Safety Critical Conver...
Functional Python Webinar from October 22nd, 2014
F# for startups v2
The Road to Lambda - Mike Duigou
Java Closures
JSR 335 / java 8 - update reference
F# for startups
The Rise of Functional Programming
Fp for the oo programmer
Clojure - An Introduction for Lisp Programmers
Software Craftmanship - Cours Polytech
Functional Programming for Busy Object Oriented Programmers
FP Days: Down the Clojure Rabbit Hole
Functional-style control flow in F#
10 Sets of Best Practices for Java 8
Polyglot and Functional Programming (OSCON 2012)
Lec 01 introduction
Ad

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
ai tools demonstartion for schools and inter college
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
System and Network Administraation Chapter 3
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
medical staffing services at VALiNTRY
PPTX
assetexplorer- product-overview - presentation
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Wondershare Filmora 15 Crack With Activation Key [2025
ai tools demonstartion for schools and inter college
Digital Systems & Binary Numbers (comprehensive )
VVF-Customer-Presentation2025-Ver1.9.pptx
Softaken Excel to vCard Converter Software.pdf
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
System and Network Administraation Chapter 3
Designing Intelligence for the Shop Floor.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Introduction to Artificial Intelligence
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Odoo Companies in India – Driving Business Transformation.pdf
medical staffing services at VALiNTRY
assetexplorer- product-overview - presentation

Introduction to Functional Programming and Clojure

  • 2. What to Expect … • Look at programming in a different way – Immutable data – A world without for-loops • Understand basics of functional programming – In the context of Clojure • A POV on why to consider a functional programming style in your current project • And why Clojure might be a good choice
  • 3. What NOT to Expect … • NOT a deep dive into all aspects of the Clojure programming language • NOT about installation, debugging, performance, etc. of Clojure • NO bashing of Java or any other language • NO bashing of Object-Oriented Design
  • 4. Don’t forget Java yet … • FP is a programming paradigm or style • Some languages lend themselves better to functional programming – Clojure, Haskell, Erlang • Most languages support FP to some extent – Java 8 – JavaScript – Python
  • 5. Functional Programming Concepts • More like Mathematical Functions – vs. Subroutines/procedures • Support higher order functions • Pure functions – with no side effects • Recursion is favored over iteration • Lazy Evaluation • Referential Transparency – Once defined, a “variable” never changes value
  • 6. What is Clojure ? • Created by Rich Hickey • Immutable and Functional Programming style • Lisp that runs on the JVM • Interoperates with Java • Power of Functional Programming meets the Richness of Java Ecosystem
  • 9. Lists • Collection of heterogeneous values • Operations on lists never modify the original list. They always return a copy. • This “immutability” of data structure is a big deal in Functional Programing. • Two fundamental operators – first, & rest • Every data structure and function is built up using these two operators
  • 10. Lists
  • 11. Building Blocks – first & rest • Favoring recursion over iteration • Do you see the bomb in the nth-element ?
  • 12. Tail recursion is your friend
  • 14. Composition • FP encourages you to compose small/simpler function to create complex functions
  • 15. What does this code do ?
  • 16. Sum of square of all odd numbers .. • How testable and maintainable is this code ? • Modify this for odd numbers that aren’t multiples of 7 ? • How would this work for infinitely long data ?
  • 18. Find the first 20 prime numbers
  • 19. Laziness is good ... • Iterate : returns lazy sequence of f(x) f(f(x)) etc .. • take : returns a lazy sequence of first n from collection • Map and filter can work on lazy sequences • Check out the call to java.lang.Math.sqrt
  • 21. Reading a CSV File … FROM Smith,John,45,90210 Frank,Peter,25,90110 Bond,James,38,90110 TO {:zip 90210, :age 45, :fname "John", :lname "Smith"} {:zip 90110, :age 25, :fname "Peter", :lname "Frank"} {:zip 90110, :age 38, :fname "James", :lname "Bond"}
  • 22. 12 lines of Clojure Code …
  • 23. What the %$*&^ was that ?
  • 24. In Summary … • FP concepts can be used to create concise, highly modular, and composable code • Java 8 and JavaScript have good support for FP concepts • Clojure interoperates well with Java, and could be a good way to experiment with FP without abandoning the Java ecosystem
  • 25. Questions ? Please give your feedback at http://bit.ly/introfp
  • 26. Resources • The SICP Book “Structure and Interpretation of Computer Programs” • Paul Graham’s Blogs • Clojure Home page (clojure.org) • Clojure for the Brave and True (braveclojure.com) • www.slideshare.net/SoumendraDaas/present ations • www.github.com/sdaas/clojure-talk • https://medium.com/@sdaas/functionally- speaking-f4dba2a1c7ee