Wednesday, May 9, 2007

Hello

Hi everyone, let me explain what this whole thing is. Oh, and sorry about the name of the blog. It was 2 a.m. when I came up with it, for crying out loud. (Besides, note how I managed to smuggle in both "Xcode" and the "My Whatever" naming convention... It's actually growing on me.)

So. I've decided to learn developing desktop applications for Mac OS X using Cocoa, Objective-C, and Apple's development tools, notably Xcode and Interface Builder. Then it occurred to me that I should maybe blog about it as well.

I'm going to be tracking my own progress this way, reminding me where I am, and just simply taking notes of things I should remember later. As there's nothing secret or personal about the whole learning process, I thought, why not make it public? Perhaps some helpful people will offer some help. Perhaps some people will learn from my mistakes, who knows.

So, read on! You'll be in for a ride.

Tuesday, May 8, 2007

Some background: the first 18 years

I'm 32, and I've never had any formal training in computer science, apart from some elementary introductory course at college.

I'm professionally trained as a primary school teacher in mathematics and English, though I've yet to graduate. Most of my adult life, I've worked in publishing, mostly in desktop publishing (DTP), doing layout, design, production and project management.

I'm not a native speaker of English, so if my posts sound strange, that may be the main reason. (Either that, or the fact that I'm weird. You decide.)

