OO/Imperative programmers: ‘Study Functional Programming or Be Ignorant’

Right now, if you want to understand the state of the art in computer programming, those are your choices as I see them.

Sorry to be so blunt … please don’t shoot the messenger.

My awakening started when I began searching for a better Java, and found Scala. Scala had these weird (in my ignorance) functional features and learned Scala people often talked about Haskell. A uni friend Bernie Pope raved about it too.

I took a look at Haskell. It wasn’t a pleasurable experience. Much of the code was almost incomprehensible. Half the concepts I’d never heard of before. It made me feel stupid, but actually what I was was ignorant.

I say ignorant, rather than innocent, because Haskell has been around for over a decade, and FP much longer.

I still struggle to read most Haskell, and I certainly can’t use it to build anything. But I am starting to get a sense of just how sophisticated it is, and a map of it’s concepts in my mind. I began by going down a rabbit-hole, and expected to find a burrow, a community of Haskelliers programming in their own unique way. Instead, bit by bit Ive realised Ive ended up in a vast cavern absolutely full of stuff I barely even knew existed.

The bit that stirs me up is that this “stuff” isn’t, repeat is not, Haskell-specific. Its rooted in the fabric of our reality, in our mathematics and our problem domains, and bits poke up like the tips of icebergs into mainstream OO languages, their true structure part-revealed. But rarely in the OO-world have I found such carefully abstracted and subtle techniques of programming in daily use.

Ideas from Haskell & Functional Programming will continue to flow into the mainstream over the next couple of decades. Innovations will be trumpeted, trends identified, features debated, technologies evangelized.

But personally, Im too curious (and too lazy a typist) to wait that long.,

About these ads

