JavaScript the Fun Part


functional-programming-javascript

functional-programming-learning-curve


My first experience with OOP happened with C++. Here is a simple code using OOP in C++.

class Foo;  // forward declaration of a class
 
class Bar { // definition of a class
  public:
    Bar(int i) : m_i(i) {}
  private:
    int m_i;
};
 
template <class T> // template argument
void qux() {
    T t;
}
 
int main()
{
    Bar Bar(1);
    class Bar Bar2(2); // elaborated type
}

After a while I told myself that I will become a master in C++, if OOP is just these concepts and techniques!.

I read the enter en.cppreference.com website, printed all pages, and read them, code, and push more than 2,200 examples with C++ on my github page. 1000_examples_with_cpp.

I noticed as much as I go further, it becomes harder and harder to code in OOP style. It seemed messy and I could not go further easily.!

Design Pattern

Yes, dealing with a large codebase, without any patterns or a kind of architecture, make the code messy! And the solution was by learning OOP's design patterns.

So taking off with OOP is not challenging. You can simply create a class and add data and method to it and it works.

But this is not true for functional programming. Why? Simple. Because without knowing many concepts at first you cannot start with FP. We first have to learn many things, which is tiring, then start to use very basic things, with is boring!

For exampling learning

Wait, wait. I do not want to learn these!

From Windows and Linux

When I was using Windows XP2, then 3. and finally 8, and 10; I noticed for a simple task I had to install a program - usually crack it - and for next one, installing new ones!

After a few months I had many installed programs and C drive was full. Solution? For really getting back and having a fresh OS, formatting the hard-disc and installing fresh!

But ... I moved to Linux.

I am a big fan of just using keyboard and not mouse. So quickly switching to Terminal. There is noting to do! A simple blinking cursor and that is it.

There were more than 2,000+ commands (= CLIs). Who is going to learning them? How? Fortunately after a while, little by little and learning simple CLIs and how to combine them to solve more complex task, now I am able to solve complex tasks with a few commands just by piping them in just one line!

Nnow I am very happen for migrating from Windows to Linux and sticking to Terminal and its way of using Terminal, having small CLIa that can be piped together to tackles more complex problems.

And FP is the same. We will have a hard time learning many small functions and concepts and after a while; we will be really good at combing each of these and solve our problems.

Fast versus Slow

With OOP we quickly can start coding. As we go forward - diving into larger code base - it becomes harder and harder - unless we learn Design Patterns well.

With FP the opposite happens. We first have to learn its concepts and techniques then start to code. Very annoying at first, but very sweet ending :).

Ready? Lets tackle some core concepts and techniques in FP from next posts, that we should grasp.


Update: Wed Oct 23 2019 08:18:00 GMT+0330 (Iran Standard Time)