SlideShare a Scribd company logo
1 of 67
Download to read offline
Who's More Functional
                     Groovy, Kotlin, Scala or
                             Java?

                             Andrey Breslav



Wednesday, October 3, 12                        1
About Me

              •      Project lead of Kotlin
                   ➡       at JetBrains since 2010

                                                         Andrey Breslav

              •      EG member of JSR-335
                   ➡       Project Lambda




                                                     2
Wednesday, October 3, 12                                                  2
Prologue




                           3
Wednesday, October 3, 12       3
Prologue
                               – Dad (or Mom), is Java a
                                 functional language?




                           3
Wednesday, October 3, 12                                   3
Prologue
                               – Dad (or Mom), is Java a
                                 functional language?


                               – Don't you know your dad
                                 from your mom?!




                           3
Wednesday, October 3, 12                                   3
What is FP like?



Wednesday, October 3, 12                      4
Alonzo Church         𝛌
                           1936
                                  5
Wednesday, October 3, 12              5
Alonzo Church         𝛌
                           1936 1946
                                       5
Wednesday, October 3, 12                   5
Alonzo Church         𝛌
                           1936 1946
                                       5
Wednesday, October 3, 12                   5
Alonzo Church         𝛌
                           1936 1946 1956
                                            5
Wednesday, October 3, 12                        5
John Backus


      Alonzo Church         𝛌
                           1936 1946 1956
                                            5
Wednesday, October 3, 12                           5
Can Programming
                                                     be Liberated from
                                                     the von Neumann
                                                     Style?


                                     John Backus


      Alonzo Church         𝛌
                           1936 1946 1956          1976
                                            5
Wednesday, October 3, 12                                                 5
6
Wednesday, October 3, 12       6
– Dad, what's
                                 good about FP?




                           6
Wednesday, October 3, 12                          6
– Dad, what's
                                 good about FP?
                               – It makes you
                                 look smart




                           6
Wednesday, October 3, 12                          6
– Dad, what's
                                 good about FP?
                               – It makes you
                                 look smart
                               – Like wearing
                                 glasses?



                           6
Wednesday, October 3, 12                          6
Effects (Mutability)

                                                        𝛌
                           John von Neumann


                                                    Inputs
                    commands




                                     State    VS   f(g(x), y)

                                                   Outputs
                                              7
Wednesday, October 3, 12                                        7
1, 1, 2, 3, 5, 8, 13, 21, 34, ...


                                            Leonardo Fibonacci




Wednesday, October 3, 12                                         8
1, 1, 2, 3, 5, 8, 13, 21, 34, ...


                                            Leonardo Fibonacci




Wednesday, October 3, 12                                         8
1, 1, 2, 3, 5, 8, 13, 21, 34, ...
                                    Are you functional?

                           Kotlin      V
                           Groovy      V
                                                          Leonardo Fibonacci
                            Scala      V
                           Java 8      V
                                    Recursion




Wednesday, October 3, 12                                                       8
1, 1, 2, 3, 5, 8, 13, 21, 34, ...


                                            Leonardo Fibonacci




Wednesday, October 3, 12                                         8
1, 1, 2, 3, 5, 8, 13, 21, 34, ...


                                            Leonardo Fibonacci




Wednesday, October 3, 12                                         8
1, 1, 2, 3, 5, 8, 13, 21, 34, ...


                                              Leonardo Fibonacci
                           commands



                                      State



Wednesday, October 3, 12                                           9
Effect-Free




                              10
Wednesday, October 3, 12           10
Effect-Free




                              10
Wednesday, October 3, 12           10
Effect-Free
                                   – Dad, how do I




                              10
Wednesday, October 3, 12                             10
Effect-Free
                                   – Dad, how do I
                                    -   print("Hello")?




                              10
Wednesday, October 3, 12                                  10
Effect-Free
                                   – Dad, how do I
                                    -   print("Hello")?
                                    -   write to a file?




                              10
