The base of Functional programming is lambda calculus which was developed in 1930. Lambda is used for calculation utilizing functions. We can call it as a part of the programming language. It let us know what can be computable. Anything that is computed through lambda calculus is computable. It provides a framework that describes functions and their evaluation. In this way, its foundation of functional programming. As per the Wikipedia definition
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.
These languages are further categories into two section, Pure Functional language and Impure Functional Language
Pure Functional Languages are those which support only functional paradigms i.e. Haskell, Mercury, Clean
Impure Functional languages are those which support functional paradigms as well as imperative style programming(OOPs) for instance, Lisp, Scala, Clojure, F#, OCaml
Today we will discuss the functional programming which is continuously rising from the last few decades i.e. Elixir.
what is Elixir: Elixir is the functional programming, dynamic solution which is particularly designed for scalable solutions but also that are easily maintained. Elixir supports the Erlang VM which is known for low -latency, distributed and fault-tolerant systems. meanwhile, it was also successfully used in custom software and web development.
Erlang was developed in 1986 by Ericsson to resolve telephonic issues such as distribution, fault-tolerance, and concurrency too. It was written by Jose Valim who extends Erlang and shared friendly syntax in Erlang VM.
How Elixir as functional programming rising continuously
Elixir has various characteristics that make us rising day by day in web development.
- Local Reasoning of Code - In programming languages, for example, Java, data we use is mutable (can be changed). Factors that are passed around inside the program can be changed in different spots, which makes it increasingly hard to chase down bugs. This isn't an issue with Elixir, but here language we are using is functional and data is immutable.
- Fault Tolerance Failure - With most of the programming languages, a bug in one procedure or function will make your whole application crash and fall flat. In Elixir, in any case, if bug is available in one single procedure. On the off chance when that one client in a web application makes a connection request with a bug in it, that procedure will crash yet all other different clients will stay associated.
- Testability with clear syntax- In programming languages, for example, Elixir focus on small, concise and clear functions. At the point when you go for information through a function, it's straightforward what you put in and what you get out. This encourages test-ability and permits you to roll out fundamental improvements all the more rapidly.
- Quick and Confident Refactoring - As we know, Elixir is functional and immutable language it is quick for a developer to make changes in particular functions because they it is not going to effect the other part. Any little changes wont effect the other procedures therefore, its quick to refactor the things.
- Reliability- Reliability is one of the major side of Erlang that is also present for Elixir. Erlang is also called a battle-proven programming language, therefore no one can doubts on the reliability of Elixir programming as well.
- Concurrency- Concurrent systems often face some kind of higher latency and response rate, however, this is not the case in Elixir. Here, Process scheduler divide all the tasks and shift them according to the process. In fact, when your web application is in high load, it will not affect on the entire system. Elixir and Erlang are featured by a high concurrency. It keeps the processes independent to each other.
- Speedy- Elixir and Phoenix are both are fast. For instance, performance tests of Elixir’s shows better results than Ruby, and Phoenix response times are measured in microseconds. which is mind blowing! because speed matters a lot when it comes to user experience. It feels great when app reacts and responds quickly to all of the actions. Moreover, great performance always saves time, energy even cost too.
The market trend of Elixir from 2011 to 2020
When you can use Elixir
There are certain things when you realize you can use Elixir here to develop an application
- Application of any size whether a Large or small, Elixir is best fit in both cases and provides you fruitful results. Developer can easily scale up the applications too as per the future requirement.
- JSON and GraphQL, Elixir provides the best support for JSON and GraphQL web API as a restful web API.
- The batch processing system, it processes a large amounts of data in a batch or cluster, in asynchronous (or synchronous!) manner.
- Real-time entry, Elixir supports real-time changes too through GraphQL subscription. In this way, you can also track data and make changes in the back-end, meanwhile, those changes will be reflected front-end.
- Stateful web server, while developing web applications, you face multiple scenarios where you do require stateful web servers such as during building a web proxy, either for HTTP or websocket, a router that sends requests further to the slave servers. In this time, you feel need to track the state progress and what are the timeouts in between the connection. In those cases, Elixir will be the best choice for creating such infrastructure for your project.
- Industrialization, Think about the IoT things and moderation automation, It helps you to create, install and update the devices of real-world such as drones, brewing machines, assembly lines, CCTV cameras, and automated robots.
Differentiation between Functional Programming vs. Object-oriented Programming
- Functional Programming use Immutable data whereas OOP use Mutable data.
- Functional Programming follows Declarative Programming based Model whereas OOP follows Imperative Programming Model
- Functional Programming follows the approach as what are you doing on the program on the other hand OOP focuses on how are you doing your programming.
- Functional programming supports Parallel programming and OOP doesn't support the same.
- Functions used in the functional programming does not have any side effects whereas in OOP method can produce loop holes.
- Functional programming use flow control with function calls and function calls with recursion on the other hand OOP use loops and conditional statements.
- Execution order of statements in the Functional programming is not very important whereas it is important in OOP.
- Functional programming supports both "Abstraction over Data" and "Abstraction over Behavior" whereas OOP only support "Abstraction over Data".
To conclude, Elixir would be the best choice for web applications and suitable from small scale to large scale. It covers real-world technology and changes accordingly.