Skip to main content

The promises of functional programming, by Konrad Hinsen

Hello and welcome to another post in my blog about functional programming. In this space we review several advances and insights made possible by the functional programming paradigm as a relatively new way to solve computational problems.

In this occasion,  I read "The promises of functional programming", by a scientific computer researcher named Konrad Hinsen.

In this paper, we can learn some core differences between the object-oriented style programming and the functional style-oriented programming. In general, we have spoken before about this differences throughly, which include:

  1. There are almost no variables
  2.  It's power relies on pure functions.
  3. No for loops, everything is implemented through recursion.
  4. Parallelization and concurrency optimizations.
This main reasons are several that show that functional programming is essential, in my opinion, as a compliment to object - oriented languages, like Java. Let me explain each point, before trying to explain this.

Functional programming languages do not make use of almost any kind of variable. The reason this is like this, is because when you call a function, you can call another function with that result. In another words, you can send functions as parameters to another functions. Yet, there are some implementations in Clojure - and in any other functional languages - that do require variables. That's why Clojure has the option to implement variables such as: vars, agents, atoms and references. All of this can be modified dynamically through a series of operations for each type of variable. The reason why everything could be done without variables, leads me to point number 2.

The reason why everyone says that functional programming languages make use of no variables, is because (I think) they're looking at it from a mathematical point of view, rather than a "real world" problem. As I have said before, at the core if you want to use the full power of functional languages you have to rely on pure functions. A function is said to be pure when every time you give the same input, it produces the same output, and that output does not have any impact anywhere else in the program's "world". Take for example f(x) = 2 + x. That is a pure function because no matter what value you evaluate it to, it will always produce the same output, say for example f(2) is always going to be 4. As opposed to a pure function, an impure function is one that relies on something other that what is in it's scope, for example take the function f(x) = 2 + x + a. The result of this will variate depending on the current state of a. And now, the problem with this approach is that sometimes we do want or need to use variables, so this approach works as an optimization to object-oriented approaches, in which it is way much easier to use "real world objects" such as sockets to managing connections.

In general, I think that functional programming is really exciting, trust me, it is incredibly easy to write robust programs that have a lot of functionality. The code seems elegant, and I think that once you grasp the full power of the language, developing time could be better than object oriented one.

Please go ahead and read "The promises of functional programming" by Konrad Hinsen to get more insights on the topic!


See you soon,

- Diego.


Comments

Popular posts from this blog

Revenge of the nerds, by Paul Graham.

So, once again we go to Paul Graham and his absolute amazing opinions on lisp. He understands the difficulty in changing the industry, but faces this with a good sense of humor and courage. You can check out his blog entry here . Taking it to the next level So the story goes like this. Michael Phelps went out there to change the world of an olympic sport. And did. Only he and his coaches know what he is doing differently but definitely, he is. Michael Phelps is such a good example because before Phelps, it was very rare to think of a swimmer that could do all the strokes in a competition, from crawl from breast stroke to his olympic record breaking butterfly stroke. In a sense, Phelps is like lisp. Phelps came to the 2004 Athens olympic games as a kid, he was only 19 years old, but everyone knew he had the chance to break the olympic record for 7 gold medals in the same event. He went on it and won 8 of them. So... what is he doing differently than any other swimmer? How long does

The semicolon wars by Bryan Hayes, reviewed.

I'm not an expert progammer, but I've been working with differnet programming languages for about 3 years now. I'm still a newcomer to this whole new world of opportunities with thechnology and programming... I don't think that the fact that I'm slim matters (a-ha) , since I think I've learned a lot in this past years. The point of view presented by Bryan Hayes is really interesting, and appealing. Starting out the course with a "let's go LISP!" seems like a good reading. But I've come across another good reading: "How to Choose a Programming Language: don't" and you can read it here . As I have said before, I'm not yet an expert in the languages in which I feel the most proeficcient, but as one of my professors once told us: A specific requierment requieres an specific technology, and not the other way around. Since thinking about Technology setting us new requierements doesn't always make sense, since it may not be

Rich Hickey on Clojure

So Clojure is a new programming language developed by a person named Rich Hickey. You can hear about the features of this programming language  here . The developer of Clojure then states what we feared the most, we were right. Lisp language wasn't firstly thought to be used by everyone. In one of my previous posts you can hear another podcast by Dick Gabriel on why did Lisp languages fail so bad. You can go ahead and read my review on that podcast too, to which you can find a link in the post too. Basically it explains that lisp failed because of many many things, but mainly because of what he calls " the winter of lisp" and how did artificial intelligence made lisp languages fail so bad. Now there is a new hope, another lisp like language has been developed, and it still in it's early days, but it already addresses many of the problems that lisp had, and added some cool new features. Some of the solutions that Clojure provides are: Interoperability with th