Howardism Musings from my Awakening Dementia
My collected thoughts flamed by hubris
Home PageSend Comment

Functional Programming in Java

My CS-301 course was taught in Scheme, using Abelson and Sussman's fantastic book, Structure and Interpretation of Computer Programs. I had primarily been a C programmer before this time, getting jobs writing low-level device drivers and whatnot, and at the time, I was quite skeptical of using an archaic, functional programming language. Quite the opposite. I quite enjoyed it.

My first job out of college was writing network protocol drivers, and obviously, this required no need for any Lisp variant. However, much of the FP techniques I learned was a good thing.

Twenty years later, I'm glad to see engineers and companies interested in functional programming languages (although in the guise of Java). I often say:

Like sex, every generation thinks they discovered functional programming.

We engineers are so conservative in our field, that we really could get a job on Fox News.

Paradigm disruption?

Sorry, I have a deliverable.

Want OOP?

Can I just graft that concept onto my old, familiar C language.

Now you need memory management?

This cup of Java is just right.

Now, you want functional programming, eh? Well, we wouldn't dare have the parenthesis on the left side of the function name…

Nope.

When C++ was first starting to take hold in 1990, I remember discussions (er, arguments) with colleagues about whether one couldn't just get the OOP concepts and features in C. Trying to write data hiding and other code in C was a useful exercise, and lately, I've been wondering if integrating some functional programming concepts in imperative Java might be helpful.

So I did, following the time-tested blueprint:

My conclusion? Getting rid of setter methods, using final variables, and immutable data types (from Google's Guava library) is great, but building complex functions through composition is pretty tedious.

Peat Bakke has taken this concept a step closer with his Schrodinger project. But playing with it really makes me want to use a real FP language.

I can't always blame an engineer's conservative nature for our current state, since we don't often have a choice. Companies are even more conservative, and they pay our wages. So while I doubt I could talk any employers into Scheme; Scala seems an easier sell. However, I wonder how successful people have had selling Clojure?

Tell others about this article:
Click here to submit this page to Stumble It