Coding Bootcamp: Week 4 - Functional Programming Part 1 & Part 2

09-01-2020

This is an article that I originally wrote for my Wordpress site but have moved here.

Functional Programming Part 1:

🤔

Functional Programming Part 2:

For anyone who reads this who is like “oh no, another perspective on functional programming” just know that I am not necessarily offering guidance but just reflections on a week of learning it so feel free to comment or help understand.

So my goal is to keep this super, I mean incredibly super, basic.

Of the few things we have learned so far, one of the seemingly most important is this:

In functional programming you must use pure functions. What this means is that a function cannot be dependent upon anything outside of the function for its ‘functionality.’ If so it isn’t pure. The common comparison used is comparing functional programming to calculus. Functional programming is highly mathematic so it makes sense (and here we are talking about the way functional programming works is mathematical but you do not necessarily have to have a deep understanding of math to use it).

So far it seems that functional programming is a paradigm of programming that seeks to make code more readable. You can put functions within functions but the goal in mind is always readability and understandability for our code.

Back to the use of the word conceptual, if what I am writing seems very conceptual, thats because it is. It can be highly practical but functional programming is a mind-bending endeavor.

A much clearer explanation of functional programming as well as a deep dive into it can be found at the link below. Kyle Simpson makes functional programming reasonably understandable for ‘the other guy’ (me).

The main point and take-away of this post is this:

As coders, programmers, software-engineer’s, web-developer’s, etc, a great goal to have is readable and reasonable code. A bunch of for loops (for (let i = 0; i < arr.length; i++) with if statements in adds line upon line to files and makes it difficult to understand. If we can create functions that explain themselves and put functions within other functions so that we can see what we are doing on a SINGLE line of code, that is a much better alternative for those that may read our code whether on the job or just our repositories of code out there for the world to see.

I might say more about Functional Programming at a later time so there is no soon-to-be part 3. I know how much that bums anyone out who reads this 😏.

Til next time,

– Ben