How I discovered Xcode does more than Cocoa (and saved my life in the process)

Many programmers from both Windows and Unix camps have the assumption that Xcode, the programming tool that Apple provides free with every Mac, is only good for developing Cocoa applications. Well, that’s not exactly true. Here’s a story of how a PowerBook and Xcode helped one Computer Science student to increase productivity and performance in uni.

Two years ago, when I was still in University, my classmates and I were given a really sadistic series of practical work to do. We were undergraduates in the Bachelor of Computer Science programme in Monash University, and we were attending classes for a unit called “Operating Systems”.

Now, don’t get me wrong - we don’t learn how to operate or use Operating Systems nor the differences between Operating Systems - we go beyond the higher level and reach down into the low levels of the Operating System like the kernel, scheduling, processes, synchronization… sounds alien? Don’t worry, some bits and part of them still sounds alien to 90% of us despite passing the subject :) We’re not Finnish hackers after all! 1

So when we were asked to write an equivalent of a bash shell (yes, you see the command prompt when you open the Terminal.app? That’s a bash shell. Basically, we had to write an almost complete copy of the bash shell including most of the major features that the real bash has. And we were given (on paper) 6 weeks to complete it.

Halfway through the 6 weeks, horrors of horrors - my PC notebook crashed! I was not using a Mac then, but I had been eyeing one for a very long time. I tried to salvage my PC - it was still alive, but just barely so. Not wanting to take chances, I made a phone call home and told my mom about it. She agreed that I should get a new notebook pronto - and I gingerly brought up the issue of getting a 12" PowerBook. The phone conversation went something like this:

Me: Mom, I can’t waste any more time reinstalling all the compilers one by one if I get a Windows notebook…
Mom: I thought you use.. what’s it called? Linux?
Me: Yes, but I’ll have to waste time installing Linux and getting it to work properly
Mom: What do you propose then?
Me: Umm… how about a Powerbook? It’s UNIX based, so I can just continue doing my work… it also comes built in with all the programming tools and compilers I need….
Mom: How much does it cost?
Me: RM6,699
Mom: I can’t afford that!
Me: I’ll pay for half!
Mom: … (after long deliberation) Okay

Okay, so it was easy for me to convince my mom. Your mileage may vary. My mom is an academic so she realizes the importance of having the right tool for the job, even if it costs more than others. A little while later, she called me up to say she’ll pay for 90% of the PowerBook as a gift to me for doing well in University thus far, and I was delighted. I ran out to my favourite AppleCenter (which was what it was called back then) and placed an order immediately. The following week, my PowerBook arrived and I happily took my new baby home.

After setting up my PowerBook, I started browsing through the Install DVD to look for the gcc2 installer and found something called Xcode. Judging by the name alone, I could tell it was definitely a development tool. I installed Xcode, and started a new project. While browsing through the list of possible projects, I came across this…

Xcode - New Project window

I immediately started a new project, copied and pasted my source code in, hit the button Build and Go and voila! My shell appeared in a little container inside the Xcode IDE itself!

Xcode - Jinny’s shell

Click for a larger image

I was elated! Gone were the days of writing my code in a text editor called vim within the Terminal.app itself. Gone were the days of typing gcc prac3v6.c -o shell to compile my code and gone were the days of manually debugging my code using gdb. Xcode could handle all of those for me, the coding, compiling and debugging, in a easy, simple and graphical manner. I no longer had to continuously refer to gdb references on how to put a breakpoint in my code, I could just point and click it in Xcode. I didn’t have to slowly type my code out one by one in a text editor that’s older than myself3.

While my classmates continued to struggle through that practical, I was able to quickly complete mine and move on to the next practical - writing an app that demonstrates Interprocess Communication (IPC) passing. In human terms, this means, writing an app (process) that will “send a message” to another process which will then do something with the “message”. Again, having a Mac helped me a lot, as the IPC mechanism is already built into the OS, and the documentations are already built in too! Sure, Linux has the same thing, but the aesthetic value of OS X makes the task a heck lot more pleasant :)

By this time, most of my friends had just completed their first set of practical - the bash shell, while I had completed mine, as well as my IPC practical, and have proceeded to my last task - writing a FAT floppy disk formatter. Yes, FAT like the Windows FAT File System. Now, I don’t have a floppy disk formatter, and even if I do, I wouldn’t want to waste money screwing up floppy after floppy.

My solution? I created a disk image of a floppy drive and proceeded to write my FAT disk formatter :)

By the time I submitted my floppy disk formatter, most of my classmates had just only completed their shell, or their IPC. A female classmate who managed to complete her IPC wanted to try doing the floppy disk formatter asked me to teach her how to do so. In the end, only two people managed to complete the practicals for that class - I was first, my female friend was second. But imagine if it wasn’t because of OS X, would the two of us even be able to complete every single task? Possible, but it’ll mean sleepless nights, caffeine overdoses and high blood pressure :)

  1. The joke is on Finnish hackers due to anecdotes of the Scandinavian countries having a long dark winter and their people spend their days sitting in the basement hacking and coding the Linux Kernel, and because the founder of Linux, Linus Torvalds, is Finnish.
  2. GNU C Compiler
  3. The vi editor was developed by William Joy in UC Berkeley circa 1976. vi and it’s improved version, vim, despite their age, is still considered one of the most powerful text editors ever created, surpassing even most modern graphical text editors in terms of functionality and feature-ladenness.

This article was contributed by djspinnet a.k.a. Jinny Wong, blogger, Mac lover and proof that girls can hack Unix as good as the guys. Not content with her Bachelor of Computer Science, she is now pursuing her Postgraduate Diploma in Arts (Research), in the field of Sociology of Gender and Technology.

10 Comments

  1. I had a similar experienced with Xcode during my collage days (which is really not that long ago).

    I remember during an advance computer graphics (or something like that) we were required to do some openGL programming. Of course all the notes we got on how to set up your IDE for working with openGL is Windows oriented.

    Did some searching and I found out that there is actually nothing much to do. Just open up Xcode and you can start coding, since openGL is an integral part of OSX all the libraries (frameworks?) are already there.

    Then another similar experience was during my Java class. Again all the note on setting up Java and your IDE to code some Java apps are windows oriented.

    Did some searching and found out that, unlike Windows, OSX already support Java out of the box. And yeah, you could use Xcode to code some Java apps too!

    Macs are good companion for Computer Science student :)

  2. Not just that, there’s also perl, php, ruby, python, flex, bison, yacc etc out of the box :)

  3. Wonderful story. Great writeup. Very personal.

    You are so fortunate to be able to buy a PowerBook when it is running Mac OS X. Some of us, oldies, struggled a bit during an era prior to Mac OS X.

    Anyway, welcome to the family…

  4. Jim Schimpf

    XCode is a really powerful tool. I’ve always liked IDE’s and ProjectBuilder and now XCode is quite good. At work we are doing a Linux project and while others are on Windows boxes with XWindow clones running editors/gcc/gdb as separate pieces I can used the unified XCode IDE and work on the same code. Also Graphics Arts in the building has a G5 and they allow me to do distributed compiles on it. So my humble 12″ G4 can compile 5 or 6 files at a time really speeding up the process.

    Also if you really get into it this tool Pbtomake (http://members.bellatlantic.net/~vze35xda/software.html) can turn an XCode project into a standard UNIX make file. Very useful it you want to port your project to another system. –jim

  5. Blogjunkie = Jinny?

  6. @CS: Actually Jinny = djspinnet

  7. M

    Why do you specify that your friend is female? Seems an odd thing to higlight.. twice!

  8. Whoops, I must apologize for that. Must be the after-effects of writing too much on feminism in my thesis where I am sorta required to differentiate between male and female IT students/professionals :)

    Apologies again! :)

  9. XCode is a really powerful tool. I’ve always liked IDE’s and ProjectBuilder and now XCode is quite good. At work we are doing a Linux project and while others are on Windows boxes with XWindow clones running editors/gcc/gdb as separate pieces I can used the unified XCode IDE and work on the same code. Also Graphics Arts in the building has a G5 and they allow me to do distributed compiles on it. So my humble 12″ G4 can compile 5 or 6 files at a time really speeding up the process.

    Jim, nice to know that :) Your situation was similar to mine, most of my former classmates back in Uni were either using X forwardings to their Windows boxes or using Cygwin

  10. macrunch

    cool. I am learning from scratch. Thanx for the inspiration.

Leave a Reply

Cars, Bikes and Trucks
Advertise Here