Getting the datatype of an object


Posted by Jaime | Posted in Coding | Posted on 08-11-2007

In Java and C#, it’s really easy getting the datatype of an object that you are working with. If you don’t know what I am talking about, post a comment and I’ll explain it in more detail.Well anyway, surprisingly, I never had the need, until now, to do the same thing in C++. In other languages, you have the “typeof” keyword that allows you to get the datatype of an object.

This keyword exists on the Mac, but doesn’t do the same thing. To get the same type of functionality, you can use the “typeid” class to get the datatype and name of the object you are working on:

void GetMyType()


int i = 0;

cout << typeid(i).name();



Tell me how you really feel about GDB…


Posted by Jaime | Posted in Coding, Funny | Posted on 01-11-2007

I have some complaints about working with Xcode and GDB, but this guy had a mouthful to say: Click here. 

You know, most of us developers work on timelines that are already too short and the people mandating the schedules live in their own world, but this is something we all live with and having a debugger that takes time away from us is counterproductive.Apple has done a great job with their operating system, there is no denying that, but there is still some work that has to be done with their debugging tools. I’ve come from using Visual Studio, which is very reliable… I know, I know, the word reliable is usually not associated with Microsoft… ** cough cough ** red-ring-of-death!! ** cough cough ** blue-screen-of-terror!!! ** cough cough ** 

Uh-um… excuse me. Anyway, Microsoft has done a good job with their debugging tools and so shame on you Apple for letting your competitor shine where you should have. 

Learning OpenGL the Big Nerd Ranch way


Posted by Jaime | Posted in What's New | Posted on 27-10-2007

Big Nerd Ranch HatI learn by reading and I read a lot of books. From the beginning of my programming career I have been a self taught programmer who has had the luck to work with some talented developers and has had the chance to work on some strange projects.

Since college I have been turned off by the structure of many courses. I understand how academia tries to get your to think like a scholar, by not teaching you the course, but instead, ramble on about something loosely related to the class and force you, the student, to teach yourself by performing endless research and review. Why then do I need a teacher to learn C++, Objective-C or Java if in the end, I am the one doing the reading… the studying… the research… and the teaching? I don’t need to pay someone to do that!

Well, let’s take a look at an alternative approach of learning at the Big Nerd Ranch. Situated in Georgia, this company understands that professionals need to learn a particular technology quickly and with applications to real world scenarios. I got to experience their Boot Camp style of teaching in a course that teaches OpenGL in just 5 days.

When you think about it, it seems pretty tough that you can learn anything as complex as OpenGL in five days, but their setup is such that you’re primed for learning. The Inn that you stay at is far from noise and distractions, good food is provided for you, breakfast, lunch and dinner, and their prescription for power learning also includes a good nights rest; in their own words, “[…] caffeine is not a substitute for sleep”, and sleep is what you need if you want to learn everything that is taught there.

Rocco Bowling was our teacher for this course and you couldn’t have asked for a better one. His resume includes OpenGL games created for Freeverse, makers of Big Bang Board Games, and has won multiple awards for games submitted to uDevGames and the Independent Games Festival. His style of teaching focuses on highlighting topics that easily frustrate students who are learning OpenGL and has plenty of code examples to show you how something may be done in OpenGL.

Although the class has a syllabus defined, Rocco wasn’t deterred in answering any question thrown his way. As a matter of fact, he found a way to incorporate any new question into the current topic and is quick to offer one-on-one help.

In the end I learned a lot more then I expected to and saved myself a ton of time that might have been spent in frustration, learning the ins and outs of this complex graphics language. And for any questions that I might have afterwards, students completing the course also get access to a mailing list so that post-course questions can be answered. I would definitely recommend this course to anyone programmer who needs to learn OpenGL quickly. Considering the price also includes the OpenGL’s Programmer’s Guide, Fifth Edition, accommodations, food, computer if needed, and transportation, this is a good deal and a great method for learning.

Rotating Cube

Using Subversion on Mac OS X, Part I


Posted by Jaime | Posted in Coding | Posted on 27-09-2007

The long and short of it
This article covers how to quickly install Subversion on a standalone Mac OS X workstation. If you are a developer who has used a source control program like CVS, and really don’t care about all of the different ways of setting up SVN, other than for personal development purposes, then this article is for you.

Some people want to get stared quickly and others enjoy the narrative. I have included both the long and short. The long narrative starts right after this paragraph. The short of it starts at the section titled, “How do I get started?”

