SlideShare a Scribd company logo
Functional programming 
Let’s fall back in with programming 
Sudipta Mukherjee
What’s Functional Programming 
It’s telling the computer what to get done, not how to get it done
Top 5 Reasons for considering 
Functional Programming 
 Composability: Let’s you compose solutions for complex problems easily 
 Lazy Evaluation: Enables you to benefit from Lazy evaluation 
 Immutability: Being able to write code that is side effect free 
 Parallelizable: You get easy parallelization options 
 Declarative: Lets you write very expressive code so readability increases. 
And you get more done with less code. 
I strongly recommend that you don’t try to remember these. Once you are 
familiar with functional programming, these will seem obvious.
Functional Programming 
Implementations 
 C# by LINQ 
 Rx.NET (Functional programming for Windows Events) 
 F# ( A succinct, multi-paradigm programming, functional first programming 
language from Microsoft Research) 
 fsharp.org 
 Lambdas in C++ 11 
 http://www.cprogramming.com/c++11/c++11-lambda-closures.html 
 http://www.youtube.com/watch?v=5t-_wI7nFdU 
 LINQ Clone for C++ 
 http://cpplinq.codeplex.com/
Who is using Functional Programming 
 Microsoft’s latest Functional Programming Language F# is widely accepted. 
 http://fsharp.org/testimonials/
Objective of this Talk 
 Ignite interest for Functional Programming (a.k.a FP) 
 We shall see how FP can help us remove boilerplate code 
 Provide some initial resources to get you started 
 Examples and Demos today will use LINQ 
 If people are interested, we can have a F# session later.
A 15 floor hotel gets built in 2 days!
Can we build software that fast and 
flawless ?
Oh yes, and the 
requirement should 
be frozen. 
We can. 
If we have the right tools.
A little comparison 
House building 
 Complex by nature 
 Amendments are expensive 
 Mature Industry 
 Oh, I bet 
Creating Software 
 Complex 
 Amendments are expensive 
 Mature Industry? 
 I doubt 
We don’t have 
enough generic 
building blocks
How many times you have written code 
for any of these situations 
 Finding if there is a match in a 
collection 
 Finding all the elements that 
matches a given condition 
 Finding the count of elements in a 
collection that matches a set of 
given conditions 
 Aggregating values of a collection 
in a given way 
 Creating a histogram of all values 
 Creating a lookup table for all 
values in a collection 
 Concatenating several collections 
into one as in merge sort 
 Finding if there is only one 
instance of something in a 
collection 
 …. And so many other such trivial 
things. 
Boilerplate code
Functional Programming 
Can save us from writing the same boilerplate code time and again.
How? 
By wrapping boilerplate codes into several functions that eventually 
becomes the vocabulary of the programmers.
How many times you have written code 
for any of these situations 
 Finding if there is a match in a 
collection 
Any 
 Finding all the elements that 
matches a given condition 
Where 
 Finding the count of elements in a 
collection that matches a set of 
given conditions 
Count 
 Aggregating values of a collection 
in a given way 
 Creating a histogram of all values 
 Creating a lookup table for all 
values in a collection 
 Concatenating several collections 
into one as in merge sort 
 Finding if there is only one 
instance of something in a 
collection 
 …. And so many other such trivial 
things. 
Aggregate 
Boilerplate code 
ToLookup 
Concat 
Single
LINQPad 
The tool used in demo 
 The best C#/VB/F# snippet editor/compiler ever 
 Download from http://www.linqpad.net/ 
 Use Dump() method to see anything. You can dump anything 
 DateTime.Today.Dump(); 
 (new List<int>(){1,2,3}).Dump();
Demo 
Let’s see some example using LINQ
Now little bit of theory 
Just enough so that you see the point
Programming with functions 
It’s just high school math. Reloaded. 
Simple functions 
f(x) = x + 1 
g(x) = x + 2 
z(x) = x == 0 
Composite functions/higher order function 
g.f(x) = g(f(x)) = g(x+1) = x + 1 + 2 = x + 3
You have been already doing it 
 Excel Formulae 
 =SUM(AVERAGE(A1:A10)) 
 LINUX/Powershell Pipes 
 ls | sort –r 
 Get-Process | Sort-Object id
Function Types 
 Statistical 
 Gives a statistic of a collection. 
 Generators 
 Generates something 
 Filters 
 Filters a collection 
 Projectors 
 Projects a collection as something
T [ ] 
Generators 
Generates something out of nothing.
Filters 
Runs a predicate/filter for all elements of the given collection and 
returns one or more matching entries. 
T [ ] T [ ] 
T
Projectors 
Projects a list to another of same or other type using a mapping 
function 
T [ ] U [ ] 
T and U can be same
Statistical 
Finds some statistical values for the given collection. 
T [ ]  Boolean 
T [ ] Numeric
Func<> and Action<> (C# Specific) 
 What type is this function ?
Loop to LINQ
Thank You So Much!! 
Send queries to sudipto80@yahoo.com

More Related Content

What's hot

Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IDUSPviz
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Sergey Tihon
 
Tech for devs, F#
Tech for devs, F#Tech for devs, F#
Tech for devs, F#Robert Rohr
 
GraphQL APIs is with eZ Platform, a Symfony CMS
GraphQL APIs is with eZ Platform, a Symfony CMSGraphQL APIs is with eZ Platform, a Symfony CMS
GraphQL APIs is with eZ Platform, a Symfony CMSJani Tarvainen
 
Getting Started with F#
Getting Started with F#Getting Started with F#
Getting Started with F#Rachel Reese
 
Introducing MLflow for R
Introducing MLflow for RIntroducing MLflow for R
Introducing MLflow for RKevin Kuo
 
C++ by shantu
C++ by shantuC++ by shantu
C++ by shantuShant007
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & LoopsAkhil Kaushik
 
Part I (1.5 points) Write a C++ program that reads a line from the key...
Part I (1.5 points)        Write a C++ program that reads a line from the key...Part I (1.5 points)        Write a C++ program that reads a line from the key...
Part I (1.5 points) Write a C++ program that reads a line from the key...hwbloom104
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsjody zoll
 
Excel IF function
Excel IF functionExcel IF function
Excel IF functionHtay Aung
 
The Game Translator’s Toolkit
The Game Translator’s ToolkitThe Game Translator’s Toolkit
The Game Translator’s ToolkitAnthony Teixeira
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity CalculationAkhil Kaushik
 
Artificial intelligence - Prolog
Artificial intelligence - Prolog Artificial intelligence - Prolog
Artificial intelligence - Prolog Sunjid Hasan
 

What's hot (20)

Python Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part IPython Programming for ArcGIS: Part I
Python Programming for ArcGIS: Part I
 
Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...
 
Tech for devs, F#
Tech for devs, F#Tech for devs, F#
Tech for devs, F#
 
GraphQL APIs is with eZ Platform, a Symfony CMS
GraphQL APIs is with eZ Platform, a Symfony CMSGraphQL APIs is with eZ Platform, a Symfony CMS
GraphQL APIs is with eZ Platform, a Symfony CMS
 
Backpatching1
Backpatching1Backpatching1
Backpatching1
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
Getting Started with F#
Getting Started with F#Getting Started with F#
Getting Started with F#
 
Introducing MLflow for R
Introducing MLflow for RIntroducing MLflow for R
Introducing MLflow for R
 
C++ by shantu
C++ by shantuC++ by shantu
C++ by shantu
 
Decision Making & Loops
Decision Making & LoopsDecision Making & Loops
Decision Making & Loops
 
Part I (1.5 points) Write a C++ program that reads a line from the key...
Part I (1.5 points)        Write a C++ program that reads a line from the key...Part I (1.5 points)        Write a C++ program that reads a line from the key...
Part I (1.5 points) Write a C++ program that reads a line from the key...
 
More Pointers and Arrays
More Pointers and ArraysMore Pointers and Arrays
More Pointers and Arrays
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Excel IF function
Excel IF functionExcel IF function
Excel IF function
 
The Game Translator’s Toolkit
The Game Translator’s ToolkitThe Game Translator’s Toolkit
The Game Translator’s Toolkit
 
Algorithms & Complexity Calculation
Algorithms & Complexity CalculationAlgorithms & Complexity Calculation
Algorithms & Complexity Calculation
 
Does reporting takes lots of time
Does reporting takes lots of timeDoes reporting takes lots of time
Does reporting takes lots of time
 
Touchless writer
Touchless writerTouchless writer
Touchless writer
 
GSL Examples
GSL ExamplesGSL Examples
GSL Examples
 
Artificial intelligence - Prolog
Artificial intelligence - Prolog Artificial intelligence - Prolog
Artificial intelligence - Prolog
 

Similar to Functional programming (Let's fall back in love with Programming)

Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#Alfonso Garcia-Caro
 
C++programing
C++programingC++programing
C++programingrmvvr143
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010Skills Matter
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsDirecti Group
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming ParadigmsJaneve George
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009nkaluva
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Insidejeffz
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentPython Ireland
 
Algorithm and Programming
Algorithm and ProgrammingAlgorithm and Programming
Algorithm and ProgrammingNidal Abusaleh
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsRobert MacLean
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_pythongunanandJha2
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptMohitChaudhary637683
 

Similar to Functional programming (Let's fall back in love with Programming) (20)

Functional Programming in C# and F#
Functional Programming in C# and F#Functional Programming in C# and F#
Functional Programming in C# and F#
 
C++programing
C++programingC++programing
C++programing
 
C++programing
C++programingC++programing
C++programing
 
Getting started with R
Getting started with RGetting started with R
Getting started with R
 
London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010London F-Sharp User Group : Don Syme on F# - 09/09/2010
London F-Sharp User Group : Don Syme on F# - 09/09/2010
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Toub parallelism tour_oct2009
Toub parallelism tour_oct2009Toub parallelism tour_oct2009
Toub parallelism tour_oct2009
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Functional programming in C++
Functional programming in C++Functional programming in C++
Functional programming in C++
 
The Larch - a visual interactive programming environment
The Larch - a visual interactive programming environmentThe Larch - a visual interactive programming environment
The Larch - a visual interactive programming environment
 
Algorithm and Programming
Algorithm and ProgrammingAlgorithm and Programming
Algorithm and Programming
 
Core .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 EnhancementsCore .NET Framework 4.0 Enhancements
Core .NET Framework 4.0 Enhancements
 
Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)Illustrated Code (ASE 2021)
Illustrated Code (ASE 2021)
 
Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
presentation_intro_to_python
presentation_intro_to_pythonpresentation_intro_to_python
presentation_intro_to_python
 
presentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.pptpresentation_intro_to_python_1462930390_181219.ppt
presentation_intro_to_python_1462930390_181219.ppt
 

More from Sudipta Mukherjee

More from Sudipta Mukherjee (13)

Sudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdfSudipta_Mukherjee_Resume-Nov_2022.pdf
Sudipta_Mukherjee_Resume-Nov_2022.pdf
 
Sudipta mukherjee certificate
Sudipta mukherjee certificateSudipta mukherjee certificate
Sudipta mukherjee certificate
 
Sudipta mukherjee 2016_2017
Sudipta mukherjee 2016_2017Sudipta mukherjee 2016_2017
Sudipta mukherjee 2016_2017
 
Think in linq
Think in linqThink in linq
Think in linq
 
Sudipta_Mukherjee_2016_2017
Sudipta_Mukherjee_2016_2017Sudipta_Mukherjee_2016_2017
Sudipta_Mukherjee_2016_2017
 
Coursera ml 2016
Coursera ml 2016Coursera ml 2016
Coursera ml 2016
 
Squirrel – Enabling Accessible Analytics for All
Squirrel – Enabling Accessible Analytics for AllSquirrel – Enabling Accessible Analytics for All
Squirrel – Enabling Accessible Analytics for All
 
Squirrel do more_with_less_code_light_cheatsheet
Squirrel do more_with_less_code_light_cheatsheetSquirrel do more_with_less_code_light_cheatsheet
Squirrel do more_with_less_code_light_cheatsheet
 
Squirrel do more_with_less_code_cheat_sheet_1
Squirrel do more_with_less_code_cheat_sheet_1Squirrel do more_with_less_code_cheat_sheet_1
Squirrel do more_with_less_code_cheat_sheet_1
 
Sudipta mukherjee
Sudipta mukherjeeSudipta mukherjee
Sudipta mukherjee
 
Thinking in linq
Thinking in linqThinking in linq
Thinking in linq
 
C sharp fsharp_pain_pleasure_1
C sharp fsharp_pain_pleasure_1C sharp fsharp_pain_pleasure_1
C sharp fsharp_pain_pleasure_1
 
110103
110103110103
110103
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoTAnalytics
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
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 3DianaGray10
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
 
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
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Product School
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
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
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024IoT Analytics Company Presentation May 2024
IoT Analytics Company Presentation May 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
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
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
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...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
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...
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 

Functional programming (Let's fall back in love with Programming)

  • 1. Functional programming Let’s fall back in with programming Sudipta Mukherjee
  • 2. What’s Functional Programming It’s telling the computer what to get done, not how to get it done
  • 3. Top 5 Reasons for considering Functional Programming  Composability: Let’s you compose solutions for complex problems easily  Lazy Evaluation: Enables you to benefit from Lazy evaluation  Immutability: Being able to write code that is side effect free  Parallelizable: You get easy parallelization options  Declarative: Lets you write very expressive code so readability increases. And you get more done with less code. I strongly recommend that you don’t try to remember these. Once you are familiar with functional programming, these will seem obvious.
  • 4. Functional Programming Implementations  C# by LINQ  Rx.NET (Functional programming for Windows Events)  F# ( A succinct, multi-paradigm programming, functional first programming language from Microsoft Research)  fsharp.org  Lambdas in C++ 11  http://www.cprogramming.com/c++11/c++11-lambda-closures.html  http://www.youtube.com/watch?v=5t-_wI7nFdU  LINQ Clone for C++  http://cpplinq.codeplex.com/
  • 5. Who is using Functional Programming  Microsoft’s latest Functional Programming Language F# is widely accepted.  http://fsharp.org/testimonials/
  • 6. Objective of this Talk  Ignite interest for Functional Programming (a.k.a FP)  We shall see how FP can help us remove boilerplate code  Provide some initial resources to get you started  Examples and Demos today will use LINQ  If people are interested, we can have a F# session later.
  • 7. A 15 floor hotel gets built in 2 days!
  • 8. Can we build software that fast and flawless ?
  • 9. Oh yes, and the requirement should be frozen. We can. If we have the right tools.
  • 10. A little comparison House building  Complex by nature  Amendments are expensive  Mature Industry  Oh, I bet Creating Software  Complex  Amendments are expensive  Mature Industry?  I doubt We don’t have enough generic building blocks
  • 11. How many times you have written code for any of these situations  Finding if there is a match in a collection  Finding all the elements that matches a given condition  Finding the count of elements in a collection that matches a set of given conditions  Aggregating values of a collection in a given way  Creating a histogram of all values  Creating a lookup table for all values in a collection  Concatenating several collections into one as in merge sort  Finding if there is only one instance of something in a collection  …. And so many other such trivial things. Boilerplate code
  • 12. Functional Programming Can save us from writing the same boilerplate code time and again.
  • 13. How? By wrapping boilerplate codes into several functions that eventually becomes the vocabulary of the programmers.
  • 14. How many times you have written code for any of these situations  Finding if there is a match in a collection Any  Finding all the elements that matches a given condition Where  Finding the count of elements in a collection that matches a set of given conditions Count  Aggregating values of a collection in a given way  Creating a histogram of all values  Creating a lookup table for all values in a collection  Concatenating several collections into one as in merge sort  Finding if there is only one instance of something in a collection  …. And so many other such trivial things. Aggregate Boilerplate code ToLookup Concat Single
  • 15. LINQPad The tool used in demo  The best C#/VB/F# snippet editor/compiler ever  Download from http://www.linqpad.net/  Use Dump() method to see anything. You can dump anything  DateTime.Today.Dump();  (new List<int>(){1,2,3}).Dump();
  • 16. Demo Let’s see some example using LINQ
  • 17. Now little bit of theory Just enough so that you see the point
  • 18. Programming with functions It’s just high school math. Reloaded. Simple functions f(x) = x + 1 g(x) = x + 2 z(x) = x == 0 Composite functions/higher order function g.f(x) = g(f(x)) = g(x+1) = x + 1 + 2 = x + 3
  • 19. You have been already doing it  Excel Formulae  =SUM(AVERAGE(A1:A10))  LINUX/Powershell Pipes  ls | sort –r  Get-Process | Sort-Object id
  • 20. Function Types  Statistical  Gives a statistic of a collection.  Generators  Generates something  Filters  Filters a collection  Projectors  Projects a collection as something
  • 21. T [ ] Generators Generates something out of nothing.
  • 22. Filters Runs a predicate/filter for all elements of the given collection and returns one or more matching entries. T [ ] T [ ] T
  • 23. Projectors Projects a list to another of same or other type using a mapping function T [ ] U [ ] T and U can be same
  • 24. Statistical Finds some statistical values for the given collection. T [ ]  Boolean T [ ] Numeric
  • 25. Func<> and Action<> (C# Specific)  What type is this function ?
  • 27. Thank You So Much!! Send queries to sudipto80@yahoo.com