Hi everyone in this video I'm going to highlight a about why Java8 important and why the Java
developers should invest in learning all the features that got introduced as part of Java8.
We all know that Java is one of the most popular and widely accepted language in the world. Since it's
already one of the mostly used language.
Why the Java creators decided to change it. Java creators decided they wanted to introduce the functional
features such as Lambdas, Streams, Optionals and etc because of the technology advancements that are happening
around the world.
Even a smart mobile in our hands have multiple processors in order to make use of the multiple
processors prior to Java 8 you have to use threads.
Otherwise you will just be accessing only one processor even though the system that you with you
have multiple processors and we all know that working with threads is so touchy and you have to be
really really careful working with Threads.
With Java8 we will be able to write the functional programming code using the new functional concepts
which is going to help you simplify the concurrency operations which will make use of the multiple processors
whenever you perform the concurrency operations.
We will be covering a lot of examples on this topic in the course. Now, we'll talk about what are the other
capabilities that functional programming can help you achieve.
It supports creating immutable objects which is going to solve a lot of problems in the java application.
If you think about it mutable objects are the source for many errors in java application and functional programming
highly discourages mutating an object and functional programming is going to let you write more concise
and readable code. With Java8
it is going to let you use the functions or methods as first class citizens.
What does it mean is that functional programming is going to let you create a function and assign that functionality
to a variable and pass it around as like method parameters.
This was never possible before Java 8.
This is an excellent addition to Java8.
Here is a simple example that I have here.
This whole line might look new to you because function is something which got introduced as part of
Java8.
This represents the input and this represents the output and we have a new syntax here.
This syntax is called lambda syntax.
You don't have to worry about it for now because I'll be walking you through all these concepts step
by step and we're going to cover all these concepts via code.
Don't worry about it for now. Let me explain what's happening here.
So here the input is going to be a string and then we are performing the uppercase operation on it and
then followed by that we are performing the concatenation operation here.
Basically two operations are happening and this logic is being assigned to a variable called add some
string and we can pass this add some string as like any other variable in Java.
That's one of the benefits of functional programming. With Java8 it is going to let you write the code
in a declarative way rather than an imperative way. What does it mean? I'm going to highlight the difference
between imperative and declarative style of programming.
Let's talk about the imperative style of programming.
This style of programming focuses on how to get the result that we want.
This style of programming embrace's changing the object's state to achieve an objective which is nothing
but mutating an object and getting that result you want. Lets say you want to achieve an objective then
you define the list of steps to achieve an objective.
You code what needs to be done in each step.
Imperative programming is a concept used behind the classic object oriented programming style.
Now let's talk about that declarative programming.
This style of programming focuses on what is the result you want.
It does not bother or worry about how to get the result.
This style of programming embraces object immutability. This style of programming is analogous to SQL.
In SQL,
we request for data from the tables but we don't care about what is
algorithm or how the data is retrieved from the DB. Right ?
Declarative style of programming is similar to the same concept. We will make use of the
functions that comes with the language.
So far Java 8,
there are lot of functions that got introduced as part of it.
You're going to make use of those functions in order to get the result we want.
You don't have to worry about how the data is processed behind the scenes in order to get the result
you want.
Functional programming uses a concept of declarative programming. I would like to explain the difference between
the imperative style and declarative style using some examples.
We'll code this in the following tutorials.
With we came to the end of the theory part.
Thank you for watching.