The journey begins

Every wondered how to quickly set up Subversion, aka SVN, on your home workstation? I did, and it took me some time to figure out how to do it right. I’ve actually used Subversion at work and was able to set up the environment the way that most documents illustrate. When it came time to set it up on my home computer, I encountered a whole new experience that wasn’t pretty.

So, to save you some grief, I put together this article so that you can learn from my experience and maybe learn some things on the way. As with any endeavour, you should be careful of what you do on your computer. If you decide to install the software listed in this article, back up your computer first! This is common sense, but not too many people practice this until after the fact. So with that said, back-up your computer and come back when you are ready.

Save Your Butt
I’ve used CVS and SourceSafe in the past. Both programs use the same concept of source control where you have a central repository that stores a copies of your files in your project. You check out a file or whole projects onto your computer, do your work and the check those files back into the repository. The source control server then checks your files against what is in the repository, and depending on the options your have set up for your environment, asks your for additional bits of information, such as a log for the file commitment.

I’ve heard about Subversion from a fellow developer and I was intrigued. When this guy mentions a program, it’s usually good. After some poking around, I found that Subversion has a lot of nice features and some weird ones. SVN offers a really nice way of handling directories and tracing the history of those folders. Since I worked a lot with directories, SVN seemed like a good tool.

The Good, The Bad and The Ugly
I had the fortunate opportunity of installing Subversion at my office alongside CVS. The process wasn’t too painful: the documentation called for Apache to be installed along with WebDav components and this worked well on my server. The client computers used SmartSVN as a GUI client and importing projects into the server wasn’t too hard. SVN seemed quicker than CVS and worked very well over SSH connections.

I also had the unfortunate opportunity of setting up SVN on my home computer. All of the documentation available stated that you need to use Apache to have the clients work with the SVN server. So, there I was trying to figure out how this would actually work on a standalone computer. I couldn’t find anything that showed a single workstation set up and I even tried installing Apache with WebDav on my home computer. This just didn’t make sense! There are a lot of developers that work on their on computer and use that same computer for versioning their work. CVS of course made it very easy, and SVN seemed like the opposite.

So what happened? I did a lot of reading, that’s what happened. I haven’t done this much reading since I first learned C. To me, a source control program doesn’t seem like something that should require so much research, but times have changed and so have the tools.

How do I get started?
So enough talking and let’s get down to business. Here are the steps that you need to take to install a standalone version of SVN on your own computer along with a client that allows you to check out/in your project files.
Step 1: Download the software
This goes without saying. But what do you need? You need the following tools:

1. Subversion, aka SVN, can be found at
2. [Optional] A good graphical tool like SmartSVN

Step 2: Install the software
Mac OS X
These instructions came from the Apple Developer Connection site,, but here is my shortened version:

1. Download the source files from:
2. Open the Terminal application, found in /Applications/Utilities/.
Extract the zip archive:

$ cd ~/Desktop
$ tar xvfz subversion-1.4.5.tar.gz
$ cd subversion-1.4.5

Compile the source code:

$ ./configure –prefix=/usr/local \
–mandir=/usr/local/share/man –with-ssl \
–with-apxs=/usr/local/apache2/bin/apxs –with-zlib \
–enable-swig-bindings=no –without-berkeley-db \
–with-apr=/usr/local/apache2 \

Run the make command, and then run the sudo make install command:

$ make
$ sudo make install

Add the ‘/usr/local/bin’ path to your profile:

$ cd ~
$ echo ‘export PATH=”$PATH:/usr/local/bin”‘ >> .profile

If you don’t want to go through that trouble, you can run the following shell script on your computer:

Step 3: Create a repository
This can be the confusing part. In a version control system like CVS, you have a single repository where all of your files and their versions are kept. In Subversion, you can have one repository for all of your projects, or you can create a repository for each project or a combination of both. I took the way that I am most familiar with and created a single repository for all of my projects. To create a repository, you type the following command in the Terminal App:

$ svnadmin create /path/to/your/repository

The repository can be anywhere you like. If you want to place a folder named ‘SVN’ in a Development folder in your Documents folder, you would type in Terminal:

$ cd ~/Documents/Development

$ svnadmin create SVN

The last command creates the SVN folder and all of the items in it to support the Subversion repository. You can name the folder anything you want; you don’t have to use SVN as the name of the folder.