Wednesday, October 3, 12                                   10
Effect-Free
                                   – Dad, how do I
                                    -   print("Hello")?
                                    -   write to a file?
                                    -   do both?




                              10
Wednesday, October 3, 12                                   10
Effect-Free
                                    Are you functional?

                           Kotlin      V        X
                                                       – Dad, how do I
                                                          -   print("Hello")?
                           Groovy      V        X
                                                          -   write to a file?
                            Scala      V        X
                                                          -   do both?
                           Java 8      V        X
                                    Recursion   Pure




                                                  10
Wednesday, October 3, 12                                                         10
Summary
                    • FP makes things simpler
                    • Sometimes at a huge price

                    • Our languages are
                           not purely functional




                                          11
Wednesday, October 3, 12                           11
Higher Order
                             FP brings order :)




Wednesday, October 3, 12                          12
FibonacciTest




                                13
Wednesday, October 3, 12             13
FibonacciTest




                                     – How do I test both
                                       implementations?

                                13
Wednesday, October 3, 12                                    13
test(f)




                           14
Wednesday, October 3, 12        14
test(f)
                                    Are you functional?

                           Kotlin      V        X      V
                           Groovy      V        X      V
                            Scala      V        X      V
                           Java 8      V        X      V
                                    Recursion   Pure   HO




                                                  14
Wednesday, October 3, 12                                    14
GoF and FP                       rd er
                                              r-O n
                                            he io
                                          ig ct
                                         H n
                               Strategy = Fu



               Command Observer Abstract State Visitor
                                Factory




                                  15
Wednesday, October 3, 12                                 15
Internal Iteration




                               16
Wednesday, October 3, 12             16
Internal Iteration


            users: ArrayList
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                    16
Internal Iteration


            users: ArrayList                users: ParallelCollection
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                                                16
Internal Iteration


            users: ArrayList                users: ParallelCollection
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                                                16
Internal Iteration


            users: ArrayList                users: ParallelCollection
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                                                16
Internal Iteration


            users: ArrayList                users: ParallelCollection
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                                                16
Internal Iteration


            users: ArrayList                users: ParallelCollection
                      user 1   Hello

                      user 2   Hello

                      user 3   Hello

                      user 4   Hello



                                       16
Wednesday, October 3, 12                                                16
Summary
                    • Good old callbacks/strategies
                    • Very important abstraction




                                       17
Wednesday, October 3, 12                              17
ADT
                           What is your "A" for?




Wednesday, October 3, 12                           18
Example: Messages
                           Server        Client




                                    19
Wednesday, October 3, 12                          19
Example: Messages
                           Server                         Client
                                    search for "lambda"




                                            19
Wednesday, October 3, 12                                           19
Example: Messages
                           Server                         Client
                                    search for "lambda"
                                    exact match at ...




                                            19
Wednesday, October 3, 12                                           19
Example: Messages
                           Server                         Client
                                    search for "lambda"
                                    exact match at ...
                                      similarity at ...




                                             19
Wednesday, October 3, 12                                           19
Example: Messages
                              Server                         Client
                                       search for "lambda"
                                       exact match at ...
                                         similarity at ...



                           message ::= search for term
                                     | exact item
                                     | similar item
                                                19
Wednesday, October 3, 12                                              19
ADT



                           Abstract                 Algebraic
                           data type                data type
                               ~I                         ~D
                                  nte                        ata
                                      rfa                          cla
                                         ce                           ss



                                               20
Wednesday, October 3, 12                                                   20
Are you functional?
                                            ADT

                            Kotlin      V      X      V     V
                           Groovy V            X      V   V
                              Abstract                  Algebraic
                             Scala typeV
                             data              X      V data type
                                                          V
                                  ~I V                        ~D
                            Java 8 nt          X      V   V      ata
                                      erf                              cla
                                          ace                             ss
                                     Recursion Pure   HO   ADT




                                                 20
Wednesday, October 3, 12                                                       20
ADT in Kotlin




                                21
Wednesday, October 3, 12             21
Utilization
                    You may have your cake, but can you eat it too?




Wednesday, October 3, 12                                              22
Up to 5 HO-functions
                        for free!   g rad
                                 U p for
                                          e


                                     m  ore




Wednesday, October 3, 12                      23
Static Utility Methods

                           backwards!




                                        24
Wednesday, October 3, 12                     24
Static Utility Methods

                           backwards!


                                    as opposed to




                                          24
Wednesday, October 3, 12                            24
Extension Functions




                             25
Wednesday, October 3, 12              25
Extension Functions
                     Receiver Type




                                     25
Wednesday, October 3, 12                  25
Extension Functions
                     Receiver Type

                                          receiver




                                     25
Wednesday, October 3, 12                             25
Summary
                    • Extending existing types
                    • Without changing the classes




                                       26
Wednesday, October 3, 12                             26
Epilogue



Wednesday, October 3, 12              27
– Dad, should I use FP?


                            Epilogue



Wednesday, October 3, 12               27
– Dad, should I use FP?


                            Epilogue

                                       – What is your problem?!


Wednesday, October 3, 12                                          27
– Dad, should I use FP?


                            Epilogue

                                       – What is your problem?!

    P.S. Kotlin is cool :)     http://kotlin.jetbrains.org
Wednesday, October 3, 12                                          27
Kotlin Resources
                 • Docs: http://kotlin.jetbrains.org
                 • Demo: http://kotlin-demo.jetbrains.com
                 • Code: http://github.com/jetbrains/kotlin
                 • Twitter:
                      ➡    @project_kotlin
                      ➡    @abreslav


                                             28
Wednesday, October 3, 12                                      28

More Related Content

Viewers also liked

Domain Modeling in a Functional World
Domain Modeling in a Functional WorldDomain Modeling in a Functional World
Domain Modeling in a Functional WorldDebasish Ghosh
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Scott Wlaschin
 
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Chris Richardson
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioLuis Atencio
 
Category theory for beginners
Category theory for beginnersCategory theory for beginners
Category theory for beginnerskenbot
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScripttmont
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm Chandler Huang
 
DNS Security Presentation ISSA
DNS Security Presentation ISSADNS Security Presentation ISSA
DNS Security Presentation ISSASrikrupa Srivatsan
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013mumrah
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & FeaturesDataStax Academy
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBMike Dirolf
 
Etsy Activity Feeds Architecture
Etsy Activity Feeds ArchitectureEtsy Activity Feeds Architecture
Etsy Activity Feeds ArchitectureDan McKinley
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 

Viewers also liked (18)

HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
Domain Modeling in a Functional World
Domain Modeling in a Functional WorldDomain Modeling in a Functional World
Domain Modeling in a Functional World
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
Map, Flatmap and Reduce are Your New Best Friends: Simpler Collections, Concu...
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis AtencioFunctional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
 
Category theory for beginners
Category theory for beginnersCategory theory for beginners
Category theory for beginners
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
DNS Security Presentation ISSA
DNS Security Presentation ISSADNS Security Presentation ISSA
DNS Security Presentation ISSA
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Etsy Activity Feeds Architecture
Etsy Activity Feeds ArchitectureEtsy Activity Feeds Architecture
Etsy Activity Feeds Architecture
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Intro to HBase
Intro to HBaseIntro to HBase
Intro to HBase
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 

More from Andrey Breslav

2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdfAndrey Breslav
 
Shoulders of giants: Languages Kotlin learned from
Shoulders of giants: Languages Kotlin learned fromShoulders of giants: Languages Kotlin learned from
Shoulders of giants: Languages Kotlin learned fromAndrey Breslav
 
Future of Kotlin - How agile can language development be?
Future of Kotlin - How agile can language development be?Future of Kotlin - How agile can language development be?
Future of Kotlin - How agile can language development be?Andrey Breslav
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinAndrey Breslav
 
Flexible Types in Kotlin - JVMLS 2015
Flexible Types in Kotlin - JVMLS 2015Flexible Types in Kotlin - JVMLS 2015
Flexible Types in Kotlin - JVMLS 2015Andrey Breslav
 
Introduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clearIntroduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clearAndrey Breslav
 
Kotlin for Android: Brief and Clear
Kotlin for Android: Brief and ClearKotlin for Android: Brief and Clear
Kotlin for Android: Brief and ClearAndrey Breslav
 
Kotlin (Introduction for students)
Kotlin (Introduction for students)Kotlin (Introduction for students)
Kotlin (Introduction for students)Andrey Breslav
 
Kotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designKotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designAndrey Breslav
 
Kotlin gets Reflection
Kotlin gets ReflectionKotlin gets Reflection
Kotlin gets ReflectionAndrey Breslav
 
Language Design Trade-offs
Language Design Trade-offsLanguage Design Trade-offs
Language Design Trade-offsAndrey Breslav
 
Kotlin: Incompetence * Motivation = Innovation?
Kotlin: Incompetence * Motivation = Innovation?Kotlin: Incompetence * Motivation = Innovation?
Kotlin: Incompetence * Motivation = Innovation?Andrey Breslav
 
JavaOne2012: Kotlin: Practical Aspects of JVM Language Implementation
JavaOne2012: Kotlin: Practical Aspects of JVM Language ImplementationJavaOne2012: Kotlin: Practical Aspects of JVM Language Implementation
JavaOne2012: Kotlin: Practical Aspects of JVM Language ImplementationAndrey Breslav
 
[JVMLS 12] Kotlin / Java Interop
[JVMLS 12] Kotlin / Java Interop[JVMLS 12] Kotlin / Java Interop
[JVMLS 12] Kotlin / Java InteropAndrey Breslav
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Andrey Breslav
 
Kotlin @ CSClub & Yandex
Kotlin @ CSClub & YandexKotlin @ CSClub & Yandex
Kotlin @ CSClub & YandexAndrey Breslav
 
Kotlin @ StrangeLoop 2011
Kotlin @ StrangeLoop 2011Kotlin @ StrangeLoop 2011
Kotlin @ StrangeLoop 2011Andrey Breslav
 

More from Andrey Breslav (20)

2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
2022 May - Shoulders of Giants - Amsterdam - Kotlin Dev Day.pdf
 
Shoulders of giants: Languages Kotlin learned from
Shoulders of giants: Languages Kotlin learned fromShoulders of giants: Languages Kotlin learned from
Shoulders of giants: Languages Kotlin learned from
 
Future of Kotlin - How agile can language development be?
Future of Kotlin - How agile can language development be?Future of Kotlin - How agile can language development be?
Future of Kotlin - How agile can language development be?
 
JVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in KotlinJVMLS 2016. Coroutines in Kotlin
JVMLS 2016. Coroutines in Kotlin
 
Flexible Types in Kotlin - JVMLS 2015
Flexible Types in Kotlin - JVMLS 2015Flexible Types in Kotlin - JVMLS 2015
Flexible Types in Kotlin - JVMLS 2015
 
Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014Eval4j @ JVMLS 2014
Eval4j @ JVMLS 2014
 
Introduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clearIntroduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clear
 
Kotlin for Android: Brief and Clear
Kotlin for Android: Brief and ClearKotlin for Android: Brief and Clear
Kotlin for Android: Brief and Clear
 
Kotlin (Introduction for students)
Kotlin (Introduction for students)Kotlin (Introduction for students)
Kotlin (Introduction for students)
 
Kotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designKotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language design
 
Kotlin gets Reflection
Kotlin gets ReflectionKotlin gets Reflection
Kotlin gets Reflection
 
Language Design Trade-offs
Language Design Trade-offsLanguage Design Trade-offs
Language Design Trade-offs
 
Functions and data
Functions and dataFunctions and data
Functions and data
 
Kotlin: Incompetence * Motivation = Innovation?
Kotlin: Incompetence * Motivation = Innovation?Kotlin: Incompetence * Motivation = Innovation?
Kotlin: Incompetence * Motivation = Innovation?
 
