Friday, December 30, 2011

Teaching yourself to write software

    I have been programming off and on again for around twenty years now. There is just something that I really find exciting about making a machine do exactly what I tell it to do. Of course that is often a problem as well. A computer cannot guess at your intentions or motives. Right or wrong, it will do exactly what it is told, nothing more. For the most part, my experience has been primarily in Microsoft Windows.

    To be more specific, for the last five or six years I was an avid user of Microsoft Visual Studio. You see, there are times when you just want to go to the source for your tools. I still use Microsoft Office on my MacBook Pro because there is no real viable alternative. In order to ensure document integrity and ensure that your document will work across all of the computers, both at work and at home, it really is a no brainer.

    The same is true when writing software. The best tool for writing software for any operating system will usually come from the people that make said operating system. Almost always anyway. Microsoft has Visual Studio with is great at what it does. Google has their own "plugin" for the Eclipse IDE for Android, and again, it is very good at what it does.

    Apple, has Xcode. While is still technically an IDE and very different from anything I have worked with in the past. First, it doesn't use a Multiple Document Interface (MDI) window. Instead it uses a myriad of other windows. Second, the User Interface (UI) and the actual code (Objective-C) are separate, but contain links to each other.

    This may sound trivial but is actually a very different way to do things. You see, in Visual Studio, if you want a button to do something, you select it, and write the "code" for that button. This works great for keeping you program in segments that can operate independently, yet in concert with your overall program you are trying to create. There is a way to manually create a link so that other buttons can use the same code snippet, but for the most part, each item of the UI does what you tell it to do. Its a very good way to keep your code clear and understandable, especially in very large projects.

    In contrast, Xcode for Apple, has one IDE for writing and compiling you code. In Visual Studio you have a choice of a few different languages to use (VB.Net, C#, C++, etc...). In Xcode, you get Objective-C, that's it. Really that is all you need, and for me at least, it also means that I must learn yet another language.

    Xcode also has a separate program, or IDE for creating the UI (User Interface). This is called, aptly, "Interface Builder". You write your code in one program, design the UI independently in another, then create links so the UI can interact with the code.

    This may sound a little off putting at first, until you really spend some time looking at the benefits. The first being collaboration. Someone else can work on code (or even pieces of it), while you work on the UI, or vise-versa. This can be done in Visual Studio as well, but requires addition software that you have to pay for and generally requires some advanced setup or else you will be emailing the entire project back and forth for each update. Of course, the main advantage of Xcode on the Mac, well at least for osX Lion anyway, is that it is free.

    Another big advantage of Xcode is that you use the same Objective-C and Interface Builder software for writing across all of apples hardware platforms. iPhone, iPad, iPod, and even osX Lion application, drivers, plugins and add-ons can all be made from one suite of software.

    This then presents a small dilemma. Which to learn first? Xcode or Objective-C? UI or Code? I have the Kindle version of two books that I will be using to learn all of this.

    The first is "Programming in Objective-C third edition" by Stephen G. Kochan. This is a very solid book that walks you through all of the in and outs of Objective-C without the distraction of the UI. This is, in my opinion, the place to start in order build a good solid foundation for writing software for apple products. No UI ever made can function without the code behind it. However code with no UI is not always very interesting to the average user.

    That's where the second book comes in. "Mastering Xcode 4 - Develop and Design" by Joshua Nozzi. This, again, is a very solid book for what it teaches. This books starts you off with interface builder and then adds the code behind it. It teaches you things like symbolic linking and how all of the various UI controls work and should be used. This book will probably get me started writing "user application" much faster than the other book, but I worry that I may miss something about Objective-C that may have otherwise learned about.

    I will be taking the next few days to look over both books and decide witch or both to use. In the mean time, check back often as I will be posting updates as they arise.