Successfully reported this slideshow.
Your SlideShare is downloading. ×

Who's More Functional: Kotlin, Groovy, Scala, or Java?

Ad

Who's More Functional
                     Groovy, Kotlin, Scala or
                             Java?

                  ...

Ad

About Me

              •      Project lead of Kotlin
                   ➡       at JetBrains since 2010

                ...

Ad

Prologue




                           3
Wednesday, October 3, 12       3

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Ad

Check these out next

1 of 67 Ad
1 of 67 Ad
Advertisement

More Related Content

Advertisement

Who's More Functional: Kotlin, Groovy, Scala, or Java?

  1. 1. Who's More Functional Groovy, Kotlin, Scala or Java? Andrey Breslav Wednesday, October 3, 12 1
  2. 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. 3. Prologue 3 Wednesday, October 3, 12 3
  4. 4. Prologue – Dad (or Mom), is Java a functional language? 3 Wednesday, October 3, 12 3
  5. 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. 6. What is FP like? Wednesday, October 3, 12 4
  7. 7. Alonzo Church 𝛌 1936 5 Wednesday, October 3, 12 5
  8. 8. Alonzo Church 𝛌 1936 1946 5 Wednesday, October 3, 12 5
  9. 9. Alonzo Church 𝛌 1936 1946 5 Wednesday, October 3, 12 5
  10. 10. Alonzo Church 𝛌 1936 1946 1956 5 Wednesday, October 3, 12 5
  11. 11. John Backus Alonzo Church 𝛌 1936 1946 1956 5 Wednesday, October 3, 12 5
  12. 12. Can Programming be Liberated from the von Neumann Style? John Backus Alonzo Church 𝛌 1936 1946 1956 1976 5 Wednesday, October 3, 12 5
  13. 13. 6 Wednesday, October 3, 12 6
  14. 14. – Dad, what's good about FP? 6 Wednesday, October 3, 12 6
  15. 15. – Dad, what's good about FP? – It makes you look smart 6 Wednesday, October 3, 12 6
  16. 16. – Dad, what's good about FP? – It makes you look smart – Like wearing glasses? 6 Wednesday, October 3, 12 6
  17. 17. Effects (Mutability) 𝛌 John von Neumann Inputs commands State VS f(g(x), y) Outputs 7 Wednesday, October 3, 12 7
  18. 18. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  19. 19. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  20. 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. 21. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  22. 22. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci Wednesday, October 3, 12 8
  23. 23. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci commands State Wednesday, October 3, 12 9
  24. 24. Effect-Free 10 Wednesday, October 3, 12 10
  25. 25. Effect-Free 10 Wednesday, October 3, 12 10
  26. 26. Effect-Free – Dad, how do I 10 Wednesday, October 3, 12 10
  27. 27. Effect-Free – Dad, how do I - print("Hello")? 10 Wednesday, October 3, 12 10
  28. 28. Effect-Free – Dad, how do I - print("Hello")? - write to a file? 10 Wednesday, October 3, 12 10
  29. 29. Effect-Free – Dad, how do I - print("Hello")? - write to a file? - do both? 10 Wednesday, October 3, 12 10
  30. 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. 31. Summary • FP makes things simpler • Sometimes at a huge price • Our languages are not purely functional 11 Wednesday, October 3, 12 11
  32. 32. Higher Order FP brings order :) Wednesday, October 3, 12 12
  33. 33. FibonacciTest 13 Wednesday, October 3, 12 13
  34. 34. FibonacciTest – How do I test both implementations? 13 Wednesday, October 3, 12 13
  35. 35. test(f) 14 Wednesday, October 3, 12 14
  36. 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. 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. 38. Internal Iteration 16 Wednesday, October 3, 12 16
  39. 39. Internal Iteration users: ArrayList user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16 Wednesday, October 3, 12 16
  40. 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. 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. 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. 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. 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. 45. Summary • Good old callbacks/strategies • Very important abstraction 17 Wednesday, October 3, 12 17
  46. 46. ADT What is your "A" for? Wednesday, October 3, 12 18
  47. 47. Example: Messages Server Client 19 Wednesday, October 3, 12 19
  48. 48. Example: Messages Server Client search for "lambda" 19 Wednesday, October 3, 12 19
  49. 49. Example: Messages Server Client search for "lambda" exact match at ... 19 Wednesday, October 3, 12 19
  50. 50. Example: Messages Server Client search for "lambda" exact match at ... similarity at ... 19 Wednesday, October 3, 12 19
  51. 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. 52. ADT Abstract Algebraic data type data type ~I ~D nte ata rfa cla ce ss 20 Wednesday, October 3, 12 20
  53. 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. 54. ADT in Kotlin 21 Wednesday, October 3, 12 21
  55. 55. Utilization You may have your cake, but can you eat it too? Wednesday, October 3, 12 22
  56. 56. Up to 5 HO-functions for free! g rad U p for e m ore Wednesday, October 3, 12 23
  57. 57. Static Utility Methods backwards! 24 Wednesday, October 3, 12 24
  58. 58. Static Utility Methods backwards! as opposed to 24 Wednesday, October 3, 12 24
  59. 59. Extension Functions 25 Wednesday, October 3, 12 25
  60. 60. Extension Functions Receiver Type 25 Wednesday, October 3, 12 25
  61. 61. Extension Functions Receiver Type receiver 25 Wednesday, October 3, 12 25
  62. 62. Summary • Extending existing types • Without changing the classes 26 Wednesday, October 3, 12 26
  63. 63. Epilogue Wednesday, October 3, 12 27
  64. 64. – Dad, should I use FP? Epilogue Wednesday, October 3, 12 27
  65. 65. – Dad, should I use FP? Epilogue – What is your problem?! Wednesday, October 3, 12 27
  66. 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. 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

×