Thursday, March 31, 2005

I used two different styles of game loops in my Managed DirectX books.

Both approaches were wrong.

It seems that our stalwart Rick Hoskinson has spent a little groktime on this and has reached, he believes, the Perfect GameLoop.  My publisher is pressuring me to do a second edition of my game programming books, so maybe that's a good time to make the move.  Anyway...give it a read if you're into getting the most performance out of Managed DirectX apps (and who isn't? :-) )

P.S. -- For those of you reading this post on InkBlog (my "personal" blog), you'll notice a few changes.  I finally got around to upgrading to dasBlog 1.7.  Welcome to my new old blog :-)

3/31/2005 3:26:58 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]  |  Trackback
Thursday, March 17, 2005

I bought a Mac Mini last week.  The day before I left on vacation, a tiny box from Apple appeared at my doorstep.  In a fit of boldness, I decided to take it with me and spend part of my weekend in Texas pounding away at it.  I wanted to get a feel for the kind of user/developer experience a Mac user would get as an “out of the box” experience and share it with you.

 

A few of caveats before I begin:

  1. This is a really long blog entry.  I spent an entire weekend in a love/hate relationship with my new Mac.  I want to share the whole experience with you.
  2. I deliberately avoided the “multimedia experience” of the Mac.  The features of Apple's iTunes/iDVD/iPhoto stuff are pretty well-known.  I was more interested in what kind of experience an average Windows developer would have.
  3. It's possible, especially during the development part, that I've done something that wasn't "The Apple Way."  I haven't touched an Apple since 1991, so any errors/omissions/undeserved grousing is entirely my responsibility.  If you read something in here where you think I'm just plain wrong/daft, pop in a comment and correct me.  I love my PC, but I'm also a Mac owner now, so any suggestions you can offer that would make my experience on here a better one is very welcome
  4. Yes, I work at Microsoft.  Yes, I'm an evangelist at Microsoft.  No, I'm not being paid to write this, nor am I writing this to be a shill for Microsoft's products.  I spent my own money to buy a Mac, and what you are reading is my own opinion.  I will say good things and bad things about the Mac.  You have been warned.  

 

The Out Of the Box Experience

 

Big kudos goes to Apple here.  My Mac Mini was a relatively high-end configuration. It had a 1.42Ghz G4 CPU, 80gb HD,512Mb RAM, DVD RW, built-in Bluetooth/802.11b/g, plus Bluetooth mouse/keyboard.  Microsoft employees actually get small discount from Apple, and the total “shipped to the door” cost to me was under $1000.  Looking back now, I recommend bypassing the Bluetooth mouse/keyboard combo and sticking to whatever Mouse/Keyboard combo you like (Microsoft, Logitech, etc.).  Aside from my rants about the mouse (see next section), I also noticed my Apple bluetooth keyboard occasionally didn’t send a character to the screen.  I can’t tell if this is because I’m having difficulty in typing with a “non-split” keyboard or if it was a Bluetooth problem.

 

Opening the (extremely small) box was simple, as was hooking the computer up to the monitor.  Startup was very simple, and after a short “first user setup” sequence, it hooked up to the Internet and identified several updates to install.  This procedure was simple, and each step was clear.  Other than the mouse issue, a Windows developer would have little to no difficulty getting used to OS X (and to an old Unix guy like myself, I'm quite fond of popping up a bash shell anytime I want -- of course, I can install Windows Services for Unix and get bash on my XP box).

 

The overall visual and performance, even for such a tiny box like the Mac Mini, is quite impressive.  The glass effects and visual behaviour of the dockbar is impressive, and overall visual presentation is simple.  One really cool thing is Expose, which allows you to quickly organize and look at all the open windows at once with just one button.

 

Apple’s Glaring Wart

 

In my opinion, this is a major Achille’s heel of Apple – their persistent belief that people want/need a one-button mouse.  My Mac Mini came with a Bluetooth keyboard and mouse, but the experience of a one-button mouse was nothing short of miserable.  What is ironic is that I suffered the EXACT same problem when I was first developing on a Mac IIfx running A/UX back in 1990.  You'd think that Apple would at least offer a three-button mouse as an option (although the latest news from Engadget says Apple is about to offer a two button mouse -- That would be nice -- a 21st century OS with an early 90's mouse). Fortunately, the Microsoft wireless mice/keyboards work GREAT with the Mac.  Even better, almost ALL software on the Mac is actually smart enough to understand right-clicks and the scroll wheel.  Um, Apple...if you wrote the software to support 3 mouse buttons and a scroll wheel, why not offer hardware to match the functionality?

 

Would You Like To Play A Game?

 

Let's be honest, you probably won't buy a Mac Mini for its gaming power.  That being said, I decided to give a few games a whirl.  The Marble Blast game that came with the Mac was cute (but simple).  The "Nanosaur2" game bordered on stupid (both in terms of gameplay and controls).  I also own World of Warcraft, which will install on either a Mac or PC, so I loaded that up and gave it a run.  Not pretty.  Yes, it was playable, but barely.   

 

Developers Developers Developers Developers

 

This was really the ultimate test.  What is the experience like to develop on a Mac?  How easy is it, compared to something like VB.NET or C# development?  This is my summary: In spite of Apple's XCode development tools coming for free with Mac OS X, developing on a Mac sucks like an inverted hurricane.

 

There are two primary paths a developer can take when writing code for OS X:

1)    Carbon: This is the C/C++ interface for writing Mac OS X applications

