Thursday, January 8, 2009

IPhone Programming, where to start?

During my Christmas vacation, I decided that I will learn Iphone programming.  As soon as I finished ordering my Mac, I was on the Internet to try and find literature about this new development platform.  Sometime it's good when there aren't that many choices of books on a subject, and in the case of Iphone programming, there really isn't that many books available. As long as their some good choices (anyone ever seen a good Direct X book?  I haven't) then having little choices makes shopping much easier and faster.    It really doesn't take me long to see if I'm going to like a book, you can learn a lot from the content pages, the intro and the index, readily available on Amazon.  Most people agreed, "Beginning IPhone Development" was one of the better books to start learning IPhone programming.  

But wait a minute, I need to learn Objective-C also? And Cocoa?  This is slightly more complicate than I first thought.  I certainly don't back down from a challenge so I ordered another book for Cocoa, "Cocoa programming for Mac OS X".  It was rather well reviewed and seems like the goto book for this framework.  Objective-C was a bit more complicated because the book of choice "Programing in Objective-C" by Stephen Kochan is between edition right now.  I would love to get the book as fast as possible, but there was going to be a new release in only 2 weeks!  Surely I could do without having a book on the subject till then.  So I decided to pre-order the "version 2.0" and wait on this book a little while longer.  I received an email today that I should be expecting it by mid to end of February. 

So far, I've read through the Beginning IPhone Development and I've really enjoyed it.  The syntax (Objective-C) is really really getting on my nerve, but more on that later.  I haven't had the need to read the Cocoa book, and I quickly noticed that the IPhone framework although similar is not the same as the Mac OS X programming.  By browsing quickly, I can see that there are things that would be useful for me, but these are normally already well covered by the Beginning IPhone Development book.  If your interest is with IPhone programming, I probably wouldn't get the Cocoa book if you are on a budget.

Objective-C
The IPhone programming book does NOT teach you anything about Objective-C, but it's a good thing.  I hate swiss army knife type books.  If I knew Objective-C well, having a book on IPhone development explain it to me would slow me down with learning what I actually want to learn: IPhone programming.  It would also just do a mediocre job at covering Objective-C compared to a purely Objective-C book.  So many books go down this road and it always annoys me (Appendix are alright).  Kudos on not making this mistake.  Unfortunately I do not know Objective-C, but thankfully the book points you to an online resource that does a great job at covering the basic of the language.  You'll need to register with the IPhone Dev Center, there you will find many resources here that will be absolutely necessary for learning IPhone development quickly. 

I'm normally really quick at picking up new language, the last language I had to learn was C#.  I started and finished "Programming in C#" by Jesse Liberty  on a transatlantic flight over to Europe.  Alright, so it was the first edition and it was slimmer than the current version but nonetheless I was very impressed at how intuitive the language and the environment was.  C# is now the first language I turn to as soon as I have to do any tools.  I also looked at using it for games, unfortunately the support for XNA isn't great for the casual market.  The Visual Studio IDE with C# is top notch when developing user interface, I've never seen a better application for doing GUI development.

Objective-C is no C#!!!  The language feels quite archaic and the Cocoa framework is nowhere as clear as .Net when it comes to naming convention.   I was very surprised by XCode though, I actually find it very good for the most part.  Code Sense is a bit inferior to Intellisense but I was just happy to have something that works!  As I previously mentioned in an earlier post, I love to be able to switch between header and cpp file with a hotkey.  Maybe this is now available in 2008, which I haven't switch to yet, but 2005 only allows the Go to header and in 2003 you don't even have that luxury.  Instead I believe I use King Tools to be able to have this functionality. 

As much as I really like XCode, Interface Builder is a major FAIL in my book.  It reminds me of the old MFC, if I can ding Beginning IPhone programming in only one way is that the authors alludes that this approach is better than generated code. My first annoyance with it is that it's not really integrated in XCode, which makes my environment a mess.  After clicking on a few nib files, I'm forever trying to find the interface that I need to work with.  Thank god for Expose!!  If I could change one thing, this would be it.  Find a way to integrate it into XCode, I want it to go away when I close my project and open another project.  In one instance I had made a copy of a project that I had so I could make some non-destructive changes.  To make sure I didn't mistake one project for another, I closed down XCode but forgot to closed down Interface Builder because it was residing in another space.  Next thing I know I'm modifying the right project, but the wrong interface....grrr.  I'm not sure how often someone would need the Interface Builder up without having the XCode running.  Maybe this is useful for some people and that they now have it part of their workflow.  I just don't see it working for me right now.  Another thing that really annoys me with Interface Builder is that when it comes to programming, I hate magic.  I want to understand how things happen and in C# I know exactly what is happening because I see the code.  I know that I can enter the same code manually and get the same result.  In Interface Builder, I believe the nib is serialized data that does these connections for you.  Because of this, my learning is much slower.  How I register callback functions for my actions?  How do I create a new GUI element programatically.  I can do a bit of digging and figure these out, but because it's not in my face all the time it takes much longer. I'm also always more comfortable looking at code to see if everything is setup right.  Now I have to check my code, then change application and check if everything in Interface Builder also is correct.  I'll get use to it, but I'll never like it like I like C#.  Maybe the comparison to MFC is a bit harsh though :)

