Archive

I survived an earthquake!

This morning at 4:17, I woke up, sweating profusely. Our room was so hot! So as I was laying there in bed, all of the sudden I heard a low but pretty darn audible rumbling sound. My bed started shaking back and forth, not violently, but very very very noticeable. It felt as if someone was climbing up the ladder to my bed. I quickly looked over to my ladder, but no one was there. Looking across the room to my roommates, they were sound asleep. As my bed began to stop shaking, I started wondering to myself what in the heck that was. An earthquake… NO way! I was convinced that either the shaking back and forth had been a dream, I was seriously mentally handicapped, or there was someone in our room. There was no one in our room, and I was not certainly not dreaming, and last time I checked, I was still somewhat normal (though my friends and family may disagree). I dismissed the event completely and went back to bed after opening the window.

This morning when I awoke to get up, my roommate Brett told me that “we missed an earthquake.” “I didn’t!”, I shouted back. So apparently I wasn’t imagining things and my sea-rocking-bed was for real. I survived and witnessed first-hand an earthquake, and in Illinois of all places. The last earthquake I witnessed was in California a few years ago. Hands down to the awesome power of God!

A tale of two developer sites

The other day, I wanted to look at how to write applications for Windows for a class I am in. Where is the logical place to look? The manufacturer’s developer website would be a good place to start. Upon arriving at Microsoft’s Developer Network homepage, suddenly everything got really confusing.

I have a theory about developer home pages, whether they be from Microsoft, Apple, ARM, or Intel: they should be extremely simple and geared mainly towards beginners who know nothing about the technology they want to write software for. I feel that Microsoft fell far short of that. Their MSDN homepage is cluttered, hard to pinpoint where to go if you want to write Windows applications, depends on you knowing about existing Microsoft technologies, and even has ads for their developer products (making people pay for Developer tools is another whole issue).

MSDN home page

Now on the other side of this spectrum is Apple’s developer homepage, which is simple, clean, and extremely informative about where you should go next: “Are you developing for the Mac or the iPhone?”

Apple home page

Matters get worse with the Mac and Windows Dev Center. If I am developer wanting to write an application, I want something that tells me where to go, that explains things simply, and walks me through getting started. Once again, Apple gets it, and even after trying to get through Microsoft’s developer site for about a half-hour, I couldn’t figure it out. Apple’s seemed to take about 2 seconds (or maybe like a minute).

Microsoft’s Windows Dev Center:

Windows Dev Center page

Apple’s Mac Dev Center:

Apple's Dev Center page

So I guess my question is: what’s so wrong with making things simple? Is it just a personal thing?

Granted, all this said, neither of these two developer sites is perfect, in any regard. Both sites place a huge emphasis on their products, versus the actual development on said products. Secondly, anyone who wambles onto their site should be able to write a 5-minute “Hello world!” application with no hassle. Apple and Microsoft both need to simplify, swallow the fact that people do not care to see ads for their products, and then provide a handy guide for how to write applications for their platforms.

Another decorative pizza

While I was home this past weekend, Leslie and I did another decorative pizza. At Wheaton North High School where Leslie and her sister Lizzy attend, there is a program where French foreign exchange students come and spend two weeks at the homes of students at the school. This year, Leslie’s family volunteered to have someone join them. On Saturday, the day we made the pizza, Agathe arrived. So in honor of her arrival to the states and her Frenchness, we decided to make the pizza French themed.

Can you guess what we did?

Our French pizza

The cry for musings

I have to apologize, the last like 132984 posts on my blog have been technical. I hear the cries of those who just want to read musings, and so I will try my hardest to muse more.

Keep checking back!

Thread safety performance on different CPU architectures

A few weeks ago, I did a post on thread safety performance on my machine. However, that was only on one machine, a 2.16 GHz Intel Core Duo architecture.

Yesterday, Joey and I decided to run some more tests of thread safety performance implementations (no thread safety, mutexes, and semaphores) on different architectures, and the results were quite interesting. We ran tests on my machine again, on a 2.16 GHz Intel Core 2 Duo iMac, a 800 GHz PowerPC G4 iMac, and a Quad Core 2.66 GHz Intel Xeon Mac Pro. After running the same tests on each machine, we normalized the data to get rid of the clock-speed factor.

For mutexes, the machines all performed about the same, with my Core Duo doing slightly better than all of the other machines. In second place was the PPC G4, and then the Core 2 Duo machines took up last. For the semaphores, the PPC G4 smoked the Intel chips, a very interesting result.

