What is functional programming?

Web Developers, or any person that wishes to work with Javascript, has to choose between a programming paradigm inevitably. But, what is a programming paradigm?

3.jpeg

Yesterday I say a video from Anjana Vakil (@AnjanaVakil on Twitter), where she explained what is functional in her own words during a JSConf in 2016.

When a programmer writes code, it can do so in various ways, one of them is through imperative programming, which is one of the most natural ways of writing code. When using the imperative programming style, one states to the computer each line of code that it has to run afterward: “first you do this, then this, and finally, this”.

But when we write using another programming paradigm, such as Object Oriented Programming (OOP), we tend to use objects and methods more frequently. When using OOP, we want to manipulate objects and work with a defined structure.

Now, when using functional programming, we work with functions as the main concept. In fact, we would need not only functions but also pure functions, since everything that makes any function work in this programming style, requires to be inside the function. For example, if a global variable is defined outside a “pure function”, this could cause problems and the function would not be pure any more.

2.jpg

In functional programming, according to Anjana, we would also work with hash trees or Merkle tree. The reason behind this is immutability, a concept that requires maintaining values in variables, especially arrays, completely intact. Every time we wish to make a little change in one of these arrays, instead of just creating an entirely new copy (to maintain to original one untouched), with the little modification, we could just use hash trees, that will enable us to recognize not arrays, but separated elements, and each time we want to make a new combination of elements in a new array, we could do so without creating a new copy every time.

I was really fascinated with this concept. For me, a “newbie” on the programming web development community, I didn’t even know what a programming paradigm or style was. Understanding this helped me to be more conscious about how I’m writing code; because, initially I thought that everything consisted of just using imperative programming, and then figuring another way of writing code with more experience. Programming paradigms helped me to give further structure to my still-growing programmer thinking.

There are a lot of things I didn’t mention in this entry. Anjana mentioned a lot of things on her video that you should watch right now because she’s a really good communicator! Also, she has a lot of other videos where she deepens even more on the topic of functional programming, and other things such as Lambda Functions on Python (“and behind lambda is actually one of the most powerful & elegant abstractions in the history of computer science”)

Check her video out!:

Sort:  

Congratulations @freedomanytime! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 10 posts. Your next target is to reach 20 posts.
You made your First Comment

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Support SteemitBoard's project! Vote for its witness and get one more award!

Congratulations @freedomanytime! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You got a First Reply

Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word STOP

Support SteemitBoard's project! Vote for its witness and get one more award!

Coin Marketplace

STEEM 0.25
TRX 0.20
JST 0.038
BTC 95561.42
ETH 3560.31
USDT 1.00
SBD 3.76