The Promises of Functional Programming
The Promises
of Functional Programming
In this article, it explains that functional programming is not frequently used for 2 main reasons, one is reason is that functional programming is very different from traditional programming (also referred to as imperative programming) and thus requires a lot of learning and unlearning and the other reason that I did not know is that computer hardware implements the imperative programming model, so imperative programs are easier to compile into efficient machine code than functional programs. I agree with the author because thanks to these reasons it makes easier for you as a programmer to understand what the computer does and what you’re programming.
Nevertheless, functional programming has a lot of advantages that it can "cost" you to understand better your code but it will have a better performance, for example, a set of programmers dislike that syntax in Clojure for a simple multiplication is represented like this: (* 2 2) . This is a simple operator, but imagine if you are programming things that are more complicated, obviously it will look awful, but this cost gives you power thanks to this notation, because it gives you a way of using fewer resources and making your code faster according to the functional programming definition, furthermore, I always say that one of the most powerful resources of programming are comments, because it does not matter the programming language you are writing, you can comment your code and it gives you a way to understand better the code or even remember what did you do at that moment of inspiration, because in some cases, when it has been a long time since you wrote that powerful code, you can forget why did you do certain things, but comments are always useful and it is a practice that I do a lot when I am programming and it can handle this kind of problems in order to understand your code.
Functional programming has advantages for concurrency and parallelism. Concurrency refers to the existence of several processes executing over the same data; modifying the same variable. While parallelism refers to the division of tasks in different processes that execute at the same time (in parallel).
The problem you face when using concurrency is that you have to keep the data in a coherent way, this is solved with locks in imperative programming. (this takes computational resources) This means that while a process is writing something, other processes can only read them, not write on them. But in functional programming, there’s no such thing because it has no variables, so coherence is always assured (so this is why it takes fewer resources).
If you do not believe me about the powerful benefits of using functional programming here is an example of the use of functional programming and it is also mentioned in the article: Mathematica
Wolfram Mathematica is a mathematical system that it is used in the scientific, engineering, mathematical, and computing fields, you can create "workspaces" writing your code using the Wolfram language that it can use the functional programming paradigm, I did use this language during my course of numerical methods in engineering that I studied 1 year ago at ITESM and I can say that when I began to learn Clojure I remembered a lot the Wolfram language because it has some features in common, and I can say that the application of wolfram language that it is used in Wolfram Mathematica is a big example of the power of functional programming because you can do a lot of powerful things (calculations) using this programming paradigm and it uses fewer resources! So that it is a big reason of using this paradigm.
Many people can think that variables are always a good thing that made the programmer’s life easier, but after reading this, I think that it can change their mind because these variables have their negative effect also and if you don’t know how to handle them properly, then you are going to take a lot of computational resources. So this is one of the reasons that it can motivate you to understand better the functional programming in order to develop great software.
Comentarios
Publicar un comentario