At the MSDN Blogs, Shawn Burke has recently decided to do a comparison of the iPhone SDK and the Windows Phone 7 Series SDK (what a horrible, horrible name!) by writing a simple Hello World application and showing the difference between the two.

While I don’t think it’s really fair to compare a C-based platform with a .NET based one, Shawn’s point that the it takes a lot more code to write the same application is real. It’s also real to say that the iPhone SDK could run extremely well in a 400MHz processor three years ago, while the Microsoft will need a 1+Ghz processor and still isn’t on the market, but that’s a different conversation.

Anyway, I work daily with MonoTouch, a port of the Mono platform to the iPhone, and thought it would be a good idea to show how concise iPhone development can be when you write code on top of the platform. Here are the steps:

So, at the end, how many lines of code have we written? 3 or 5, depending how you count. If I had written the code the same way as Shawn, it would be more like 7-8. So it’s more code than when using the Windows Phone SDK, right? Well, I would say wrong. Here’s why:

Although we used XML on the solution (the XIB file is XML afterall), we absolutely never touched the file at all. For all purposes, the code in that file doesn’t exist at all. I’ve been developing for 5 months using MonoTouch now, and I never had to open the XIB in anything other than Interface Builder.

So when Shawn mentions that he can write the entire thing in only 4 lines of code, (or even zero!) that’s not entirely true. You’ll be hand editing the XML directly daily, to the point of even writing untested, non-testable business logic in it (like Shawn did in his example). And that XML will have bugs in it (yes, it will). And if you’re going to do it, you better count those lines of code as well. In Shawn’s case that adds 15 lines and a totally different language developers will have to get used to.

Isn’t it funny how you never really hear objective-C users complain about their platform? The iPhone SDK is a really well developed API, and really simple to use to create applications. It’s different from Microsoft’s solution, but that doesn’t mean its bad (some would say its actually better just for that, I prefer to stay in the middle).

Before anybody says anything, yes, I used MonoTouch, and not Objective-C like the Shaw’s example. My opinion here is that the language doesn’t really matter: the framework does. What’s the problem if it takes 5 more lines of code in objective-C than C# to do something? I bet a lot of those obj-c developers can write those 5 lines a lot quicker than I do.

I love .NET, and I’ll likely be writing many apps in the WP7SSDK (worst acronym ever, I guess) in the future. From what I’ve seen so far, the platform sounds very interesting, and it’ll be great to reuse code from MonoTouch and just have to rewrite the view code for the new phone.