Is this functional programming?

Recently I’ve read a blog post by Keith Dahlby. It was titled “Is Functional Abstraction Too Clever?”. The title sounded more rhetoric because clearly Keith was very satisfied with the code he presented.

But it got me thinking again. After some time with Lisp at university, some Haskell and some functional thinking in Ruby, I’m deep into Scala for some months. I’ve written some functional code before in Java, but I’m using much more with Scala now. Many examples are mostly thinking and syntactic sugar to me, not something I can put a finger on: this is functional.

Haskell examples clearly are more functional – how so? – and some blog authors give very nice functional solutions. Some blog posts by Raganwald and Debasish gave me great insights into functional composability. But many examples of people new to functional programming do not look functional to me.

Keith says about functional programming:

To me, this is the value proposition of functional programming. By expressing the algorithm in terms of common operations, we’re able to spend more time thinking about the problem than the details of the solution.

Let’s take a look at his code:

Looks more like a filter pipeline than functional programming. Especially compared for example to the things Apocalisp does with functional programming. Years ago I wrote a rendering pipeline, before the functional hype, and it was just a collection of Filter objects which filtered and transformed input into output. There were many users, and no-one thought of it as “functional”. Keith goes on:

A similar change in an imperative implementation would almost certainly have been more involved and prone to error.

The example is written in C# so it supports closures neatly, transformed to Java it might look like this (the generics are not totally correct, I’m spoiled by Scala):

More involved? More prone to error? Not so sure. Someone with an OO background would righteously say: Sure this is OO. Method chaining and objects.

As we all know, Java is not a functional programming language, but an object oriented one. There isn’t much difference here, some shorter code, some syntactic sugar for creating functions. The only difference between object oriented and functional being that OO is more noisy? Is OO as superset of FP? The line blurs even more with Functional Java. Is functional not only a way of thinking? Immutable, side effect free, composable code blocks?

Is this example functional? What is functional? Your view would be appreciated, especially if you’re one of the usual suspects.

46 thoughts on “Is this functional programming?”

  1. Pingback: ???
  2. Pingback: motogolf
  3. Pingback: Trisha
  4. Pingback: Music Publishing
  5. Pingback: Music
  6. Pingback: para para dinle
  7. Pingback: joseph de saram
  8. Pingback: rhodium
  9. Pingback: joe de saram
  10. Pingback: Sandra balan
  11. Pingback: smart mode tøj
  12. Pingback: economics tuition
  13. Pingback: kimsin sen
  14. Pingback: buy danabol ds
  15. Pingback: aquatest steroid
  16. Pingback: android games
  17. Pingback: free download
  18. Pingback: drive with uber
  19. Pingback: kimim ben
  20. Pingback: original site
  21. Pingback: Hindi Sex Story
  22. Pingback: Bilskrot Göteborg
  23. Pingback: child abuse

Comments are closed.