SlideShare a Scribd company logo
The Imminent Threat
   of Functional Programming
Dimitry Solovyov
‣   Haskell enthusiast and FP proponent
‣   Heavy user of Underscore (FP library for JavaScript)
‣   Former assistant teacher of FP course at TTI
‣   Developer at Amber Games and Livesheets
dresdencodak.com
FUNCTIONAL
PROGRAMMING
In programming land,
there are two kinds of problems
In programming land,
there are two kinds of problems




                   memory
                 management
In programming land,
      there are two kinds of problems




sequencing                     memory
(aka do it in what order?)   management
In programming land,
      there are two kinds of problems




sequencing                     memory
                                    E D
                                  LV
                             management
(aka do it in what order?)
                               SO
In programming land,
      there are two kinds of problems




                                    memory D                *
sequencing                              VE
(aka do it in what order?)
                                     O L
                                  management
                                    S
                             * Except for null pointer exceptions ;-)
In programming land,
      there are two kinds of problems


           ?
                                    memory D                *
sequencing                              VE
(aka do it in what order?)
                                     O L
                                  management
                                    S
                             * Except for null pointer exceptions ;-)
Sequencing in Java

   while cond stmt
  do stmt while cond
for init cond step stmt
   for x : xs stmt
Sequencing in Ruby
       loop stmt
   while cond stmt
   until cond stmt
   stmt while cond
   stmt until cond
   for x in xs stmt
     xs each stmt
     n times stmt
    n upto m stmt
   n downto m stmt
          ...
Sequencing in Ruby
                   loop stmt
               while cond stmt
How elegant!   until cond stmt
               stmt while cond
               stmt until cond
               for x in xs stmt
                 xs each stmt
                 n times stmt
                n upto m stmt
               n downto m stmt
                      ...
Imperative programming in a nutshell


10   BEGIN
20   DO SOMETHING
30
40
     DO THAT OTHER THING
     GOTO 20                       ✔
INSTRUCTIONS                     RESULT
Declarative programming in a nutshell



Dear computer,
I want a pony.
                    MAGIC         ✔
DESCRIPTION                     RESULT
INSTANT
SUCCESS
“        OO makes code understandable by
                encapsulating moving parts.

              FP makes code understandable by
                  minimizing moving parts.
                                                   ”
                                  -- Michael Feathers

“Functional Programming in C++”
      http://goo.gl/aVSXX
Abstraction and reusability in FP


Absolutely abstract
                               Category theory *
            ly reu sable
       High
 Exciting
            ly comp
                   osable
                             Mathematically proven
   Ex tremely fun              to be composable


                            * Check out Scalaz for CT in Scala
                              Guava for other FP patterns in Java
+
                  Some GoF pattern analogs
                  provided at semantic level


“Design Patterns in Haskell”
    http://goo.gl/T0Evt
You can get away without
      encapsulating in objects


                   Data types




                                 fo
                                 rm
               r
             fo




                                  ed
             d
          ne




                                      in
                                      to
        ig
         s
      de




                    operate on      Immutable
Combinators
                                  data structures
You can get away without
      encapsulating in objects


                   Data types




                                 fo
                                 rm
               r
             fo




                                  ed
             d
          ne




                                      in
                                      to
        ig
         s
      de




                    operate on      Immutable
Combinators
                                  data structures
You can get away without
      encapsulating in objects


                   Data types
              Ready for the
             age of multicore


                                 fo
                                 rm
               r
             fo




                                  ed
             d
          ne




                                      in
                                      to
        ig
         s
      de




                    operate on      Immutable
Combinators
                                  data structures
Traits instead of inheritance

        Thesis: Inheriting state creates brittle software.
                     Inheriting implementation tends to
                     become useless over time.




“Life without Objects”
 http://goo.gl/wlOyq
Traits instead of inheritance

        Thesis: Inheriting state creates brittle software.
                     Inheriting implementation tends to
                     become useless over time.


                              A
                          B                      Data type

“Life without Objects”
                              C                 Expected to behave
                                                  like A, B, and C
 http://goo.gl/wlOyq
“         In the exclusive sense, functional
                     means no side-effects.

               In the inclusive sense it means a
             programming style which composes
                 functions in interesting ways.
                                                     ”
                                     -- Martin Odersky

