Lets be clear about something from the very beginning - I’m not bright. I’m very enthusiastic, and that can get you far, but I’m not bright. Why is this relevant? We’ll see in a minute…
But let’s also be clear about something else; I reckon I’m a pretty good Java developer. If I was to subcategorise myself, I’d say I was a pretty good Corporate Java developer with good instincts in the Clean Code, Test Driven Design, KISS / YAGNI departments.
I’d also say that I “get” Object Oriented Programming. By that I mean I can remember the moment when the whole classes and objects concept fell into place in my head and I had a moment of clarity which persists to this day. It just makes sense.
I’d even go so far as to say that when I don’t grok a piece of Java code pretty quickly, it’s because there is some dodgy design, or a framework has imposed it’s view of the world too strongly, obscuring the clear concepts of an expressive OO design.
But I want to learn a new language. Why? Well, I’ve done this before. I learned Ruby previously (and blogged my process just as I am doing here) and I less explicitly learned Groovy which I use a little at work but mainly on the Job DSL Plugin OSS project. At the time of learning Ruby, getting to grips with a dynamic, non-statically-typed language was difficult and exciting. It also properly introduced me to new concepts which I came to love such as closures and DSLs. Feeling the grass on the other side of the fence also made me a better Java developer – I became explicitly aware of things that Java did well (it turned out I really like types, for all sorts of reasons) and not so well (there’s a lot of typing for starters, plus a vast amount of syntactic noise, and closures make for much more legible code).
So now it’s time again to learn another new language, and it’s time to get functional, and my language of choice is Scala.
Functional?
I’ve never done Functional programming before – neither conceptually nor explicitly. My education only properly exposed me to Java, and at the time, that seemed like a lot. But now, with all the noise coming from the Scala camp, and the fact that it’s rapidly growing JVM language with strong OO credentials and scripting and internal-DSL support built in from the ground up, it seems like it’ll be worth both the mental and time investments. Perhaps the only real benefit is that I become an even more aware of the strengths and limitations of Java itself. That’s no bad thing. Perhaps the only benefit will be that I learn more about the limitations of myself. That’s no bad thing either.
But this vocal community isn’t the only reason I’m starting this now. It seems to me, that with the recent publication of “Atomic Scala” by Bruce Eckel and Dianne Marsh, that the Scala community is ready to embrace the functional-noobs (read: not bright) amongst us. How so? They’ve approached learning the language using a cumulative, step-by-step approach which appeals to me greatly as a student. They’ve also steered clear of the “there are also 100 other ways of doing this” pitfall which appeals to the “learn via the syntax” rocket scientists, but which to me feels incapable of leading me towards a Functional equivalent of my “OO moment”.
This means they’ve focussed instead on an idiomatic way of doing things, and so there’s a way in for folks like me without a hint of an academic Functional or even Mathematical background. The same thing happens in the Pickaxe Book, and that helped greatly when I did this for Ruby. Add that to the fact that Thinking in Java was my gateway to my first language, I’m pretty confident that this will be a profitable approach this time.
Full Disclosure
Reading back over the last few paragraphs, despite my alleged humility, it does seem I’m pretty confident of a few things. Well, that’s because I’ve not been entirely honest. The book isn’t my first exposure to Scala (or even my second or third) and this won’t even be the first time I’ve read it. I’ve tried to get into Scala before. Having attended the massively popular JavaONE 2008 session by Martin Odersky, and having heard Dick Wall of the Java Posse enthuse about it, I decided to try and work my way through an O’Reilly Rough Cut of Programming Scala. But I didn’t get on well – it was the “here’s the syntax” directed approach that I’ve mentioned above, and it felt like I was missing the deeper connections and complete picture I’d need to build of the language in order of it to stick, and for me to properly understand it and be a proficient user of it.
Some more time passed and I was lucky enough to attend numerous Java Posse Roundups and came face-to-face with many hyper-concentrated bursts of enthusiasm in the shape of sessions, lightning talks, hackathons, and tens of “hallway conversations” (there’s not really a hallway to speak of in Crested Butte Church Hall).
Finally, a few years ago, I was even luckier to be asked by Bruce and Dianne if I’d read and comment on an early draft of Atomic Scala. As long as I could approach it as a complete and utter novice, I was happy, and fortunately, having an idiot on the team was what they were looking for. I was off. What I read was impressive, but more importantly, made sense to me, and it was that experience which finally drove me to decide to write this blog when the finished book finally came out.
Levels of Ignorance
But before we begin, there’s one more piece of data that must be submitted. Earlier this week I attended TypeSafe’s Fast Track to Scala. I’d finally managed to convince my boss to let me attend this two day course and was super excited that I was getting to attend this two-day immersion. It started very well, and after day one I felt confident – my head still well above water. But I’d grown complacent (stupid people do that) and day two plunged me off the edge into a conceptual torret, the bottom of which I had little hope of finding.
Firstly, lets make a few points crystal clear:
- It was not the fault of the course or the trainer that this happened – I failed to pay attention and keep up;
- by the time I realised I’d lost the thread it was too late to ask the relevant catch-up questions – the classroom is not a place to be selfish IMHO
On the train home I did however manage to make some sense at least of where I had lost the thread, and also analyse what I thought were the specific areas which had given me so little that to me felt solid enough to cling on to. These were:
- Algorithms – I was brought face to face with the fact that my ability to design algorithms is one of my weakest areas. By this I mean low level algorithms. The stuff you learn at University, like bubble sort
- The Functional Idiom – quite simply, in the core of my being, “map” doesn’t mean “apply this to every one of these”, and a “flatmap” is a map laid out nicely
The latter was the thing which slowly undermined me. There came a point, when we were looking at the collections API (which I am excited to eventually learn – it does look very powerful) when I had to keep looking back in the notes to remind me of what all these functions were doing for me. Sound stupid? Yup.
But it was the former, which was the thing that did for me. To be frank, I’d been avoiding facing up to this fact for along time and it’s not a Scala-only problem. (See, better Java developer already.) But now here it was, laid out in front of me. To make it worse I was surrounded by PERL hackers to whom this made perfect sense. I mean, they barely have objects!
Remembering the Kanji
After a good nights sleep, I’d come to terms with my predicament. I realised I’d been here before - during a short-lived (but successful, until I ran out of time) attempt to learn the 3000+ Japanese Kanji characters with James Heisig’s “Remembering the Kanji”. What that experience proved was I’m a visual guy – that’s why OO is such an attractive concept for me. Unfortunately the way that most folks are able to grok algorithms and concepts of functional programming doesn’t play into this, and consequently, few of the learning materials work along non-visual lines.
However, that didn’t mean I was disheartened, but it did mean I’ll need to take things slowly – ensure I fully understand every concept as I move through it. Rather than the “Fast Train (Track) to Scala” this will be more like the “Slow, Stopping, Regional Train to Scala”. But that’s cool, I can handle that. Armed with Bruce and Dianne’s book, which does work in a way that I’m comfortable with (at least in the draft I read) , I’m going to start out on my journey, and this blog will record my progress. As I plod slowly on, chapter by chapter, and koan by koan, I’ll put posts up here. The primary aim will be to help me ensure I fully understand everything, but if its useful for others folks, brill.
Ok, all set? Lets go….