SlideShare uma empresa Scribd logo
1 de 67
Baixar para ler 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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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
 

Mais de 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
 

Mais de 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
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
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
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 

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