Joel on Win32; API complexity and the Army of Muppets (a rant)

Joel has written a nice little piece on the demise of the Win32 API. Some of it I agree with; such as for many developers the fact that .Net is just the latest example of Microsoft indulging in a Fire and Motion exercise, yet for other developers it’s vitally important; the trick, as ever, is working out which camp you fall into… But some of it, I don’t.

I really don’t understand the problem with API complexity (but perhaps that’s because I don’t really understand the problem with API complexity…). Sure some aspects of the Win32 API are complex and hard to fathom but you only have to work it out once and then you’re done. You write some code that makes it easier to use and put that code in a library and use that in future. By doing this you get to understand the problem to a level that’s lower than you’d probably choose to, but at least you do understand it.

If you only need part of the API (such as just needing the SChannel aspects of SSPI) then you write wrappers that let you do that easily and ignore the bits (like Kerberos auth) that you don’t much care for. If you then need to use another part of that API you can either extend your wrappers or write new, focussed, classes for the new bits you need. If you find that your wrappers are at too high a level for a particular problem you can revisit them, refresh your understanding and then decide at how to craft the abstraction that you need for this version of the problem…

The key point is that you take this hit just the once, generally. From then on you have code that you’ve adjusted to how your mind deals with that particular problem; you have tests and whatever level of docs you feel comfortable with… If you need to go deeper you can, you don’t have someone else’s abstraction as the only way to do things…

OK, so the guy’s in VB-land or .Net-city don’t ever need to do this (except when they do because they need something that the people who wrote their runtime didn’t expect them to need and they have to delve into the raw API to achieve it…). Personally, I’d rather be used to doing this stuff, and know that I’m capable of doing it rather than work at someone else’s level of abstraction and then suddenly find that they don’t cut the mustard and realise that it’s hard to get up to speed on the lower level stuff just so that I can work out how to get the last 5% of functionality that I need to finish my app by tomorrow…

It’s the same with memory management, it’s not that hard, but you do need to think about it. It’s nice to work in a language that does that thinking for you but you have to be aware of the times when, perhaps, it’s not appropriate or possible; I agree that in ‘Enterprise-development-land’ those times are less often… The problem is that many “developers” don’t seem to think much at all, so they’re bound to get tied up with memory management; but, in general I’d prefer for them to remain tied trying to understand pointers rather than allowing them to skip all that and get on with writing really poor business systems ;)

It’s not as though you write C++ production code like those MSDN samples and do everything the hard way using bare API calls and have to copy the same 4 or 5 lines time and time again every time you want to access GetFileVersionInfo()… Oh, you do? Well that’s your problem then, not the complexity of the API, just that you’re failing to add any value with the code that you’re writing…

I think this is just a rant now, still, never mind… I’m starting to believe that, at 37, I must now be old and cranky because to be quite honest with you; if you’re not writing code in such a way that you define concepts and abstractions in such a way that the actual main line business logic code that you write is clear and easy to understand then you’re just not doing it right. You’re not adding value. You’re making things worse. You are part of the problem. You’re building shit on top of shit and nobody will thank you for it. You should give up and go become a landscape gardener or something… Told you I was old and cranky… ;)