“In Defense of Pattern Matching”
      http://goo.gl/HaKQD
Origin of the “functional style”


  LISP                      ML
Common Lisp            Standard ML
  Scheme                  OCaml
   Dylan                    F#
  Racket                 Haskell
  Closure JVM              Frege JVM
                          Scala * JVM


                    * (cough) Close enough.
LISP                     ML

 Dynamic               Strong types
Code = data           Type inference
Metaproggin'               ADTs

       First-class functions
      Higher-order functions
        Pattern matching
LISP                     ML

 Dynamic               Strong types
Code = data           Type inference
Metaproggin'               ADTs

       First-class functions
      Higher-order functions
        Pattern matching
Linus says:
 “Words are cheap,
  show me the code.”
Fake first-class functions in Java

interface Func<A, B> {
    B apply(A x);
}



static <A, B, C> Func<A, C> compose(final Func<A, B> f,
                                    final Func<B, C> g) {
    return new Func<A, C>() {
        public C apply(A x) {
            return g.apply(f.apply(x));
        }
    };
}
Fake higher-order functions in Java



 static <A, B> List<B> map(final Iterable<A> xs,
                           final Func<A, B> f) {
     List<B> ys = new ArrayList<B>();
     for (A x : xs) {
         B y = f.apply(x);
         ys.add(y);
     }
     return ys;
 }
                                    map
Fake higher-order functions in Java



 static <A, B> B fold(final Iterable<A> xs,
                      final B init,
                      final Func2<A, B, B> f) {
     B acc = init;
     for (A x : xs) {
         acc = f.apply(x, acc);
     }
     return acc;
 }
                                     fold
REFERENTIAL
TRANSPARENCY
How logic works


  x=1
  y=2
  x+y=3
in languages
     How logic works with side-effects


         x=1
         y=2
         x + y = 3*


* But only if the moon is still young!
  Otherwise the answer is 5.
Functional programming on the JVM




                                   en l


                                 fe d
                               tio ss



                               ar ia


                              ef le



                              ch n
                            c o cy


                                       s
                           nc cla



                           sp nt
                  es




                           at er
                           e- rol
                                    ct
                                   ns




                                     g
                         an re




                                  in
              ur




                         m att
                         fu st-




                        sid nt
                       tr efe
             os




                              p
                            fir
             cl




                            r
   Clojure    ✔          ✔   ✔   ✘   ✘
   Fantom     ✔          ✔   ✔   ✘   ✘
    Frege     ✔          ✔   ✔   ✔   ✔
     Java     ✔          ✘   ✘   ✘   ✘
    JRuby     ✔          ✘   ✘   ✘   ✘
    Kotlin    ✔          ✔   ✔   ✘   ✔
    Scala     ✔          ✔   ✔   ✘   ✔
FP exploration checklist

❏ Start learning a functional language:
   Scala, Clojure, or even Haskell
❏ Get together @ Latvian FP Group:
   look for it on LinkedIn      http://goo.gl/YhlJl


❏ Talk to me!   dimituri@gmail.com

More Related Content

Similar to Dimitry Solovyov - The imminent threat of functional programming

Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
Skills Matter
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
Michał Konarski
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
Eelco Visser
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
Dominic Graefen
 
Lang Net
Lang NetLang Net
Lang Net
Keith Curtis
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?
sbjug
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
Steve Elliott
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineeringSaswat Padhi
 
Coding style of Linux Kernel
Coding style of Linux KernelCoding style of Linux Kernel
Coding style of Linux KernelPeter Chang
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanicselliando dias
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
spierre
 
F-Script
F-ScriptF-Script
F-Script
ESUG
 
FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)
Dierk König
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developer
Anton Kirillov
 
Close encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet CodeClose encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet Code
lbergmans
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet code
lbergmans
 
Exploitation and State Machines
Exploitation and State MachinesExploitation and State Machines
Exploitation and State MachinesMichael Scovetta
 
Paulking dlp
Paulking dlpPaulking dlp
Paulking dlpd0nn9n
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
Will Iverson
 

Similar to Dimitry Solovyov - The imminent threat of functional programming (20)

Simon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelismSimon Peyton Jones: Managing parallelism
Simon Peyton Jones: Managing parallelism
 
Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?Ruby is dying. What languages are cool now?
Ruby is dying. What languages are cool now?
 
IN4308 1
IN4308 1IN4308 1
IN4308 1
 
LISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love ParanthesesLISP: How I Learned To Stop Worrying And Love Parantheses
LISP: How I Learned To Stop Worrying And Love Parantheses
 
Lang Net
Lang NetLang Net
Lang Net
 
I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?I know Java, why should I consider Clojure?
I know Java, why should I consider Clojure?
 
Mud flash
Mud flashMud flash
Mud flash
 
The Forces Driving Java
The Forces Driving JavaThe Forces Driving Java
The Forces Driving Java
 
Reverse engineering
Reverse engineeringReverse engineering
Reverse engineering
 
Coding style of Linux Kernel
Coding style of Linux KernelCoding style of Linux Kernel
Coding style of Linux Kernel
 
the productive programer: mechanics
the productive programer: mechanicsthe productive programer: mechanics
the productive programer: mechanics
 
Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009Sugar Presentation - YULHackers March 2009
Sugar Presentation - YULHackers March 2009
 
F-Script
F-ScriptF-Script
F-Script
 
FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)
 
Evolving as a professional software developer
Evolving as a professional software developerEvolving as a professional software developer
Evolving as a professional software developer
 
Close encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet CodeClose encounters in MDD: when Models meet Code
Close encounters in MDD: when Models meet Code
 
Close Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet codeClose Encounters in MDD: when models meet code
Close Encounters in MDD: when models meet code
 
Exploitation and State Machines
Exploitation and State MachinesExploitation and State Machines
Exploitation and State Machines
 
Paulking dlp
Paulking dlpPaulking dlp
Paulking dlp
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
 

More from Dmitry Buzdin

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
Dmitry Buzdin
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
Dmitry Buzdin
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
Dmitry Buzdin
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
Dmitry Buzdin
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
Dmitry Buzdin
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
Dmitry Buzdin
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIsDmitry Buzdin
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахDmitry Buzdin
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fmDmitry Buzdin
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIDmitry Buzdin
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsDmitry Buzdin
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional ProgrammingDmitry Buzdin
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contestDmitry Buzdin
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery Dmitry Buzdin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOpsDmitry Buzdin
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump AnalysisDmitry Buzdin
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test AutomationDmitry Buzdin
 

More from Dmitry Buzdin (20)

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Thread Dump Analysis
Thread Dump AnalysisThread Dump Analysis
Thread Dump Analysis
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
 

Recently uploaded

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
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
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
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
 
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
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
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
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
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
 
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
 
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
 
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
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 

Recently uploaded (20)

Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
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
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
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
 
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
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
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
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
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 !
 
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™
 
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
 
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
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 

Dimitry Solovyov - The imminent threat of functional programming

  • 1. The Imminent Threat of Functional Programming
  • 2. Dimitry Solovyov ‣ Haskell enthusiast and FP proponent ‣ Heavy user of Underscore (FP library for JavaScript) ‣ Former assistant teacher of FP course at TTI ‣ Developer at Amber Games and Livesheets
  • 5. In programming land, there are two kinds of problems
  • 6. In programming land, there are two kinds of problems memory management
  • 7. In programming land, there are two kinds of problems sequencing memory (aka do it in what order?) management
  • 8. In programming land, there are two kinds of problems sequencing memory E D LV management (aka do it in what order?) SO
  • 9. In programming land, there are two kinds of problems memory D * sequencing VE (aka do it in what order?) O L management S * Except for null pointer exceptions ;-)
  • 10. In programming land, there are two kinds of problems ? memory D * sequencing VE (aka do it in what order?) O L management S * Except for null pointer exceptions ;-)
  • 11. Sequencing in Java while cond stmt do stmt while cond for init cond step stmt for x : xs stmt
  • 12. Sequencing in Ruby loop stmt while cond stmt until cond stmt stmt while cond stmt until cond for x in xs stmt xs each stmt n times stmt n upto m stmt n downto m stmt ...
  • 13. Sequencing in Ruby loop stmt while cond stmt How elegant! until cond stmt stmt while cond stmt until cond for x in xs stmt xs each stmt n times stmt n upto m stmt n downto m stmt ...
  • 14. Imperative programming in a nutshell 10 BEGIN 20 DO SOMETHING 30 40 DO THAT OTHER THING GOTO 20 ✔ INSTRUCTIONS RESULT
  • 15. Declarative programming in a nutshell Dear computer, I want a pony. MAGIC ✔ DESCRIPTION RESULT
  • 17. OO makes code understandable by encapsulating moving parts. FP makes code understandable by minimizing moving parts. ” -- Michael Feathers “Functional Programming in C++” http://goo.gl/aVSXX
  • 18. Abstraction and reusability in FP Absolutely abstract Category theory * ly reu sable High Exciting ly comp osable Mathematically proven Ex tremely fun to be composable * Check out Scalaz for CT in Scala Guava for other FP patterns in Java
  • 19. + Some GoF pattern analogs provided at semantic level “Design Patterns in Haskell” http://goo.gl/T0Evt
  • 20. You can get away without encapsulating in objects Data types fo rm r fo ed d ne in to ig s de operate on Immutable Combinators data structures
  • 21. You can get away without encapsulating in objects Data types fo rm r fo ed d ne in to ig s de operate on Immutable Combinators data structures
  • 22. You can get away without encapsulating in objects Data types Ready for the age of multicore fo rm r fo ed d ne in to ig s de operate on Immutable Combinators data structures
  • 23. Traits instead of inheritance Thesis: Inheriting state creates brittle software. Inheriting implementation tends to become useless over time. “Life without Objects” http://goo.gl/wlOyq
  • 24. Traits instead of inheritance Thesis: Inheriting state creates brittle software. Inheriting implementation tends to become useless over time. A B Data type “Life without Objects” C Expected to behave like A, B, and C http://goo.gl/wlOyq
  • 25. In the exclusive sense, functional means no side-effects. In the inclusive sense it means a programming style which composes functions in interesting ways. ” -- Martin Odersky “In Defense of Pattern Matching” http://goo.gl/HaKQD
  • 26. Origin of the “functional style” LISP ML Common Lisp Standard ML Scheme OCaml Dylan F# Racket Haskell Closure JVM Frege JVM Scala * JVM * (cough) Close enough.
  • 27. LISP ML Dynamic Strong types Code = data Type inference Metaproggin' ADTs First-class functions Higher-order functions Pattern matching
  • 28. LISP ML Dynamic Strong types Code = data Type inference Metaproggin' ADTs First-class functions Higher-order functions Pattern matching
  • 29. Linus says: “Words are cheap, show me the code.”
  • 30. Fake first-class functions in Java interface Func<A, B> { B apply(A x); } static <A, B, C> Func<A, C> compose(final Func<A, B> f, final Func<B, C> g) { return new Func<A, C>() { public C apply(A x) { return g.apply(f.apply(x)); } }; }
  • 31. Fake higher-order functions in Java static <A, B> List<B> map(final Iterable<A> xs, final Func<A, B> f) { List<B> ys = new ArrayList<B>(); for (A x : xs) { B y = f.apply(x); ys.add(y); } return ys; } map
  • 32. Fake higher-order functions in Java static <A, B> B fold(final Iterable<A> xs, final B init, final Func2<A, B, B> f) { B acc = init; for (A x : xs) { acc = f.apply(x, acc); } return acc; } fold
  • 34. How logic works x=1 y=2 x+y=3
  • 35. in languages How logic works with side-effects x=1 y=2 x + y = 3* * But only if the moon is still young! Otherwise the answer is 5.
  • 36. Functional programming on the JVM en l fe d tio ss ar ia ef le ch n c o cy s nc cla sp nt es at er e- rol ct ns g an re in ur m att fu st- sid nt tr efe os p fir cl r Clojure ✔ ✔ ✔ ✘ ✘ Fantom ✔ ✔ ✔ ✘ ✘ Frege ✔ ✔ ✔ ✔ ✔ Java ✔ ✘ ✘ ✘ ✘ JRuby ✔ ✘ ✘ ✘ ✘ Kotlin ✔ ✔ ✔ ✘ ✔ Scala ✔ ✔ ✔ ✘ ✔
  • 37. FP exploration checklist ❏ Start learning a functional language: Scala, Clojure, or even Haskell ❏ Get together @ Latvian FP Group: look for it on LinkedIn http://goo.gl/YhlJl ❏ Talk to me! dimituri@gmail.com