Skip to content
This repository was archived by the owner on Sep 19, 2020. It is now read-only.

Latest commit

 

History

History
16 lines (13 loc) · 1.77 KB

File metadata and controls

16 lines (13 loc) · 1.77 KB

Why Functional?

Why not?

This question gets asked a lot by new students in programming. Why learn a paradigm such as functional programming when a perfectly good Object Oriented Programming paradigm exists perfectly with C++/JAVA?

Strengths of Functional Languages

While it would be possible to write an entire library about functional programming, I won't do so here and relugate that task to better qualified and more eloquent writers. A simpler and much more concise task is listing out briefly the main strengths of functional languages.

  1. Functional Languages are highly mathematical.
    • The functional paradigm treats each and every computation and process as the evaluation of a mathematical function. For every input, there will be one output. As such it is very easy to debug programs written in functional languages as you can easily follow the flow of the functions.
  2. Data is Immutable and States are Non-changing.
    • Immutable data means that your variables can not be changed. Ever. While this is an early inconvenience, it becomes a blessing later on when you need not worry about variables suddenly changing out of nowhere (aka side effects).
  3. There is a garbage collector.
    • While it will forever be argued that micromanaging memory resources is far more efficient, in practice garbage collection systems are sophisticated enough that their performance is equal to manual memory managment, if not better (due to lack of human error).
  4. Write less lines of code, far less.
    • In almost all functional languages, what would normally take 10 lines in an imperative language, would take 2 lines or so. Imagine all that you could do with that time saved! (hint: it's called sleep)