Here is a summary of our results (the numbers listed are in cycles/5 seconds and the numbers in parenthesis are the normalized data):

Core Duo:
No thread safety: 440909468 (1)
Mutexes: 98324839 (0.223)
Semaphores: 197981 (0.00044)

Core 2 Duo:
No thread safety: 831519248 (1)
Mutexes: 135168338 (0.163)
Semaphores: 1153251 (0.00139)

PowerPC G4:
No thread safety: 119723944 (1)
Mutexes: 23709889 (0.198)
Semaphores: 1020029 (0.00852)

Quad-core Xeon:
No thread safety: 884848737 (1)
Mutexes: 140097898 (0.158)
Semaphores: 1157646 (0.00131)

Here are some charts representing this data:
All data

Mutex performance

Semaphore performance

Detecting conflicting Objective-C category methods

Objective-C categories are an extremely powerful way to add functionality to an existing class. Take for example, the category below that adds some stack-like methods to NSMutableArray:

@interface NSMutableArray (StackAdditions)
- (id)pop;
- (void)push:(id)object;
@end

@implementation NSMutableArray (StackAdditions)
- (id)pop
{
    id lastObject = [[[self lastObject] retain] autorelease];
    [self removeLastObject];
    return lastObject;
}

- (void)push:(id)object
{
    [self addObject:object];
}
@end

Now let’s say that I was writing a plugin for any app in Mac OS X that had a plugin architecture, such as IB, Aperture, Address Book, etc. Now, let’s also say that these apps had the same category methods on NSMutableArray, but they were slightly different, maybe they didn’t retain the object because of a special need they had. Well, when my plugin gets loaded into the app, the Objective-C runtime will auto-magically replace their category with mine because they have methods with the same name.

Obviously, this presents a problem. Now whenever their code calls -[NSMutableArray pop] or -[NSMutableArray push:], then the runtime will use my implementation instead. And if their category relied on some special happenings in their implementation, then the entire app could quickly fall into an unstable and fatal state.

So what’s to be done? If you are writing an application that has a plugin architecture or you are writing a plugin for an app, you should run the application during testing with the environment variable OBJC_PRINT_REPLACED_METHODS set to YES. What this does is it tells the Objective-C runtime to print out any methods it replaces when loading in a plugin. If you see that your implementation is being overwritten or you are overriding someone else’s, then you know that you will need to change the name of your method to something else, such as -[NSMutableArray myPop] instead of the original method -[NSMutableArray pop].

Pictures from Leslie’s visit are up

I just put up a few pictures from Leslie’s visit to the U of I this past weekend.

Click the image below to see them.

Leslie at the U of I

Attempted to upgrade Wordpress

A new version of Wordpress is out, and after attempting to update to this new and improved version, well… my site broke. So after some finagling with the server, I was able to restore the old version, luckily.

A weekend with Leslie

This weekend, Leslie came down to visit me here at the U of I. Boy, it was blessing to have her here.

She arrived Friday evening, and since we both had had long school days, watching LOST entertained us until bed time. She stayed with my friend Anne at Stratford House, which was certainly very nice of her to do.

Saturday was a day of… walking. Before brunch, we took a walk around the 6-pack and south quad. Then after brunch, we walked up to the Engineering Quad, up a little farther to see my apartment for next year, then all the way down to Oregon Avenue for coffee, and then down past Florida and Lincoln to the Arboretum. For a college in Illinois, the Arboretum was quite pleasant. It had some gardens, a lake, wooded areas, and a Japanese house used by the college for Japanese Education. After we were done with that all, we had to walk back.

In all, Leslie and I walked 7.28 miles, according to Google Earth. You can a trace of our trip below:
Our walk

Today we went to church at TCBC, had brunch at FlatTop Grill (I highly recommend it!), and then plan on spending the rest of our time watching LOST or reading Harry Potter before her bus at 5.

Mandarin Wok: Good Chinese food for a corn field

This evening I went to Mandarin Wok for some chow with my good friend Joey. You know, for being in the middle of a cornfield, the food was actually quite tasty. We ordered off of the Chinese menu, which partially meant that I had no idea what I would be receiving. We pointed to stuff, and in broken English, were told was it was… “Chick-in”, “Veggie-tables”. But whatever it was, it was good.

After the meal, I scurried off to a Computational Theory exam before having to walk the 25 minutes back in the freezing, torrential rains amidst a thunderstorm. A nice warm shower and clean clothes awaited me back at the dorm.