2)    Cocoa: This is the Objective-C/Objective-C++ interface

 

Unlike the managed/unmanaged demarcation Microsoft has with .NET, the Carbon/Cocoa difference is more about preference and background more than execution environment.  For instance, you can call Carbon APIs from Cocoa, and vice versa.

 

Performance-wise, Carbon apps are (theoretically) a little slower because they use a more object-oriented framework.  As a comparison, one game programmer indicated that a file management component took 800 lines of code in Cocoa, versus 18,000 in Carbon.  Generally speaking (from what I can tell), newer apps should be written in Cocoa, while older apps (C/C++ based) will benefit from using the Carbon APIs (Office for Mac is written using Carbon).  I will focus on Cocoa app writing for this entry.

 

I wanted to start with a simple window that had a few controls, just to get a feel for what my development would look like.  When you launch XCode and create a new project, you’re faced with a large array of startup options, generally either Cocoa or Carbon apps, but also including the ability to develop Java EJB or Swing applications (I'll skip over this part except to say this -- if you want to write a Java app, forget about XCode and use Eclipse).

 

After you select a Cocoa application, the XCode project window opens with a set of pre-populated files.  Although it looks nothing like Visual Studio, I didn’t find the layout to be too arcane/overwhelming.  One thing that was VERY different, however, was the process to create and wire up a GUI.  To begin with, you must launch a separate Interface Builder tool.  The tool is laid out rather oddly (from my prespective), but a quick read of some developer documentation helped. Unfortunately, playing “drag and drop” with the controls was the only easy part of the task.  The process of wiring up outlets and actions (similar to properties and events in .NET) is nothing short of wierd.  What would take a .NET developer a scant few minutes to do takes easily three to four times as long with the Interface Builder.  Compounding this is the fact that generating the code is effectively a one-way trip.  You really can't go back and add/change things without a lot of pain (According to the Apple docs, “Once you have created .h and .m files for a new class…, you should not use the Interface Builder Info window to add more actions and outlets to the class.”).Once the code is generated, you're back in the XCode development tool, and you begin "filling in" the code stubs generated by the Interface Builder tool.  This process is also quite painful, as the XCode editor has only redimentary code sense and contextual help (again, I emphasize I'm comparing to Visual Studio).  In addition, there is little to no help to warn you about potential errors in your code (I didn't turn on the "predictive compilation" feature though, so maybe that would have changed things -- XCode has some interesting features that appear to be turned off by default).  Once you've managed to write your Objective-C code correctly, you go through the standard "compile and run" cycle.  Debugging is also a challenge, but if you're familiar with gcc/dbg, you should be somewhat comfortable.

 

My Final Thoughts

 

Apple has a nice hit here with the Mini.  It's definitely lowered the bar for people wanting to bring a Mac into their lives, and it boggles me why PC manufacturers can't offer something in as small of a form factor as Apple has done.  For a non-gaming Mac user experience, the Mini delivers in a nice package.  For a developer experience though, the Apple developer tools have a long way to go.

3/17/2005 2:22:20 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]  |  Trackback
Sunday, March 06, 2005

Some of you remember a post I had made in late September about my climb up Tiger Mountain.  I decided to do it again, now that the nice weather has returned to the Seattle area.  Of course, things are a little bit different now.  Back when I first climbed Tiger Mountain, there were two important things to note:

  1. I weighed 285 pounds (not including the 30lbs in my backpack)
  2. The entire round trip took me 4.5 hours (3 hours up, with many stops, and 1.5 hrs down).
During this time between my ascents up Tiger Mountain, I went into a rigorous program that corrected my bad eating and exercise habits, and have _so far_ lost over 50 lbs.  So this time, there were a couple minor changes:
  1. I now weigh 230 lbs (and I'm still working to get down to a comfortable 210-215 range).
  2. The entire trip took me about 2.5 hours, and that included a leisurely 30 minute rest at the summit and stroll back down.  The ascent alone was completed in 1 hour, 10 minutes.
Anyway, I did take a few pics...although I didn't get some real stunners like I did the last time, probably because I did the hike MUCH faster than I thought it would take me (time flies when you're having fun!).

Here's my (blurry) happy face as I started the hike.  Yes, I should have turned the flash on.  Compare that pic with the fat version of me (the next pic) from my first hike!

The start of the trail...about to begin a 3 mile, 2000ft hike.

Reached the top in 70 minutes...I was tired, but not exhausted (like the last time).  Heck, I even passed some people on the way up.  The last time I did this, SNAILS were passing me :-)  You'll also see that I wasn't the only one that decided to get out and enjoy the hike.

And here's a couple of scenery pics.  The first one is looking east, the second one is looking west.  The blurry city you see in the pic is Seattle.

 

3/6/2005 10:50:32 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]  |  Trackback
Tuesday, March 01, 2005

I've been knee-deep in WSE for the last bazillion weeks, and am finishing up an article for MSDN on it.  Since I'm on a WSE kick right now, I should point you to Mark Fussell's notice telling people that WSE 2.0 SP3 is ready for downloading.  Enjoy!

News coming up next week: Some talk about upcoming Avalon goodness, packing for a vacation to Texas, and hoping I don't get get people at work pissed off because I bought a Mac Mini. :-)

3/1/2005 9:10:00 PM (Pacific Standard Time, UTC-08:00)  #    Comments [3]  |  Trackback

Theme design by Jelle Druyts

Pick a theme: