oh no, I just updated a ruby gem!

Are you a ruby developer? Do you want to manufacturer something to do? Well here is a quick tip. Take your beautiful working Rails 3 application that you started creating 6 months ago and type in “bundle update”.

I don’t think there exists a time when I have issued that command and then 10 seconds after it completed not thought “what the fuck was I thinking”. Just about every gem that updates seems to make several breaking changes. For real comedy value it’s worth doing it between major Rails releases, actually, I take that back, make that minor Rails releases.

This just doesn’t seem to happen with C++ libraries. When coding in C++ (which I do almost every day) I can reliably update to even major version changes and still be pretty much guaranteed that what worked before will still be working now. At most you get a “deprecation” warning. Not in the Ruby world, oh no, here progress is rapid but backwards compatibility is an afterthought. It really is no wonder that enterprises are so cagey about moving to, how can we say it, well in the words of Steve Yegge, hardcore liberal languages. There is something to be said for stability.

So is this a bad thing? As much as I would like to say that I think it is, I’m just not that sure. There is nothing more frustrating than using something that is not willing to change (I’m looking squarely at you Java). It’s the fact that there is no attempt to maintain backwards compatibility for at least a short period of time that doesn’t fill me with confidence.

These days you see many people picking the latest and greatest technology to build a business on. This always makes me squirm just a little. This may be OK for a small business with technical founders. However, it makes little sense for a company with shareholders where employees can leave at any time. I certainly wouldn’t want a company I’d invested my money in being in left open to the vagaries of change quite so much.

stop trying to show how smart you are

Sitting feeling bright and somewhat giddy with my own self confidence I decided to dust down my copy of “C++ Template Metaprogramming” by David Abrahams and Aleksey Gurtovoy. Thinking I really need to be the master of something and further thinking C++ template programming was that “thing”. I approached the task with some gusto for at least a few days hours minutes, however, as with most advanced study you really have to be willing to dedicate your life to it. It’s never long before the inevitable gloom of reality sets in and you realise that this is more than an afternoons work. Without much control your brain starts telling you that there are much more important things you could be doing. Thankfully for everyone else on your team you stop and decide that it’s just not worth it.

The fact is that writing code that only those who have decided to dedicate a fair chunk of their life to is never going to be the right choice. There is nothing worse than trying to understand code like this. There are times where it pays to be smart, like when you have a better (much) faster algorithm, or doing something saves you hundreds of lines of code. But most of the time you see this kind of code it’s people just trying to prove how smart they are.

Now C++ is not alone in this. Ruby has exactly the same problem – you can get stuff happening as if by magic. I could be wrong but I imagine most people read code from top to bottom, working line by line, they don’t expect code to be auto generated or happen as some elaborate method_missing technique. Sure I can maybe relax my vitriol for those building frameworks where things are being used in some generic unknown context. However the vast majority of applications out there don’t have to deal with these problems. The biggest problem these applications face is that the developers creating them want to architect some elaborate framework to fit a very specific use case – it almost makes me cry. I’m not sure why as a profession we don’t revel in an approach that oozes simplicity. This is certainly what the smartest developers I’ve working with have always managed to do.

back to the future with c plus plus

Around 6 years ago I was steadily programming away in C++ in Unix using a Sun Workstation and I quickly followed this up with some Windows programming using MFC. During this time I also experimented with PHP creating a small “MVC” style framework long before Rails was even a twinkle in it’s daddy’s eye. Now since then I’ve managed to have quite a varied experience with languages such as Java, C#, and most recently Ruby. However, I now find myself running back 6 years and working with good old C++ again.

So why am I back here? Well to be honest, performance. The stuff that I’m currently working on (Kidney Exchange Problem) requires a fair bit of it – it’s NP-hard optimization problem that that we really do need to find an optimal solution for using an exponential-time algorithm. Anyway, maybe more details on this another day.

With C++ being decidedly “yesteryear” with the cool kids, I was pleased to find that it still seems to have a large user base, a moderately active community, and with Google being heavily invested, it would appear that it ain’t going to die as quickly as people may have though. Despite this, I wasn’t holding out too much hope for finding a wealth of “modern” programming tools, and first on my list was a JUnit/NUnit clone.

After some searching and experimentation (which resulted in some moderate surprise) I came across Google Test – good old Google! In my opinion this is the best C++ unit test framework out there. I did try others (CppUnit, CppUnitLite, and another which I now can’t remember) but Google Test was the easiest to use, has everything I need, and seemed to be the most active in terms of development.

Also, now very old hat, is Boost. Although this has been around for quite some time, back when I was first invested in C++, this just didn’t exist (or if it did it was in its infancy). I just love things like shared_ptr and the Boost Graph Library. I’m sure there will be much much more I will find to use in the coming months in Boost.

Finally, for just now, I also have to put out an honerable mention to Google Mock. I’ve not had a chance to use this much at the moment but, like Google Test, it looks as if it will come in pretty handy.

It’s nice to see that C++ is still living and breath, even if it ain’t so cool any more. However, with the community and C++0x it looks as if it may well just have some sort of future.