As you might have realized from my previous paragraph, I do not currently have any version control system.  I have perforce on my windows machine and I really like it.  I might have to check to see if I can't setup some kind of CVS system on my Synology backup system.  This would be the best approach for me since I could share code base easily between all my OS.  I installed GIT quickly but really haven't played with it.  If anyone has suggestion please fire away.  I need to set something up sooner rather than later.  Time Machine is alright, but it won't replace a good configuration management system. 

Well, back to the grind...

Wednesday, December 31, 2008

More on The Great Transition

My old setup was a duo core PC with a core duo 2.6 gig and a dual 22" monitor setup.  I've grown very accustom to having a dual monitor setup and wouldn't really know how to work without it.  That's on Windows.  My Mac setup is a Macbook Pro 2.8 with a 320 HD hooked up to the Apple Cinema Display 24".  Yes, I've read many many posts about people saying that the ACD LED 24" is way over priced and that for the price of that monitor you could buy 2 24" monitor or at least a 24 in monitor, a mic, a camera and a spare power adapter.  Well, it's still sitting on my desk right now so get over it.  When I jumped to Mac, I really wanted to try the whole apple experience and having the screen in front of me right now, I don't regret it...it is BEAUTIFUL (we'll see how beautiful when I get my visa statement next month!).  Seriously, I'm an amateur photographer and when I put my pictures on this screen they just pop.  I've never seen anything like it.  I do find that it's over priced by about 100$ and I would have loved to pay a bit less than that.

In the first few days of working on the Macbook pro, I was using my laptop open + the ACD. I've since tried it with the laptop closed and just the 24 inch now and I like this much better. One of the reason I didn't like it with 2 monitor is that I couldn't make my ACD screen my primary monitor with the tool bar on it.  The toolbar would always default to the laptop monitor.  It was a real pain because I constantly had to drag my mouse to the other screen to go click on the menu because I had so many short cuts to learn.

Spaces and Expose
These are the greatest OS related tools I ever had to work with!  With this I can often work better on 1 screen than 2 screens on windows.  There are some occasion where I absolutely need 2 screens.  When creating games in fullscreen for example, I normally use one screen for my IDE where I can debug my game running on the other screen.  Most of the time though, I use multiple screen to divide and conquer.  I can run to instance of visual studio side by side on screen while having a few Firefox windows opened in the other.  Now I can run 1 to 2 instance of Xcode in 1 spaces, then use another spaces for Safari and yet another space for Interface Builder.   Would I like working with 2 screens on the Mac?  I probably would, but I don't like working on 2 screens when one is a 24" at eye level and the other is a miniature screen beside it.  Because the screens aren't really balance I'm sitting square toward my 24", while normally, on my Windows setup, I'd be sitting square between the 2 screens.  You can't really do that with a 15.4" macbook pro screen and a 24".  When it comes time to upgrade my PC, who knows maybe I'll get a Mac Pro at which point I'll either buy 2 new screens, reuse my old ones or get a 30" ACD (or other 30" screens that would be good at the time).

Rest of My Stuff
When I moved to the Mac I already had an Ipod loaded with a few apps, a few of albums and some videos.  I tried synching it and I couldn't find a way to synch it without losing everything I had downloaded.  I wasn't too thrilled about this.  I did it a bit hastily and I forgot the name of some of the programs I had previously downloaded and I since lots track of them.  From now on this shouldn't be a problem since I don't really need to synch my touch to the PC.  The Ipod touch was mainly bought for programming, otherwise the old IPod classing or the blackberry bold can do the trick just as well.

I had no problem installing my Wacom tablet, I just needed to download a driver and it was a painless installation.  My Synology CS 407 is a different matter :(.  There doesn't seem to be any easy way of me to use it as my backup system.  In the end, I'm using an old 500GB USB drive I had, although I would have preferred a centralized backup it will have to do for now.

Bootcamp
I was a bit disappointed with Bootcamp, actually, I was downright mad at first.  I tried installing Windows XP professional using Bootcamp.  Unfortunately I THINK that it didn't have the Service Pack 2 pre installed on it.  This was a rather old version that came with MSDN Subscription.  So when I installed the disk in and the machine rebooted to install XP, it went to the DVD menu but then it stuck there.  I couldn't pick any of the choice on the screen and I couldn't get the DVD out.  I finally found a way to get the DVD out by just pressing the mouse button, I thought this would be the end of my troubles.  Instead whenever I rebooted it would show the white screen but no logo and it would just sit there.  I finally found in the documentation how to clear the nvram at boot up and that did the trick.  Although I have to say I was sweating for a little while!  So for now I purchased VMWare Fusion and installed the very same XP version through VMWare with no problem.  I have to say, I have yet to use it.  Of course I have a very good Vista machine sitting right next to this one, so there's no real reason for me to launch the VMWare version other than pure curiosity.  Although I'm curious, practicality normally wins over.  When I'm on the road I'll probably bring my Macbook pro instead of an HP Tablet with Vista and I have no doubt that VMWare will become become a very good friend of mine when that time comes.

The Woes of the Great Switch

With my recent switch to Mac, I am reminded of how dependent on all of my shortcuts I can be.  I launch Pages write a few paragraph and I want to change to a new page and control-enter doesn't work.  I don't use word processor to often, so this isn't a huge concern, and I could always install Neo Office that would probably closely match Open Office for windows.  It took me a while to find the front delete key (fn +delete).  I'm fairly used to start deleting where I land and having to reposition myself was starting to annoy me a bit.  Fn + delete short cut will do just fine though.

My main problem right now is all the little short cut I use every 5 min that seems to be gone. Windows key + e for bringing up explorer, is now replaced by either using command + N or option + command + space if I wasn't clicking on the desktop first.  I haven't really found a way to check for processes running and their performance yet, except for using the terminal and running top.  I've used it a few time so far to close programs that hung(Mac program do hang after all!).  How about an easy way to lock your computer?  I was used to windows key + L, now the best way I've found was to move the mouse in the corner of my monitor to trigger the screen saver.  I hate using the mouse.  I already have my hands on my keyboard, so using the mouse for anything takes more time.  Plus if you move the mouse while it's in the corner and while its triggering the screen saver, it will cancel the screen saver.

It was worst within XCode, not because there's no short cuts, there's an abundance of short cuts and I have to confess that I'm already getting used to them, although I haven't found a way to comment out block of code automatically yet (Ctrl-k + Ctrl-c in visual studio).  Since XCode is what I use the most right now, I'm spending way too much time using the mouse which I normally rarely used during development.  After 3 days in the environment and being very deliberate about using short cuts (going through the menu with the mouse and then canceling out and using the short cut instead), I am getting somewhat comfortable about using them...maybe too comfortable.  I really like the Option+Command+ up array for switching between .h and .m file.  In Visual Studio 2003, I'm using a plug in for this and in 2005 they incorporated a "Go to header" functionality.

All in all, I am on my way to a full transition.  It's not going as fast as I'd like, but I have to be somewhat realistic about how quickly muscle memory will accept new key combination.  After all, I never think about pressing the key combination, it's really just a reflex.  With time, it will come though, now I'm interested in seeing if I can switch easily between Mac mode and Windows mode.  I can't forget my Windows background either since I still need to use it for work!


Windows Programmer Switches To Mac

I've been a Windows user for many years.  My very first computer was an Apple II, but after it came Dos and since then only Windows.  I've skipped a few version here and there, I stayed away from Millenium for example.   Windows 98 Plus?  C'mon.  All in all, I've had very few complaints about Windows although I had the occasional crash.  I'd also reboot my PC weekly,  but nothing that would really really bug me to the point that switching to Mac seemed like the only alternative.  My worst experienced would probably working with the Windows GINA a few years back.  Wow did I ever screw up my machine often.  VMWare would have been a god send back then!

Why now thinking about switching to Mac?  IPhone/IPod touch development is why!  Although I wish I could do development on a PC (it would be much cheaper as I have enough of those :) ), the Intel Mac is currently the only platform that supports development for this interesting new mobile platform.

I've decided that I will be buying a Mac and learn as much as I could over the Christmas Holidays.  I don't have 2 weeks off in a row often, so I'm hoping I can take full advantage of this to learn my way around a new OS, a new IDE and a new language (Objective-C, Cocoa).  I've actually created this blog more or less to document my plunge into the Mac world since I think this is probably the biggest changed I've done in my profession to date (time will tell).