The Java Hammer and Learning Functional Programming

Somehow I’ve ended up with three tools to do the job of one.

Ribbing other developers about their programming language of choice is all part of the culture. I nearly succumbed myself today.

The obvious joke being surely if you debug PHP you just end up with Perl6. Usually just a bit of a larf, but often dismissive humor is a quick way to avoid having to understand and learn something new. Occasionally, as in the case of the PHP Hammer, things can go perhaps a little to far.

This is my hammer:

I made it when I used to big wall climb a lot. Where I learnt to climb you couldn’t walk into the local climbing store and buy a hammer so I made one (along with a lot of my other gear). I bought a geologist’s hammer, cut part of the pick off, ground in a notch for pulling pitons and drilled a hole for attaching a funkness for ripping out stubborn pitons and busted bolts. It worked really well and I helped a couple of friends make their own hammers.

I don’t big wall climb any more but I hung onto the hammer. I still use it when I work around the house or garden and it works just fine to whack in nails. The handle is a bit longer and the head is heavier than a typical framing hammer so you can really punch a nail home with it. Of course because it’s heavier my feeble geek arms get tired quicker than they might with a smaller hammer. If I help a friend out on a project they always take the time to make fun of my hammer. However, it’s when I need to pull a nail out that the real problems start. I can’t just flip this hammer over and use the claws on the back, I have to resort to this tool:

Which is fine until the nails get large and then I have to break out Fat Max:

Somehow I’ve ended up with three tools to do the job of one.

I could go get a new hammer that’s more appropriate for the job, but when I just need to put in a few nails I never bother making the trip to the hardware store. I’d have to wade through shiny nail guns and battery powered impact drivers just to get one simple tool to do a straight forward job, so I stick with what I’ve got.

I realised today that this is exactly how I feel about Java. This is the Java Hammer; not always the right tool but I reach for it because it’s familiar.

Like most people who have been programming for a while I’m truly proficient (be honest) in a small number of languages, can muddle my way through in a few more, and I’ve written hello world in more languages than I can remember. I haven’t properly learnt a new language every year because it often ends up being relearning object oriented programming with different syntax.

Lately I’ve become interested in functional programming, particularly Scala. I can see that it will suit a lot of the programming problems that I have. What really interests me is the paradigm shift to functional programming. The trouble is, it’s hard to break the habit of the familiar especially when there is work to be done. I’ve been to presentations and tutorials about Scala and functional programming and the most useful for me was this one by Dianne Marsh. Dianne’s talk helped steer me off the inevitable path of being a functional fascist: behaviour that would make adoption at work difficult. Instead, she suggested ways to start using Scala in daily coding, beginning with non production code like tests and simple scripts and building out from there. Also, Dianne encouraged me to start out using Scala in an object oriented way, and to worry about writing functional code later. Sound advice for making a daunting change!

When the world stops shaking or erupting and I have the energy to look at a computer in the evenings, I’m going to finish working my way through Atomic Scala by Dianne Marsh and Bruce Eckel. It’s really great and I’m pretty sure that if I stick at it that one day I will be able to look at some code and realise that I can write in a truly functional style. It will be a nice break from the Java Hammer.

Footnote: This blog is about me learning something new that suits the programming problems I have. Don’t bother flaming, trolling, extolling the virtues of your favorite language, or any of that other pointless behavior. I won’t be listening. Put your energy into learning something new yourself.

Disclaimer: I have never coded in PHP and have no opinions about it. I do notice that it’s used for a lot of things on the web so it must be good for getting stuff done.

Written on August 1, 2013