26 Comments

  1. Lachlan O'Dea said,

    June 2, 2009 at 2:51 pm

    I had exactly the same experience when I started learning Scala (also coming from Java). To a Java programmer like myself, Haskell looks like alien technology at first. I feel like I’m learning how to program from scratch when I try to program in this way. I should point out, in case it wasn’t clear, that this is a good thing :-).

    I’m coming to the conclusion that functional programming is more than just a different “style” of programming. It’s not a case of “functional vs OOP, which is better?”. Functional programming is about working with the fundamental mathematical concepts that describe computation (knowledgeable functional people will probably cringe at my clumsy wording). All of the fundamental concepts like monads are present in code written in Java or C#, but they’re not explicit and you’re simply not aware of it until you learn some functional stuff. One of the results is that most Java programmers have no idea how much of their code is actually boilerplate.

  2. BONUS said,

    June 3, 2009 at 6:11 am

    That’s what I really like about functional programming. We describe what stuff is in terms of other stuff instead of giving a computer some steps to carry out. The concepts aren’t langage-specific, and our logic, reality, and mathemathics kind of pop out in functional languages, allowing us to model them with programs and learn more about them. For instance, the whole overlap of functional programming and cathegory theory is a testament to that. Also zippers being derivatives of types, etc.

    So yeah, it’s pretty awesome and I’ve even developed a little obsession where I spend a lot of time trying to explain to myself why I find all this so awesome.

  3. Tommi Ripatti said,

    June 5, 2009 at 7:46 pm

    Welcome to FP land!

    Haskell is truly awesome and when you get it, it can be a once-in-a-lifetime learning experience :)

    The thing I most like about Haskell is the way it really cuts down code to it’s bare essentials. That is, unless you go over the board with arrows, point free style and all the other goodies Haskell programmars are spoiled with :)

    Although I had my mandatory introduction to functional programming
    concepts at Uni (in those days Scheme was still mandatory at Helsinki University of Technology), I did not really have the background or experience to see any benefits of doing things ‘the hard way’, as it then seemed.

    I was very lucky to have plenty of control over my work when I was doing non-comp.sci research recently for a few years. Implementing / reimplementing a bunch of projects in Haskell was certainly among the most rewarding experiences I have ever had in computing.

    Sadly some of it’s libraries are quite unstable, and many lack documentation past the mandatory typesignatures.

    Getting a working set of libraries to do varied IO stuff ( databases, user interfaces, and such) can be a real pain.

    Having said that, I wish I could work with Haskell – every day.

    Tommi

  4. intoverflow said,

    June 30, 2010 at 7:04 am

    This captured my experience perfectly.

    My favorite thing about this post: you captured an essential point, which is that Haskell’s good ideas aren’t Haskell-specific. It’s easy to imagine them in other languages, and over time this vision will likely manifest.

  5. June 30, 2010 at 9:47 am

    After taking some time to look at functional programming, you should dive into logic and constraint programming.

  6. June 30, 2010 at 12:09 pm

    And now that you’ve been inducted into the Cult of Haskell, come at join us at AusHack in a few weeks time! http://www.haskell.org/haskellwiki/AusHac2010

  7. Tony Morris said,

    June 30, 2010 at 12:57 pm

    Excellent article Ben. Spot-on with many points.

  8. June 30, 2010 at 5:27 pm

    [...] a comment » When I read Ben Hutchison‘s OO/Imperative programmers: ‘Study Functional Programming or Be Ignorant’ I knew I had too much to say for the comments, so I figured I’d put in my 2 cents [...]

  9. Brian said,

    July 1, 2010 at 1:27 am

    Unfortunately, I did study functional programming quite a bit, doing a lot in F#. I still get called ignorant because I don’t think that functional programming is a replacement for all other paradigms.

  10. mrkkrj said,

    July 26, 2010 at 6:32 pm

    Study Functional Programming or Be Ignorant –> ??? much if that stuff has been around for a long time, so any programmer doing C++ or/and Perl has had some exposure to it (except monads, as they are useles in non-lazy setting) IMHO. So don’t exxagerate.

  11. Ivan Miljenovic said,

    July 27, 2010 at 4:05 pm

    @mrkkrj: so you’re saying that F# is a lazy language? http://blogs.msdn.com/b/dsyme/archive/2007/09/22/some-details-on-f-computation-expressions-aka-monadic-or-workflow-syntax.aspx

    Actually, all of .Net must be lazy: http://en.wikipedia.org/wiki/LINQ

    Also, whilst C++ or/and Perl might have features such as closures, first-class functions, function composition, etc. they aren’t as emphasised or as elegant as in an explicitly functional language.

  12. July 28, 2010 at 6:45 am

    Yes me too. I wish I had paid more attention to some people I worked with 15 years ago – Lisp and Haskell gurus that were patiently amused with this Java nonsense ;)

  13. Cadd said,

    July 28, 2010 at 3:58 pm

    i have learned some beginner C++ and visual basic, how to move from there?
    tyvm

  14. Paul Dyson said,

    July 28, 2010 at 7:35 pm

    A good summary and an interesting perspective but I’d like to be a bit of a controversialist: what’s wrong with ignorance?

    When I started programming it was only about assembly language programming: 6502, Z80a, 68000 and even Acorn Risc. I knew how to code 32-bit multipliers for 16-bit processors and how to read IEEE 754-1985 FP numbers from the binary. Maybe ten years ago every good programmer had a bit of ASM behind them, these days there are lots of good programmers who wouldn’t have the foggiest idea how to write even a simple iterator for the latest x86 (and I must admit I’d need a pretty comprehensive refresher first).

    Their (our) ignorance doesn’t stop good quality systems being delivered.

    I actually did some Lisp 16 years ago. My PhD supervisor got me to write a Lisp interpreter in C++; possibly the sharpest introduction to FP in history? It certainly blew my mind. Once I got it working he then asked me to write a Lisp interpreter in Lisp to run on my C++ Lisp interpreter. More brain frying but I got there. I learned something about FP, interpretive languages, meta-level programming, and how to take long walks when your head isn’t large enough to hold all the thoughts it needs to process.

    What I didn’t learn was how effective Lisp is at delivering good quality systems.

    I’m not anti-FP or pro-OO or a nostalgist for ASM. But I am interested in delivering good quality systems that users use and businesses get value from. And whilst I appreciate lists like this as a good summary of what I’m ignorant of, I’ve yet to see a good list of the reasons why Scala or Haskell or even dear old Lisp will allow me to deliver what I’m building better/faster/cheaper, why it will make the system easier to maintain and change over time with different people than wrote it.

    Or maybe I’m just ignorant of those too?

  15. July 29, 2010 at 5:43 am

    Hi Paul,

    > I’ve yet to see a good list of the reasons why Scala or Haskell or even dear old Lisp will allow me to deliver what I’m building better/faster/cheaper,

    I don’t have a list but some experience of working with scala over the last year and learning about FP.

    What I’ve found is that FP languages allow me to express solutions to problems much more concisely and elegantly than in an OO language like Java. Furthermore, when I return to code I wrote some time ago, I can understand it again much quicker than I would if it were Java. I also understand other people’s code quicker when its written in scala than I do in Java (despite 15 looong years of Java).

    Maybe this a failing of Java not supporting functions and a robust type system , perhaps smalltalk (inspired by lisp) would give me the same kind of results.

  16. Paul Dyson said,

    July 29, 2010 at 4:26 pm

    Hi Channing,

    So I think Smalltalk – which I have used to deliver enterprise systems – benefits from a number of things: its pure OO (removing all the primitives/auto-boxing/if(x == null) nonsense), its message- rather than method- based (ability to override DoesNotUnderstand) and it is image-based (the language, ide and execution environment are one and the same thing). It also benefits from the fact that its just hard enough to master and unpopular enough amongst the certification set that only people who really know and care what they’re doing tend to use it.

    I wonder if Haskel, Scala et. al. also benefit from the latter?

    Really interested in your experience that you can express and understand concepts better. Would you say this is universally true or true in certain circumstances? Are we talking about at the function level, the system level or both? My experience of running a number of projects that take over and rescue other peoples enterprise Java systems: one thing Java has going for it is that I can write or use tools that extract the gross structures and design from the code to give me a roadmap to the system. This is much harder in Smalltalk.

    My own take is that delivering good quality systems better/faster/cheaper requires a combination of language, IDE, libraries and environment. There was a point when Java won me over from Smalltalk because Java + Eclipse + various libraries for all sorts of integration and processing + Tomcat & MySQL was more effective than Smalltalk + DST + Objectivity. These days Java is struggling under the weight of its popularity: the language is bloated, eclipse is slow and buggy, the libraries are a morass of CSR lowest common denominators and the app servers/frameworks are the worst of the lot. Ruby/RAILS is gaining acceptance because the language is good and there are some good libraries, the IDE and environment are acceptable and will come because enough people can cope without them to gain the critical mass needed that will lead to their improvement.

    I wonder whether you see that Haskel, Scala and the rest need the same ecosystem to be truly useful in delivering enterprise systems and whether you think this will come?

  17. July 30, 2010 at 4:32 am

    I certainly think that Haskell benefits from being hard to master. Scala is not hard to use. You can write what you would in Java, just with a different syntax, which may mean that you will not benefit from a higher barrier to entry.

    However, if you start applying the FP concepts in scala then you different raise the bar.

    My experience with scala is things fall out better from the function level up to the system level – everything just seems easier. And the more I learn about functional stuff, and the type system, the easier things get but its a long road :)

    People are working hard on the ecosystem with build tools like sbt, web frameworks like lift, and IDE support in Netbeans, Eclipse and Intellij. I hope scala’s day will come.

  18. July 30, 2010 at 4:33 am

    should read before I post, I mean to say “However, if you start applying the FP concepts in scala then you definitely raise the bar.”

  19. July 31, 2010 at 5:05 am

    [...] Ben Hutchison’s Study Functional Programming or Be Ignorant [...]

  20. August 2, 2010 at 2:03 pm

    [...] OO/Imperative programmers: ‘Study Functional Programming or Be Ignorant’ « My Digital Neuron (tags: haskell functional programming functionalprogramming scala functional-programming oop) [...]

  21. June 11, 2011 at 11:54 am

    [...] Study Functional Programming Or Be Ignorant (2009, artículo de Ben Hutchison) [...]

  22. ccdan said,

    December 9, 2012 at 2:41 pm

    The vast majority of FP advocates are awfully clueless when it comes to real world software engineering and are completely delusional… just a much of math-obsessed people who have absolutely no idea how computers work and what programming is… :D

  23. July 25, 2013 at 1:53 am

    Thank you for your information, nice blog ;)

  24. August 6, 2013 at 8:26 pm

    Not bad at all this article on programming. Congratulations :)

  25. September 6, 2013 at 5:43 pm

    Scala is a great Java tool, thank you for the information.

  26. September 19, 2013 at 6:46 pm

    Really nice blog, good job. Great articles on programmers !


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: