Your SlideShare is downloading. ×
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

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

4,579

Published on

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,579
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
36
Comments
0
Likes
6
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Whos More Functional Groovy, Kotlin, Scala or Java? Andrey BreslavWednesday, October 3, 12 1
  • 2. About Me • Project lead of Kotlin ➡ at JetBrains since 2010 Andrey Breslav • EG member of JSR-335 ➡ Project Lambda 2Wednesday, October 3, 12 2
  • 3. Prologue 3Wednesday, October 3, 12 3
  • 4. Prologue – Dad (or Mom), is Java a functional language? 3Wednesday, October 3, 12 3
  • 5. Prologue – Dad (or Mom), is Java a functional language? – Dont you know your dad from your mom?! 3Wednesday, October 3, 12 3
  • 6. What is FP like?Wednesday, October 3, 12 4
  • 7. Alonzo Church 𝛌 1936 5Wednesday, October 3, 12 5
  • 8. Alonzo Church 𝛌 1936 1946 5Wednesday, October 3, 12 5
  • 9. Alonzo Church 𝛌 1936 1946 5Wednesday, October 3, 12 5
  • 10. Alonzo Church 𝛌 1936 1946 1956 5Wednesday, October 3, 12 5
  • 11. John Backus Alonzo Church 𝛌 1936 1946 1956 5Wednesday, October 3, 12 5
  • 12. Can Programming be Liberated from the von Neumann Style? John Backus Alonzo Church 𝛌 1936 1946 1956 1976 5Wednesday, October 3, 12 5
  • 13. 6Wednesday, October 3, 12 6
  • 14. – Dad, whats good about FP? 6Wednesday, October 3, 12 6
  • 15. – Dad, whats good about FP? – It makes you look smart 6Wednesday, October 3, 12 6
  • 16. – Dad, whats good about FP? – It makes you look smart – Like wearing glasses? 6Wednesday, October 3, 12 6
  • 17. Effects (Mutability) 𝛌 John von Neumann Inputs commands State VS f(g(x), y) Outputs 7Wednesday, October 3, 12 7
  • 18. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo FibonacciWednesday, October 3, 12 8
  • 19. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo FibonacciWednesday, 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 RecursionWednesday, October 3, 12 8
  • 21. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo FibonacciWednesday, October 3, 12 8
  • 22. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo FibonacciWednesday, October 3, 12 8
  • 23. 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Leonardo Fibonacci commands StateWednesday, October 3, 12 9
  • 24. Effect-Free 10Wednesday, October 3, 12 10
  • 25. Effect-Free 10Wednesday, October 3, 12 10
  • 26. Effect-Free – Dad, how do I 10Wednesday, October 3, 12 10
  • 27. Effect-Free – Dad, how do I - print("Hello")? 10Wednesday, October 3, 12 10
  • 28. Effect-Free – Dad, how do I - print("Hello")? - write to a file? 10Wednesday, October 3, 12 10
  • 29. Effect-Free – Dad, how do I - print("Hello")? - write to a file? - do both? 10Wednesday, 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 10Wednesday, October 3, 12 10
  • 31. Summary • FP makes things simpler • Sometimes at a huge price • Our languages are not purely functional 11Wednesday, October 3, 12 11
  • 32. Higher Order FP brings order :)Wednesday, October 3, 12 12
  • 33. FibonacciTest 13Wednesday, October 3, 12 13
  • 34. FibonacciTest – How do I test both implementations? 13Wednesday, October 3, 12 13
  • 35. test(f) 14Wednesday, 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 14Wednesday, 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 15Wednesday, October 3, 12 15
  • 38. Internal Iteration 16Wednesday, October 3, 12 16
  • 39. Internal Iteration users: ArrayList user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 40. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 41. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 42. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 43. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 44. Internal Iteration users: ArrayList users: ParallelCollection user 1 Hello user 2 Hello user 3 Hello user 4 Hello 16Wednesday, October 3, 12 16
  • 45. Summary • Good old callbacks/strategies • Very important abstraction 17Wednesday, October 3, 12 17
  • 46. ADT What is your "A" for?Wednesday, October 3, 12 18
  • 47. Example: Messages Server Client 19Wednesday, October 3, 12 19
  • 48. Example: Messages Server Client search for "lambda" 19Wednesday, October 3, 12 19
  • 49. Example: Messages Server Client search for "lambda" exact match at ... 19Wednesday, October 3, 12 19
  • 50. Example: Messages Server Client search for "lambda" exact match at ... similarity at ... 19Wednesday, 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 19Wednesday, October 3, 12 19
  • 52. ADT Abstract Algebraic data type data type ~I ~D nte ata rfa cla ce ss 20Wednesday, 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 20Wednesday, October 3, 12 20
  • 54. ADT in Kotlin 21Wednesday, 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 oreWednesday, October 3, 12 23
  • 57. Static Utility Methods backwards! 24Wednesday, October 3, 12 24
  • 58. Static Utility Methods backwards! as opposed to 24Wednesday, October 3, 12 24
  • 59. Extension Functions 25Wednesday, October 3, 12 25
  • 60. Extension Functions Receiver Type 25Wednesday, October 3, 12 25
  • 61. Extension Functions Receiver Type receiver 25Wednesday, October 3, 12 25
  • 62. Summary • Extending existing types • Without changing the classes 26Wednesday, October 3, 12 26
  • 63. EpilogueWednesday, October 3, 12 27
  • 64. – Dad, should I use FP? EpilogueWednesday, 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.orgWednesday, 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 28Wednesday, October 3, 12 28

×