Saturday, July 26, 2014

the perils of spare-time programming

So, it was only three days ago that I posted this, but already I'm having second thoughts and afterthoughts. These appear below as block quotes.

Frankly, I wasn't making much headway before, hardly managing to keep up with changes to Objective-C, and significant changes to the frameworks, like ARC, and to the developer tools.

Shortly after completing RatioKey 1.1, I became involved with the Robots Association, the organization behind Robots Podcast and This involvement relates to another consuming interest of mine, which is detailed in my Cultibotics blog. As I began to feel I was making headway on that front, the amount of time I gave to it increased until it consumed nearly all of the spare time I could muster, at which point I burned out (not completely, but I had to dramatically reduce my level of involvement to keep it going). However, I couldn't just pick up where I'd left off with RatioKey, because the intervening time had left me unfamiliar with my own code, and only vaguely acquainted with the changes Apple has introduced, so I began the process of getting back up to speed.

Now there's a whole new language (Swift) to learn, and learn it I will, even if it means putting off everything else until I've done so.

(Hopefully not to the point of another burn out!) The introduction of Swift has helped to focus my attention. Since I don't have a large Objective-C code base, it doesn't make much sense for me to continue to work in that language, especially considering that the language has continued to change while I was looking the other way.

Even if, as I expect is the case, Swift can't yet be used with Core Audio, which is a C-based API, it will be otherwise applicable, and important for me to get an early start with it, rather than trying to put off the inevitable change.

Actually, I may be wrong about Swift not working with Core Audio. At the very least, I should be able to import a C header into Swift.

Besides, there's quite a bit to like about Swift. It's clear that a lot of thought has gone into its design, and it continues the trend, which began with the addition of declared properties to Objective-C, of reducing the amount of code needed to get something done.

Beyond that, from what I've seen so far, it strikes me as being closer to the metal, not of the machine, but of the essence of programming. I presume this is a result of it evolving out of compiler technology, rather than the compiler being created to fit the language. This impression gives me confidence that what I haven't yet seen will also make sense to me.

...out of compiler technology and modern programming concepts...

Understand that I wasn't one of those who was easy to convince regarding the need for a new language. I like both C and Objective-C. In particular I like being able to use numerical variables as logical values (zero being false and everything else being true), and, while I haven't used it much, pointer arithmetic strikes me as an elegant solution. Admittedly, it took me more time and fretting than it should have to wrap my mind around expressions like primativeValue** or &scratchpadMemory, but I did eventually catch on, and now I appreciate the precise control they allow. On the other hand, having to use malloc() to obtain scratchpadMemory is a pain.

It's actually worse than that, because you sometimes have to first ask for the size of the data to be received, then allocate a block of memory to hold that, then ask for the data itself, passing in a pointer to the memory block you've allocated, but that pattern typically applies to C APIs and likely isn't going away just yet.

But this is all moot. Apple wouldn't have introduced Swift with such fanfare if it weren't destined to be the future. There are already Swift versions of frameworks that worked with Objective-C, and lower-level frameworks, like Core Audio, are sure to be given the same treatment or replaced with updated versions that are Swift compatible, and that's a trend I don't care to buck.

Actually, "Swift versions of the frameworks" is probably imprecise. It's more like they've created a very fast translator, but I really don't understand how it works, only that it does and is fairly easy to use.

So, RatioKey 2.0, or whatever it ends up being called, if and when I get it done, and provided that it's accepted for distribution by Apple, will be a complete rewrite, using Swift, and probably targeted for iOS8, or, realistically, maybe even iOS9.

Emphasis on "if and when"...

Thank you for your patience!