MonoTouch Review: Porting an Obj-C App

image

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.

Background

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.

The Good

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.

The Bad

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.

Verdict

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.

19 Comments » for MonoTouch Review: Porting an Obj-C App
  1. ManniAT says:

    Nice review. By the way – one (big for me) con can be solved when you use Visual Studio instead of MonoDevelope http://manniat.pp-p.net/blog/post/2009/11/18/MonoTouch-in-Visual-Studio.aspx

  2. Eduardo Scoz says:

    Great article, Bryant. My experience has been very similar to yours. I’ve been posting lots of controls and code samples at http://escoz.com .

  3. Ian Vink says:

    I moved to MonoTouch recently from Obj-C which I learned last year after 9 years in .NET C#.

    I found the code I had to write about 1/3 as much as in Obj-C.

    My first new app is on the App Store and selling.

  4. Bryant says:

    Thanks for the input guys. Glad to see there is a community of MonoTouch developers starting to come together!

  5. Thanks for the great review!

    We initially didn’t include the SVN addin on Mac because of old reports that it had been very unstable there. However, after some demand we tested and dogfooded it,and didn’t run into any problems, so we included it in MD 2.2. If you’re having problems, it would be very helpful if you could open bug reports and attach any exceptions or crash traces you’re getting.

  6. Bryant says:

    @Michael – Thanks for all the hard work on MonoDevelop!

    Most of the issues seemed to be related to adding new folders and subsequently deleting them. The other issue I get pretty frequently has to do with modal windows losing focus. I will try to reproduce both and open a bug report.

  7. Classic68 says:

    You might post an update to your MonoTouch review. It would be good to know how things have progressed with MonoTouch.

  8. James says:

    Yes, an update would be nice, how has the platform matured in the last year?

  9. Bryant says:

    I would like to post an update but the sad truth is that after using MonoTouch for about 6 months, due to performance issues, I ended up porting my app back to obj-c and have not used MonoTouch since :(

  10. Bryant says:

    The sad truth is that I stopped using MonoTouch due to some performance issues and went back to Obj-C. Perhaps I will post a follow-up describing my experience since it sounds like there is some interest.

  11. Bryant, what performance issues did you run into? I’m looking to start MonoTouch development for all the same reasons you listed.

  12. Anonymous says:

    The main performance issue I ran into had to do with plists — which my app made extensive use of.

    At the time, monotouch was about 8x slower in loading up a plist compared to obj-c. It was a noticeable difference for the users.

  13. andy says:

    Our team used monotouch to make a real time application on ipad that monitors a lot of data, we had 7 – 8 threads running at one time. Sadly, we ran into performance and stability issues, our app would crash every time we ran it with segmentation fault and other exception. Even after desymbolicating the crash logs were not helpful at all. In all we had a very bad experience with monotouch so we moved to objective c path.

  14. Ovabus-pipes says:

    Hi andy!. Can you explain a little your situation with this ? I mean, did you indeed find out that the problem was MT’s fault and not a coding mistake or some other thing ?

  15. Andy Lawrson says:

    @7802c8d5fd4b31427f57599ed2d00807:disqus we tried for days to fix various stability issues, but didn’t get far .. seems like MT was not able to handle the quantity and rate of data that we were using … so we moved to Obj. C approach and rebuilt our app from scratch ..

  16. Ovabus-pipes says:

    @andy: Thanks for the reply! Hmm… i see. Do you think that, maybe, the problem was caused my MT’s Garbage Collector ?

  17. Andy Lawrson says:

    yes it was mono’s garbage collector .. but i think today they released an update that fixes the issues in garbage collector ..

  18. Steve says:

    I’m a few weeks into my first iPhone app with Monotouch and finding the debugger dropping out every five mins (iPhone simulator) hugely frustrating, v.tempted to drop MT and pole into Objective C. Whats other people’s experience when debugging. Is it just the free trial that’s ropey?

  19. What’s up it’s me, I am also visiting this website daily, this website is genuinely good and the people are actually sharing nice thoughts.

2 Pings/Trackbacks for "MonoTouch Review: Porting an Obj-C App"
  1. MonoTouch Article – MonoTouch Review – Porting an Obj-C App…

    Thank you for submitting this entry – Trackback from MonoTouch.Info…

  2. [...] One of my apps in written in MonoTouch on the iPhone because I don’t particularly like objective-C and I find c# more productive. Does this mean that apple is going to pull my [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>