Question

There's a lot of hype over functional languages right now, and I've spent the last year studying Haskell as my intro to FP as a result. Seeing the advantages FP provides is easy (such as referential transparency and easy concurrency due to the emphasis on immutability).

The question I have been asking myself, now, is whether imperative programming provides any clear advantage over the functional paradigm? I'm not considering more controversial advantages like, oh, more people in the industry know the imperative style. I'm looking more for advantages inherent to the style, regardless of popularity (such as, oh, it's actually better for writing performant low-level code quickly, or it's easier to debug because of x, y, and z, etc). We could pretend that it's an ideal world, if you like, when talking about each paradigm (for example, let's pretend that UNIX was written in SML when talking about functional disadvantages, instead of saying, imperative is advantageous because UNIX is written in C).

It seems I'm having a harder time these days finding out what the advantages of the imperative style are, especially as processor architecture get's more complex so that a Haskell vs C implementation of optimized low-level code looks equally frightening to me.

Was it helpful?

Solution

Well, you already hinted at the answer. Imperative programming is closer to the metal, so it makes more sense in places (like embedded) where you're working closer to the metal. Nobody would bother programming an Arduino in Haskell (well, except maybe for @JimmyHoffa), though programming one in Scheme is not unheard of.

Some other reasons:

  1. Computing model more readily maps to the underlying hardware.

  2. Imperative programs can be written in a functional style, with a small amount of additional effort.

  3. A huge base of preexisting imperative code guarantees the need for people having imperative skills.

The last point is perhaps the most important one. Imperative code has an advantage because its already out there, in great volume. And as long as we keep making languages like Java, we'll be writing more of it.

Licensed under: CC-BY-SA with attribution
scroll top