Now that you have a repository, it’s time to create some folders for each project…

Step 4: Create folders for each project and import
So, to create a folder for your project, type in this command in Terminal:

$ svn mkdir -m “Creating project folders” file:///Users/yourname/Documents/Development/SVN/MyProject

You can repeat this command for however many folders you need to create. To create multiple folders at one, you can separate each path with a backslash:

$ svn mkdir -m “Creating project folders” \

file:///Users/yourname/Documents/Development/SVN/MySmallProject \


To import your work into any of the folders you created, you can import your code using the following command:

svn import /path/toyour/projectfolder/MySmallProject file:///Users/yourname/Documents/Development/SVN/MySmallProject \
–message ‘First time project import into Subversion’

Just like any version control software, you have to check out the project before you start to work with it:

cd /Users/yourname/Documents/Development/CPP/
svn checkout file:///Users/yourname/Documents/Development/SVN MySmallProject

Notice that I first changed directories to a CPP folder. When you checkout the project for the first time, Subversion is going to copy all of the files from the repository into a new folder named MySmallProject in the CPP folder. That is a one time thing: every time you check out the project afterwards, Subversion will check the version of the file that is in that directory and do an update where necessary.

Maybe by now, you are saying to yourself that this is too much work. Well, that is were graphical tools come in handy..

Step 5: Explore Subversion with SmartSVN
SmartSVN is a great tool for working with your repository. It gives you a graphical view of your file history and allows you to see what files have changed. In the next installment, I will show you some basic commands using SmartSVN and how to use Subversion with Xcode.

Till then, happy coding!

Sometimes you can be your own worst enemy


Posted by Jaime | Posted in What's New | Posted on 16-09-2007

I’ve been working a lot on different articles. One day, one topic may seem like a good idea, and another day, I run in a different direction. It’s hard work! You think you have a good idea then the voices pop up in your head: “Who would read this?”, “Who am I writing this for?”, “What will the reader gain from this?” and/or “Who cares?”

It’s amazing the amount of time that can be spent on an article. As I said in the past, I want to help developers… not bore them. So with that said, I will continue typing until I am satisfied with what I got and present you a with a blah, blah, blah, blah… You get the point…

In the interim, check out this cool program:

Sporting a new look


Posted by Jaime | Posted in What's New | Posted on 29-08-2007

Aha! As you may have noticed, this website is sporting a new look! When I first started out, I was using Aptana, a great IDE that I have been using for JavaScript/Web development that has professional features and is free.

Aptana IDE Dashboard

You’ll especially love this tool if you are a JavaScript developer: it has Code Complete, which shows a drop down list of functions or classes, depending on the context of the code, a JavaScript Debugger which actually works, code snippets and much much more.

Now I am not trying to sell you on this development tool, just convey to you how much I loved it. However, being the lazy developer that I am, pressed for time, I took the lazy way out. Instead of coding a PHP site with a PostgreSQL backend, I coded my articles by hand. I first used Scrivener to work on my articles and then exported them to Aptana, where I would clean up the code to match my website.

Although easy, it got old pretty quickly! There are a lot of tools out there that could make my life easier and this one was recommended to me by a devout Mac fanatic. After some typing and experimenting, I decided to use this tool as the article manager of choice.

So, if anything, I would recommend this tool if you are looking for a good blog engine. However, if you happen to be looking for a better JavaScript editor with debugging tools, then you definitely have to check out Aptana!

Using Cocoa to resolve Unix file paths with tildes


Posted by Jaime | Posted in Coding | Posted on 30-07-2007

Quick! How do you expand a file path that has a tilde in a program? Luckily, you can use NSString to resolve the path for you. So, if you path looks like “~/Library”, you can use the stringByExpandingTildeInPath method to resolve the tilde to the full path: “/Users/johndoe/Library/”. Here is s snippet of code to show that:

NSString *myString = [[NSString alloc] initWithString:[@”~/Library” stringByExpandingTildeInPath]];

Of course don’t forget that you need to allocate memory for the string and initialize it! Now, if you need to use this function within a C++ App, don’t fret. You can add the above listed code to a C++ file and so long as you set the file to compile as a sourcecode.cpp.objc file,in the File Type drop down list in the “Info” dialog box, you should be good to go.

Click here for the Objective-C project

Creating writting made easier…


Posted by Jaime | Posted in What's New | Posted on 19-07-2007

So what is new? Something old actually. English is what I am referring to and I have found a new way to think about the written word!

My wife picked up some stuff at the local pharmacy and with that stuff there was a copy of ‘Mac Life’, a magazine dedicated to all things Macintosh for the people who use Macintosh at home. It was cool that my wife was thinking of me, and it was even cooler when I found out about a program called Scrivener.

This program is for helping people write. It is not like Microsoft Word. It is not a Word processor. Instead, it is a thought organizer, helping your piece together the normally disconnected pieces of research, sticky pads, etchings, website bookmarks, etc, etc, etc… You get the idea. Now… How useful is this product? Very! I have been using it to write my articles and it even has the capability of exporting my articles to HTML or even Microsoft Word!

I suggest that anyone who needs a tool that will help them organize their thoughts into the written word should look at this tool. At 35 dollars you really can’t go wrong!

Objective-C and C++: Friends or Foes?


Posted by Jaime | Posted in Coding | Posted on 16-07-2007

For many developers like myself, I learned a language as a means to create a program on a specific platform. Back in the early 90’s, I learned Pascal because that was the language that PC and Macintosh’s used. Later in the 90’s, I learned C++ because this was the buzzword language that BeOS, the powerful multimedia rich operating system, used. I learned other languages throughout my career, like Java and C#, but none has stood out more than Objective-C.Objective-C was used by NeXT and later by Apple when NeXT was acquired by them in 1996. Apple needed a next generation operating system badly and they needed one that was easier to develop for than Mac OS 7. Truthfully, programming on the Mac early in my career was a painful experience, littered with bugs, crashes and painful debugging sessions. Pascal as a programming language was not fun for me. C++ in MetroWerks looked really cool, but a program made with the PowerPlant library still had problems because of the nature of Mac OS 7.

When Windows 95 came out, Microsoft introduced an easier way to create programs for a platform. I got sucked into MFC, which was built in C++, and I created programs as soon as I learned how to subclass CWindow.

So how does this bring me here, to Objective-C and Mac OS X? Well, when Steve Jobs came back to Apple in 1996, he brought into the company one of the greatest accomplishments he and his team at NeXT created: an Objective-C based framework named OpenStep. Although Microsoft had MFC, which seemed so much better than programming with the Win32 API, OpenStep, later renamed Cocoa, was a radical departure from conventional object oriented programming.

MFC, which stands for Microsoft Foundation Classes, was built in C++ and allowed developers to create programs using reusable modular code and event messaging. A dialog class would respond to messages sent to it via a series of macros created by the compiler. Those who are familiar with programming with MFC and Visual Studio know about the event map macros. Objective-C and Cocoa were different in that you didn’t have to create a subclass in order to gain functionality in a particular module, or that you didn’t have to worry about sending a message to an object method that doesn’t exist. You see, for those who didn’t catch that last statement, that is probably one of the biggest distinctions between Objective-C and C++. In Objective-C, you are actually sending a message to an object. Even if the method doesn’t exist in the object, that’s ok in Objective-C. In MFC, built around C++, you are actually calling a function. In order to call that function, you must first declare it somewhere in your code. Messages aren’t really sent to objects in C++, but many frameworks create message-like mechanisms by storing an array of functions that would respond to a particular message posted to an event class. This is what MFC does when Visual Studio embeds your code with macros that insert extra event functionality.

So, I am assuming that if you have read the article to this point that you are most likely a C or C++ developer who is looking into Objective-C and trying to understand it more. If you were like me, you probably bought the Objective-C book published by Apple or downloaded the PDF( available from the Apple Developer Connection and either forced yourself to learn the language and accept it or gave up on trying to understand it altogether. If that is the case, I don’t blame you for feeling a little lost. Honestly, I felt that same way too. I learned the language and I compared it to every other language that I have learned, wondering why Apple choose such a strange language. When Cocoa became available in Java, I headed down that path since it is more like C++ and much more familiar to me than Objective-C. However, I quickly learned that programming with Java and Cocoa was not optimal for me or for my projects.

The first problem was that I really didn’t understand Objective-C. The second problem was that I constantly compared it to C++, thinking it was weird. The solution to both of these problems was understanding how Objective-C worked and not comparing it to C++. The first and most important attribute to learn about Objective-C is that programs built in this language can have dynamically loaded code. You might think, “big deal! I can do that with a DLL!”, but what you don’t realize is the mechanism that sits behind DLL usage: in order to use a DLL, you have to reference the DLL in your project and link you application to it via the compiler. When you compile your application, the compiler links the code into the binary executable, effectively copying the code into the application. Even if you are using a dynamically linking the library, there is only a reference to the DLL on the file system, however, if the DLL is different or missing, your application will not launch. In Objective-C, you don’t have to link to a library at compile time: you can wait until your program is running to load the library and call the functionality that is inside of it. If the library is different or missing, your program will still launch and execute.

This is hard for a lot of developers to understand, but this is similar to the COM interface in Windows. You can call invoke code within another file using an Interface class to understand the contents of that code. Objective-C is built around the Interface concept, which is evident when you declare a class in Objective-C: class declaration has 2 parts: the interface portion (in the header file) and the actual code declaration part(in the implementation file). In C++, you would declare a class as follows:

class MyClass



int _someVariable;


int _someOtherVariable;


MyClass(); // constructor

~MyClass(); // destructor

int CheckCPU();

int CheckHardDisk();


The CheckCPU function would be coded in a separate .cpp file as follows:

int MyClass::CheckCPU()


// do some work

return 0; // return an int


Objective-C is a little different: 2 keywords are used in the declaration of a class and the implementation of the methods: @interface and @implementation. To declare the above listed class in Objective-C, you would type the following:


@interface MyClass : NSObject {


// declare my class variables


int _someVariable;


int _someOtherVariable;



// declare my class methods






To implement the CheckCPU function, you would type the following:

#import “MyClass.h”


@implementation MyClass




// do some work

return 0; // return an int




Notice the usage of @interface in the .h file and @implementation in the .m file. Each one of the keywords is terminated by the @end keyword. It’s different, but very powerful!

At first glance, what might also seem odd is how methods are built. When you look at them, they look like typecasted C variables:


The minus(-) sign in front of the method indicates that the method is an instance method. Obj-C uses a plus sign (+) to indicate that a method is a class method. An instance method is one where you have to create a new instance of a class in order to use the method. A class method is like a static function in C++ where you don’t have to create an instance of a class in order to use the method.

Objective-C is a simple language that can be learned in a day. However, if you are a seasoned C++ developer, you might find it hard to absorb Objective-C and accept it. I have worked with Objective-C and Cocoa for quite some time now and there is a lot of good reasons to use this combo in your next Mac OS X project.

Now, I’m not saying that Objective-C is the end-all language, but it is certainly very impressive. Although there are a lot of features that C++ has that Objective-C doesn’t have, Apple certainly has made up for some of those lacking features in the frameworks they have built. For those of you like me, where you have written a ton of code in C++, there is good news. Most of that code can be reused in your Mac OS X project since applications built in Cocoa/Objective-C can call C++ code as well. Although Objective-C classes cannot inherit from a C++ class, it is good to know that you do not have to scrap your code for this awesome programming language.

Take a look at the resources listed below and the articles listed on There are sample projects listed on the website showing you how to use C/C++ with a Cocoa project and likewise, articles to further educate you on Objective-C and other topics related to the language. Once you start effectively working with the language, you will understand why it has become such a popular language in the developer community. Happy coding!

Additional Resources:

XBox 360 and the Red Ring of Death


Posted by Jaime | Posted in What's New | Posted on 09-07-2007

What a day! For the first time in a long time I had some time to kill, so what better way to do that then to play Gears Of War! I fired up my Xbox 360 and instead of giving me it’s usual chime and startup movie, I get three flashing red lights 🙁 I pick up my phone, dial dialed away and after spending 45 minutes on the phone with Microsoft, I end up having to send the console back to them, where it “may take 2 to 6 weeks” for Microsoft to send the unit back to me.

This all comes a couple of days after Microsoft made an announcement that anyone who has suffered from the red lights of death may have their warranty extended for up to 3 years. There’s more to Microsoft’s generosity then just the warranty extension, but you can just as easily look it up.

So, with more time on my hands, I turn my faithful PowerBook G4 on and type type type away in TextEdit!

This month is Mac OS X programming month and I aim to write articles specific to Objective-C/C++ programming for Carbon and Cocoa. The articles that I am going to post will focus on any Image processing related topics.

As always, if you are looking for a specific example or have comments, feel free to contact me by clicking on the More Info link on the bottom of this page!