So, why try to learn programming at such an advanced age? Do I stand a chance of getting anywhere? OK, while I was never formally trained, I've always been involved with computing. Here's my story. (Beware. It's long.)

I've always been fascinated by computers. As a child, I had a Sinclair ZX Spectrum, and I was amazed by its BASIC interpreter.

(Having a Commodore 64 was considered much cooler, incidentally, and I soon found myself on the losing side of a platform war. However, the BASIC interpreter of the Commodore was way inferior, lending me a sense of justified snobbery using the Sinclair. It also provided me with an early reason, back in 1986, to hate the company that had written the Commodore BASIC, long before that little software firm called Microsoft became somewhat more famous. Twenty-one years later, I'm cheering yet another underdog that also happens to be competing against computers running software from Microsoft. Some things never change.)

I took a stab at writing some very elementary games using Sinclair BASIC. One-character hero shoots one-character missiles at one-character villain that goes "beep-beep-beep." That kind of games. I had to borrow some machine code snippets from various sources for things like scrolling routines. Actually, one game called "cavern-ufo," which featured a flying saucer passing through an endless cave of stalactites and stalagmites, actually used pixel graphics, and one of my friends once actually played with it! He said it was cool.

I tried to make some of my games look like "professional" titles, with loaders, screens that the program would display while the rest of the game loads (loading a huge 40-kilobyte game could take 3 to 5 minutes from a cassette player back then). But I was a pre-teen, and it showed. Believe me when I say that the games were really no good.

I also designed some logos for my own fictitious software company, whose activity was limited to working furiously on its own corporate image, including company names, logos, and even corporate fonts! I was particularly fond of an animated logo that featured a galloping unicorn. I had to write a screen capture program (in LaserBASIC, one of the popular programming utilities for the Spectrum, beside the competing Beta BASIC) specifically for the purpose of capturing the various phases of the animation. I planned to use the capture utility for my "real" projects as well, which, however, never progressed through initial brainstorming phases. But at least I learned what was the difference between an interpreter and a compiler.

You can tell that, at such an early age, I was already fascinated with all the wrong aspects of software development: the corporate image, the software tools, and the marketing fluff. As far as actual production: sorry, folks. Nothing to announce.

That's when I had my first brush with DTP (no pun indented... I mean intended). I came across a bootlegged copy of a program called Art Studio. Upon loading, it displayed a menu bar across the top of the screen (something I'd never seen before and had no idea what it was), and a strange arrow in the middle. Then it froze. So I thought. But once I discovered, by accident, that the traditional keys for "Up, Down, Left, Right, Shoot," i.e. Q, A, O, P, and M, worked: they moved the arrow (a pointer!), and allowed you to select a menu, which would scroll down, and... You get it. Art Studio brought a bit of the Mac experience to the ZX Spectrum: a drawing program that would let you draw various shapes on the screen, including text, and even let you design bitmapped fonts (not that there were other kinds of fonts for the Spectrum). I used Art Studio to do most of my design "work." Shades of things to come! (Of course, it wasn't until another ten years or so that I first learned what a Mac was.)

I also tried to learn machine code and assembly, as all real game development happened there. But that thing just went over my head. I could never wrap my head around loading numbers into registers and accumulators. I needed the abstraction of a more human-readable (and writable) programming language. I think I still do.

High-school years were a bit of a stagnant period for my computing career. I learned English furiously, and realized that I suck at math. No, actually, I used to be the math whiz at primary school, and never spent one minute ever studying math, I just didn't need to. Then, as I tried to apply the same work ethic at high school, somehow I wasn't seeing the same results. I wasn't getting the (equivalent of) A grades, but rather some Cs and Ds. So I decided I wasn't a genius after all, and stopped caring. Only later did I realize that my classmates had one secret advantage over me, something I was shocked to discover, and started to apply it when it was too late: they actually did their homework every once in a while. It actually helps.

While at high-school, I learned how to use PCs (running then-state-of-the-art Windows 3.1), though my parents or I couldn't afford one. Then I got involved with one of the student newspapers some of my classmates produced, as a cartoonist, and later as a designer... This was at a time when PCs (at least the PCs we had access to) were still pretty damn slow and underpowered for DTP. Printing a simple headline might have taken us ten minutes. Read that sentence again. Man, do I feel old!

Back then, cutting and pasting meant scissors and glue. That's how we produced our newspaper, mostly using typewriters for the body text, while we looked at envy with some of our competitors who already started to use word processors. The bastards!

One important thing I realized, in contrast to my general suckiness in math, was that I had a strange affinity towards what I can only describe as "coding." Here's what I mean. While my classmates kept routinely kicking my ass at math (as they all wanted to go to business school and took the entrance exam pretty seriously), there was one math lesson which turned out to be a dialog between the teacher and me, with nobody else ever saying a word. That lesson focused on playful problems of encoding information.

What would you do if you had to transmit a large number to someone, using only digits, and the number nine broke off your keypad? One of my solutions (besides switching to a different numeral system): use double-digit numbers. 00 would stand for 0, 01 for 1, 02 for 2, and so on. The number 9 could be represented, by mutual agreement, by anything that doesn't start with a 0, like 11. This answer came very fast and easily to me, while the problem seemed totally alien to everyone else.

What if you have to transmit several numbers, and no separator character is working? Well, easy: use the double-digit numbers 00, 01, 02 and so on, with maybe 99 being used as the separator.

The toughest, final question was this: what if only one number, say, the 1, is working on your keypad? I was the only one to answer that as well: Write down the numbers you have to transmit, using the double-digit encoding and the 99 separator. That entire sequence of digits can be thought of as one single (very long) number. Let's call it x. Then, just transmit the number 1 x times*.

The teacher's solution would have involved a product of prime numbers raised to different powers. I haven't looked at it, but I have a feeling that mine would involve fewer clicks of the "1" button in most cases.

All in all, at that moment, I realized that while I may not be a math genius, at least parts of my brain are wired in a way that helps me come up with creative ways for encoding information. This skill might even have a name, I don't know. What I know is that it has certainly come in handy on a few occasions in my life. I'll tell about some later.

Stay tuned for more of my life story. Coming up: the college years, with some actual Pascal programming, and a lot of firsts: my first PC, my first DTP job, and maybe my first encounter with a Mac. I'll spare you the story of my first love, though. (I mean, loving a human being. It's quite different from a man's deep love for his development environment.)

*Of course, you'll be losing the initial zero this way. However, that will never cause a problem. Just think about it.