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

why kotlin is my favourite example of functional
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Why KOTLIN is my Favourite example of Functional Programming ?

Jayashree S Kumar, IBM

slide-2
SLIDE 2

Agenda

  • What ? Kotlin, Functional Programming
  • Why ? Kotlin , Function Programming
  • My Faviroute FP concepts with Kotlin
  • Conclusion
slide-3
SLIDE 3

About Me

  • Java Classes Library developer
  • Worked Extensively on JDK’s Testing
  • Runtimes team @ IBM Software Labs
slide-4
SLIDE 4

WHAT ?

slide-5
SLIDE 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

slide-6
SLIDE 6
  • Functions first class citizens
  • Immutable data
  • Mathematical(Pure) functions
  • Easier to write, reuse & test
  • No loops => lots of recursion, less efficient.
slide-7
SLIDE 7

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

Compile error: Val cannot be reassigned

slide-8
SLIDE 8

WHy?

slide-9
SLIDE 9
  • 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.

FP now?

slide-10
SLIDE 10

˜3.4 million apps on Google Play PYPL - 16th rank, SOF - least disliked, RedMonk - Raising.

Kotlin ?

Modern, Concise, SAFE Top-Notch Tools SIMPLE learning curve

slide-11
SLIDE 11

How?

slide-12
SLIDE 12

Lambda

4

slide-13
SLIDE 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
slide-14
SLIDE 14

Higher-Order Functions

slide-15
SLIDE 15

10 20

Building blocks of HOF

slide-16
SLIDE 16

Closure

1 2 3 1 4

slide-17
SLIDE 17

Extension Function

abc = (3, 2, 1)

slide-18
SLIDE 18

Composition, Currying

= 25 = 6

slide-19
SLIDE 19

Lazy Evaluation

slide-20
SLIDE 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

slide-21
SLIDE 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!! :)
slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24

Thank U!