Because Objective-C sometimes makes me want to poke out my eyes with sharp sticks, I’m relieved to see that there are finally other options. Now let me be clear. I think objective-C would be a fine language if it was something that I used day in and day out, but given that I only tinker in it and spend the majority of my time in .NET, I can’t help but see MonoTouch as a godsend.
MonoTouch is a framework, created by the brilliant mono team at Novell, that allows developers to use C# for coding iPhone apps. Not only have they ported the .NET framework to run on the iPhone, but they’ve bound it to the iPhone API. In addition, they provide a first class develop environment in the form of MonoDevelop on the Mac.
This brings up an important point. You still need a Mac to develop C# on the iPhone using MonoTouch. Luckily, I have my trusty Mac mini so I thought I’d take MonoTouch for a spin by porting my existing Objective-C app to MonoTouch.
I developed an iPhone app in Objective-C over the summer and it was approved by Apple. It’s called BragVest and allows Cub Scouts to track their progress toward ranks. It’s currently live in the app store and getting some great feedback from users. I have a lot of ideas for new features, but implementing them is a different story.
When coding in Objective-C, I spend too much time just looking up how to do simple operations. What’s the best way to load a plist? How should I best concatenate that string? Operations that should be simple and probably are to a Mac developer or someone who spends a lot of time with the language.
It’s a simple case of focusing on your strengths. I’m a professional .NET programmer and have been for a long time. I can crank out .NET code in my sleep, but programming in objective-C sometimes feels like I’m pushing a boulder up a hill. It just takes a lot longer to get a feature implemented and I spend a lot of time just looking up language features.
So, in theory, MonoTouch would be a great fit for me. I’ve already mostly learned a lot of the iPhone API, and now I get to use a language I know and love — C#.
At this point, I’m about 75% through porting my app to MonoTouch, and here’s what I’ve learned.
There’s a lot to enjoy about working with MonoTouch:
- MonoDevelop: MonoDevelop feels much more like Visual Studio.NET (my native development environment) than XCode does. I spent many months in XCode and it just takes a different approach to development. MonoDevelop seems like it was modeled after VS.NET so I felt productive almost immediately.
- C# language: It’s great to have access to the C# language. It feels much more natural to me than Objective-C. I’m sure this is just a matter of experience, but the bulk of my experience is with C#. Also, I’m glad not to have to deal with memory management so I can focus on developing new features and not writing plumbing code.
- .NET Framework: Being able to access the .NET framework is huge, and probably one of the biggest selling points of MonoTouch. Need to parse a plist? No longer do you have to resort to NSArrays and NSDictionaries. Just fire up LINQ to XML! Need to do some fancy string parsing? Don’t use NSString. Just use the standard .NET string type. They also put a lot of thought into translating between the Apple and .NET APIs so it’s mostly seamless. If you need to see how a particular class or API was translated, check out the MonoTouch Rosetta Stone.
Most of the issues that I ran into have to do with the fact that this is still a very new platform:
- Lack of Samples/Docs/Community: This was the hardest part of developing with MonoTouch. When I was working with the apple tools, if I wanted to know how to do something in Objective-C, I could generally google for it and quickly find an example. The blogs and docs are just starting to pop-up for MonoTouch so it can be much harder to find real-world examples.
- Stability: One of the most frustrating parts of developing in MonoTouch was that the IDE (MonoDevelop) would crash on me or throw strange exceptions periodically. It seems to mostly be related to the subversion integration so maybe if I disabled that I’d have more stability. That said, I have not seen any stability issues when the code is running on the phone so that’s what’s important.
- Not Fully Implemented: Every now and then, I would want to do something with MonoTouch and get a “Not Implemented Exception” (such as some LINQ features) or I couldn’t figure out how it was translated (such as NSMutableDictionary).
Some people would also mention cost ($399), but I don’t think that’s fair. The mono team have put in an amazing amount of work that provides real value to developers. It’s only natural, that they should be compensated for it.
I also think the increased file size of MonoTouch app is small price to pay for all the features and frameworks you get.
In my opinion, there is more than enough good to outweigh the bad in MonoTouch. I’m also hoping that much of the bad will disappear as the platform matures.
For an experienced .NET developer, it will give you a huge head start in iPhone development especially if C and memory management make you squeamish. That said, there is still a heavy learning curve with getting used to the Mac, the iPhone API, and Interface Builder. And MonoTouch does not eliminate the need to learn how to make a iPhone app that fits Apple’s design guidelines (which you will have to do to get it approved).
Overall, I’m planning to invest in it, and if you are an experienced .NET developer wanting to develop apps on an iPhone I would recommend you take a look as well.