JavaOne2012: Kotlin: Practical Aspects of JVM Language Implementation
JavaOne2012: Kotlin: Practical Aspects of JVM Language ImplementationJavaOne2012: Kotlin: Practical Aspects of JVM Language Implementation
JavaOne2012: Kotlin: Practical Aspects of JVM Language Implementation
 
[JVMLS 12] Kotlin / Java Interop
[JVMLS 12] Kotlin / Java Interop[JVMLS 12] Kotlin / Java Interop
[JVMLS 12] Kotlin / Java Interop
 
Kotlin @ Devoxx 2011
Kotlin @ Devoxx 2011Kotlin @ Devoxx 2011
Kotlin @ Devoxx 2011
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
 
Kotlin @ CSClub & Yandex
Kotlin @ CSClub & YandexKotlin @ CSClub & Yandex
Kotlin @ CSClub & Yandex
 
Kotlin @ StrangeLoop 2011
Kotlin @ StrangeLoop 2011Kotlin @ StrangeLoop 2011
Kotlin @ StrangeLoop 2011
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesSanjay Willie
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your QueriesExploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
Exploring ChatGPT Prompt Hacks To Maximally Optimise Your Queries
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Kotlin, Groovy, Scala or Java - Which is More Functional

  • 1. Who's More Functional Groovy, Kotlin, Scala or Java? Andrey Breslav Wednesday, October 3, 12 1
  • 2. About Me • Project lead of Kotlin ➡ at JetBrains since 2010 Andrey Breslav • EG member of JSR-335 ➡ Project Lambda 2 Wednesday, October 3, 12 2
  • 3. Prologue 3 Wednesday, October 3, 12 3
  • 4. Prologue – Dad (or Mom), is Java a functional language? 3 Wednesday, October 3, 12 3
  • 5. Prologue – Dad (or Mom), is Java a functional language? – Don't you know your dad from your mom?! 3 Wednesday, October 3, 12 3
  • 6. What is FP like? Wednesday, October 3, 12 4
  • 7. Alonzo Church 𝛌 1936 5 Wednesday, October 3, 12 5
  • 8. Alonzo Church 𝛌 1936 1946 5 Wednesday, October 3, 12 5
  • 9. Alonzo Church 𝛌 1936 1946 5 Wednesday, October 3, 12 5
  • 10. Alonzo Church 𝛌 1936 1946 1956 5 Wednesday, October 3, 12 5
  • 11. John Backus Alonzo Church 𝛌 1936 1946 1956 5 Wednesday, October 3, 12 5
  • 12. Can Programming be Liberated from the von Neumann Style? John Backus Alonzo Church 𝛌 1936 1946 1956 1976 5 Wednesday, October 3, 12 5
  • 14. – Dad, what's good about FP? 6 Wednesday, October 3, 12 6
  • 15. – Dad, what's good about FP? – It makes you look smart 6 Wednesday, October 3, 12 6
  • 16. – Dad, what's good about FP? – It makes you look smart – Like wearing glasses? 6 Wednesday, October 3, 12 6
  • 17. Effects (Mutability) 𝛌 John von Neumann Inputs commands State VS f(g(x), y) Outputs 7 Wednesday, October 3, 12 7
  • 18. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  • 19. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  • 20. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Are you functional? Kotlin V Groovy V Leonardo Fibonacci Scala V Java 8 V Recursion Wednesday, October 3, 12 8
  • 21. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  • 22. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  • 23. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci commands State Wednesday, October 3, 12 9
  • 24. Effect-Free 10 Wednesday, October 3, 12 10
  • 25. Effect-Free 10 Wednesday, October 3, 12 10
  • 26. Effect-Free – Dad, how do I 10 Wednesday, October 3, 12 10
  • 27. Effect-Free – Dad, how do I - print("Hello")? 10 Wednesday, October 3, 12 10
  • 28. Effect-Free – Dad, how do I - print("Hello")? - write to a file? 10 Wednesday, October 3, 12 10
  • 29. Effect-Free – Dad, how do I - print("Hello")? - write to a file? - do both? 10 Wednesday, October 3, 12 10
  • 30. Effect-Free Are you functional? Kotlin V X – Dad, how do I - print("Hello")? Groovy V X - write to a file? Scala V X - do both? Java 8 V X Recursion Pure 10 Wednesday, October 3, 12 10
  • 31. Summary • FP makes things simpler • Sometimes at a huge price • Our languages are not purely functional 11 Wednesday, October 3, 12 11
  • 32. Higher Order FP brings order :) Wednesday, October 3, 12 12
  • 33. FibonacciTest 13 Wednesday, October 3, 12 13
  • 34. FibonacciTest – How do I test both implementations? 13 Wednesday, October 3, 12 13
  • 35. test(f) 14 Wednesday, October 3, 12 14
  • 36. test(f) Are you functional? Kotlin V X V Groovy V X V Scala V X V Java 8 V X V Recursion Pure HO 14 Wednesday, October 3, 12 14
  • 37. GoF and FP rd er r-O n he io ig ct H n Strategy = Fu Command Observer Abstract State Visitor Factory 15 Wednesday, October 3, 12 15
  • 38. Internal Iteration 16 Wednesday, October 3, 12 16
  • 39. Internal Iteration users: ArrayList user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 40. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 41. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 42. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 43. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 44. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  • 45. Summary • Good old callbacks/strategies • Very important abstraction 17 Wednesday, October 3, 12 17
  • 46. ADT What is your "A" for? Wednesday, October 3, 12 18
  • 47. Example: Messages Server Client 19 Wednesday, October 3, 12 19
  • 48. Example: Messages Server Client search for "lambda" 19 Wednesday, October 3, 12 19
  • 49. Example: Messages Server Client search for "lambda" exact match at ... 19 Wednesday, October 3, 12 19
  • 50. Example: Messages Server Client search for "lambda" exact match at ... similarity at ... 19 Wednesday, October 3, 12 19
  • 51. Example: Messages Server Client search for "lambda" exact match at ... similarity at ... message ::= search for term | exact item | similar item 19 Wednesday, October 3, 12 19
  • 52. ADT Abstract Algebraic data type data type ~I ~D nte ata rfa cla ce ss 20 Wednesday, October 3, 12 20
  • 53. Are you functional? ADT Kotlin V X V V Groovy V X V V Abstract Algebraic Scala typeV data X V data type V ~I V ~D Java 8 nt X V V ata erf cla ace ss Recursion Pure HO ADT 20 Wednesday, October 3, 12 20
  • 54. ADT in Kotlin 21 Wednesday, October 3, 12 21
  • 55. Utilization You may have your cake, but can you eat it too? Wednesday, October 3, 12 22
  • 56. Up to 5 HO-functions for free! g rad U p for e m ore Wednesday, October 3, 12 23
  • 57. Static Utility Methods backwards! 24 Wednesday, October 3, 12 24
  • 58. Static Utility Methods backwards! as opposed to 24 Wednesday, October 3, 12 24
  • 59. Extension Functions 25 Wednesday, October 3, 12 25
  • 60. Extension Functions Receiver Type 25 Wednesday, October 3, 12 25
  • 61. Extension Functions Receiver Type receiver 25 Wednesday, October 3, 12 25
  • 62. Summary • Extending existing types • Without changing the classes 26 Wednesday, October 3, 12 26
  • 64. – Dad, should I use FP? Epilogue Wednesday, October 3, 12 27
  • 65. – Dad, should I use FP? Epilogue – What is your problem?! Wednesday, October 3, 12 27
  • 66. – Dad, should I use FP? Epilogue – What is your problem?! P.S. Kotlin is cool :) http://kotlin.jetbrains.org Wednesday, October 3, 12 27
  • 67. Kotlin Resources • Docs: http://kotlin.jetbrains.org • Demo: http://kotlin-demo.jetbrains.com • Code: http://github.com/jetbrains/kotlin • Twitter: ➡ @project_kotlin ➡ @abreslav 28 Wednesday, October 3, 12 28