10 Irresistible WordPress themes for writers
18 Sep 2018
If you are not familiar with functional programming, that not a big deal. Even the majority around you don't. After going through this, you will be introduced to this world.
First, let me first introduce you to the myths related to functional programming.
1. "Functional Programming" is well-defined
2. Functional Programming is just imperative programming but less
3. Functional Programming is inherently difficult
4. Functional Programming is inherently complex
5. Functional Programming is bad for GUIs
6. You need a lot of math to use functional programming
7. Functional programmers have to be exceptionally smart and good at computer science.
Now, you will get to know the exact thing while also getting a basic idea in the meantime.
Functional programming is well defined:
It isn't. It's one of the worst-defined terms in Computer science. There is no technical definition of "functional programming" that would not cause a lot of people to complain. Some definitions are too broad.
According to Wikipedia, “functional programming is a programming paradigm—a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.”
Very confused? Don't worry. You will get it at the end of the article. You will have a basic idea about functional programming.
Functional Programming is just imperative programming but less:
This is perhaps the most pernicious myth because it's widespread, exceptionally misleading and often unvoiced. People casually assume that functional programming is just like "normal" programming in a straitjacket. It isn't! At all. Instead, functional programming provides a new basis for programming. You express things differently. Often completely differently. In fact, much of the time, there isn't even a one-to-one mapping between things you would do imperatively and things you would do functionally.
This is most evident in Haskell as it's the only common language that's functional first. This actually lets Haskell be significantly more expressive than mixed languages. All sorts of things from to rewriting rules to laziness to large swathes of its libraries are all only really possible because of Haskell's functional core. At the same time, this is what makes Haskell so different from other languages. It's an entirely distinct way of thinking, a new foundation. Not a different size of the same usage as so many other languages.
Functional Programming is inherently difficult:
Functional programming is very different from what most people are used to. Many people find it difficult to pick up because it's like learning to program all over again. Remember what learning your first language was like, and imagine living through most of that again. Of course it'll seem difficult!
Going from Java to C# is just trivial. Going from Java to Python requires a slight shift in mentality, but it's basically the same thing. Even going from C to Java isn't that bad--in terms of concepts, Java adds on top of the same foundation as C. You have variables, control structures, statements and expressions. It's a gradual progression from the very first language you learned to the new imperative language du jour.
Functional programming is nothing like that. It really pulls the rug out from underneath your feet. The most fundamental ideas are completely replaced. No more statements. No more loops. No more variables. Hell, no more execution. Instead of running a functional program, you evaluate it. In fact, with a language like Haskell, the order of evaluation is below your level of abstraction and does not affect what your program does--the order of execution, which controls when effects happen, is completely separate to how expressions are evaluated! This means the order your program is written in largely stops mattering, which is very weird to imperative programmers because the imperative mindset involves holding the order of your program at the back of your mind at all times.
Functional Programming is inherently complex:
and "complex" is the same as "difficult". The first is a property of a system--roughly, how big it is. The second is a property of a person--how difficult something is depends heavily on experience and education.
Some people find functional programming difficult, to be sure. But this does not mean its complex! In fact, you could fit the core evaluation rules and typing rules for a language like Haskell on a single sheet of paper. Sure, you'd have to use a very concise mathematical notation, but this only works because there are so few rules! Admittedly, any language used in the real world including Haskell, quickly accretes additional complexity. But, at the very least, functional languages still retain a minimal, simple and well-defined core based on the λ-calculus, something imperative languages cannot really claim.
Functional Programming is bad for GUIs:
Functional programming is awesome for GUIs. They just do them differently. They have a brand new paradigm for GUI code: functional reactive programming (FRP). FRP makes GUI code simpler, more modular and more declarative.
FRP lets us do more than write nice reactive GUI code. It's also great for things like music or even robotics. It's a definite step up from using call-backs and state for all of these applications!
You need a lot of math to use functional programming:
You really don't. Sure, functional languages are designed on a mathematical foundation. In the same way imperative languages are designed on a computer architecture foundation. And yet you don't have to know an ALU from a register to use C! It will never hold you back in the slightest.
Functional programmers have to be exceptionally smart and good at computer science:
Functional programming isn't some dark, unholy magic. In many ways, functional programming actually helps you overcome a lack of brute intelligence. The Haskell type system drastically restricts the sorts of wrong functions you can write, which makes it possible to just bash your way through hard problems by mindlessly running into the type system.
All the stupid mistakes and some rather non-stupid mistakes are caught by the compiler. So you can just twiddle with your code until it type checks. Then it works. Usually. Far more often than it has any right to! Many of the tools Haskell give you the facility to overcome your own fallibility.
And smarter people seem more likely to pick functional programming up voluntarily. In fact, it's just like of yesteryear and yet notes how Python is widely regarded as one of the easiest languages to learn.
It's the time of the functional programming. Gone are days when the employers looked for C, C++, Java, and Python. Now, functional programming is in great demand and you must not feel left out in the race. This is just an introduction, intended to provide you with an idea of it and also tackling some myths in the process.