As an attendee, I’m very much happy and I have gained some knowledge from GIDS 2017, and I would like to share the insights which I gained out of this conference.
I wish to share about the session “From Functional to Reactive Programming” given by Dr. Venkat Subramaniam, he is an excellent speaker, the session was very interesting and more interactive, the way he explained the concepts was really awesome.
From Functional to Reactive Programming:
What is Reactive Programming?
Reactive Programming is an asynchronous programming paradigm oriented around data streams and the propagation of change. This means that it should be possible to express static or dynamic data streams with ease in the programming languages used, and that the underlying execution model will automatically propagate the changes through the data flow.
Mostly as a software developer, we are writing code for quick solutions. But that code is not responsive and feasible even though it gives solution for that problem. In Reactive programming, it simplifies the codes and gives feasible and highly responsible solutions.
Imperative to Functional Style:
Imperative, every programmer knows this style and most of the institutions teach this style, programmers gain significant experience with its style. But using functional style, we can avoid writing lot of code inside the function for simple calculations.
In this example, we are finding the first even number which is greater than 3 and doubling it. This is imperative style that too very complex. The same example in functional style,
Its clear, concise and readable code, and lets you focus on solving the problem rather than the required procedure.
Function compositions means create a simple and reusable functions that we can combine to compose new function. In the about example we created small functions like isGreaterThan3() for finding number that is greater than three, isEven() for finding whether the number is even or not and doubleIt() for doubling the number. Then finally we have combined these functions to get the result.
Lazy evaluation is the program will not evaluate the expression until just-in -time when its value is needed. If the value is not needed during the execution of the program, the evaluation of the expression will be skipped.
In the above example the program will not evaluate the expression until we calling the findFirst() function. This function only triggering the program to filter isGreaterThan3() function, isEven() function and doubleIt() function.
Benefits of lazy evaluation:
The ability to define control flow
The ability to define potentially infinite data structures
Increase performance by avoiding needless calculations
Functional Reactive Programming:
Reactive programming also called functional reactive programming because it applies functions like lambdas and closures in a reactive manner asynchronous sequence of data. Reactive programming paradigm stays responsive in the face of failure, more responsive and responds in timely manner. An example of the reactive systems is Google Spreadsheet. The library Rx-Java used for reactive + functional programming in java 8.
Thanks to Dr.Venkat Subramaniam, is an award-winning author, founder of Agile Developer, Inc., and an adjunct faculty at the University of Houston.