why kotlin is my favourite example of functional
play

Why KOTLIN is my Favourite example of Functional Programming ? - PowerPoint PPT Presentation

Why KOTLIN is my Favourite example of Functional Programming ? Jayashree S Kumar, IBM Agenda What ? Kotlin, Functional Programming Why ? Kotlin , Function Programming My Faviroute FP concepts with Kotlin Conclusion About Me


  1. Why KOTLIN is my Favourite example of Functional Programming ? Jayashree S Kumar, IBM

  2. Agenda • What ? Kotlin, Functional Programming • Why ? Kotlin , Function Programming • My Faviroute FP concepts with Kotlin • Conclusion

  3. About Me • Java Classes Library developer • Worked Extensively on JDK’s Testing • Runtimes team @ IBM Software Labs

  4. WHAT ?

  5. • Statically Typed • JVM Targeted • Open Source • OO & FP features • 100% Interoperable with Java Borrowed : https://www.slideshare.net/abreslav/introduction-to-kotlin-brief-and-clear

  6. • Functions first class citizens • Immutable data • Mathematical(Pure) functions • Easier to write, reuse & test • No loops => lots of recursion, less e ffi cient.

  7. Hello, World! Compile error: Val cannot be reassigned //Top-level functions //Optional “ ; ” . no "new" // Types on the right // Strong type inference // Val & Var(traditional way) to declare types

  8. WHy?

  9. FP now? • Exists since 1958(LISP)… Haskell (1990), OCaml (1996), Scala(2004), Clojure(2007) • Highly parallel multicore architectures -> high concurrency -> immutability in code design • Better compilers and runtimes -> more expressive • Because Java got it to mainstream! Fact: Whatsapp needs only 50 engineers for its 900M user because Erlang is used to implement its concurrency needs. Facebook uses Haskell in its anti-spam system.

  10. Kotlin ? PYPL - 16th rank, Modern, SOF - least disliked, Concise, RedMonk - Raising. SAFE ˜3.4 million Top-Notch apps on Tools Google Play SIMPLE learning curve

  11. How?

  12. Lambda 4

  13. Where Lambda? Execute a block of code later—> once or multiple times. - Run code in separate thread. - Run it multiple times - Run only when necessary - Run it at specific point in an algorithm Eg. comparison operation while sorting - Run code when some event happens Eg. on click of a link

  14. Higher-Order Functions

  15. Building blocks of HOF 10 20

  16. Closure 0 1 2 3 0 1 4

  17. Extension Function abc = (3, 2, 1)

  18. Composition, Currying = 25 = 6

  19. Lazy Evaluation

  20. Convert Java File to Kotlin File CTRL + ALT + SHIFT + K (or CMD + ALT + SHIFT + K) Command-line > vi HelloWorld.kt > kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar > java -jar Helloworld.jar

  21. Conclusion • FP is a journey . • Kotlin is making your life easier to on-board by making usage of functional concepts easier.. • Java, owing to its massive adoption, bears much more responsibility while making changes… • Happier to use my Java and Kotlin in conjunction!! :)

  22. Thank U!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend