What are Functional Programming Languages
What are Functional Programming Languages
Functional programming languages are everywhere, and most websites on the internet use them. You are even familiar with this term because it is often thrown around, but what is a functional programming language and what are its advantages and disadvantages?
But before that let's take a moment to define programming paradigms before discussing what functional programming is.
What is a Programming Paradigm?
Since computers are machines at their core, we need good ways to communicate with them. However, the more abstract from ones and zeros we get, the more specialized a language is. This is why we have so many high-level languages, because they all function a little differently and are all suited for different tasks.
The meaning of programming paradigm is a way to categorize programming languages based on their main theory or methodology for dealing with data. Language qualifies for a paradigm by having a number of defining principles. There are many programming paradigms, many of which overlap or contain other paradigms. The two main paradigms are functional and object-oriented, but there are many more ways of handling data that neither of these paradigms consider.
What is Functional Programming?
Functional programming is one of the two main programming paradigms, alongside object-oriented programming. In short, functional programming focuses on pure mathematical functions and immutable data, i.e. data that cannot be changed once it has been created. It has no state, which means that the only thing that changes in a functional program is the input.
Since there is no state change with objects, in functional programming you can conceptually change the code order and still have the same output. It's as if you multiplied eight numbers together, it doesn't matter what order you multiply them in, you'll still achieve the same result.
In this sense, functional programming is all about flow. Input appears at the top and output falls from the bottom. This is in contrast to object-oriented programming, which is more of a mutable state machine, with unique and mutable objects.
Advantages and Disadvantages of Functional Programming
1. Pure functions are easier to understand because they don't change any state and depend only on the input given to them. Whatever output they produce is the return value they provide. Their function signatures provide all the information about them i.e. their return type and arguments.
2. The ability of functional programming languages to treat functions as values and pass them to functions as parameters makes code more readable and easy to understand.
3. Easier testing and debugging. Since pure functions only take arguments and produce output, they don't produce any changes that take no input or produce some hidden output. They use immutable values, which makes it easier to check for some problems in programs written using pure functions.
4. It is used to implement concurrency/parallelism because pure functions don't modify other variables or data outside of it.
5. It adopts lazy evaluation which avoids repeated evaluations as values are evaluated and stored only when needed.
1. Sometimes writing pure functions can reduce code readability.
2. Writing programs in a recursive style rather than using loops can be a little intimidating.
3. Writing pure functions is easy but combining them with rest of application and I/O is a difficult task.
4. Immutable values and recursion can cause performance degradation.
Examples of Functional Programming Languages
* Clojure – This is a powerful functional programming language built on top of Lsip, which has been around since the 1950's. This means functional to the core. It runs on the Java platform and compiles to JVM bytecode.
* Haskell – Haskell is another pure functional language, and is designed to solve real-world problems, not academic problems. It's not as old as Lisp; it was made in the 1990s. It has been used for several popular projects, such as the Xmonad window manager.
So What Is Functional Programming? Functional programming is a programming paradigm that existed before the emergence of object-oriented. Basically, functional programming treats functions and data as immutable. In a functional programmer, functions may not change the original data or program state.
So many articles What is Functional Programming Languages. Look forward to other interesting articles and don't forget to share this article with your friends. Thank you…
Just an ordinary person who wants to share a little knowledge, hopefully the knowledge I provide can be useful for all of us. Keep in mind! Useful knowledge is an investment in the afterlife.
Post a Comment