21

I am considering using MonoTouch for some iPhone development, but payload size is an important factor.

For a user who has never installed Mono on their iPhone before, what would the size of an Objective-C "Hello World" app be compared to a MonoTouch "Hello World" app?

More specifically, what is the approx. number of bytes that need to be downloaded, and what is the approx. number of bytes used once installed?

D'Arcy Rittich
  • 167,292
  • 40
  • 290
  • 283

3 Answers3

17

A "Hello world" program in Objective-C occupies 50 KB (whole .app folder). With MonoTouch, a similar "Hello World" app occupies 5 MB (whole .app folder), which is not bad at all considering it has a runtime with garbage collection in it.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Zoran Simic
  • 10,293
  • 6
  • 33
  • 35
  • 1
    Apps are sent zipped to the app store, so count a 30 to 50% or so reduction in size for the download size. Once installed on the device, the app will take the same amount as the .app folder you built. – Zoran Simic Sep 18 '09 at 18:31
  • 5
    Not correct Zoran. The zipped executable size is NOT what the appstore lists for size. One of our applications was under 10mb when zipped and uploaded, however it now shows as 14.7 in the store. This unfortunately puts us over the limit for 3g downloads. – Lounges Sep 18 '09 at 18:33
  • 1
    Yes indeed, I mistakenly stated 70% when I meant 30... Deleted the comment, but now I realize I shouldn't have because someone followed up on it :) So, disregard the percentage statements. The download size is whatever the zipped file size is. – Zoran Simic Sep 18 '09 at 18:33
  • 1
    Oh, and I didn't know that. I thought the download size was the size of the zipped .app folder. One learns every day :) So, disregard my comments entirely then :) – Zoran Simic Sep 18 '09 at 18:34
  • @Zoran: Thanks, that's really helpful. It would be nice if the full MonoTouch code didn't have to be deployed each time, if there was already a MonoTouch app on the device... – D'Arcy Rittich Sep 18 '09 at 19:28
  • 6
    5MB is HUGE! objc + GC on Mac OS X occupy less than 1.25MB. I'd bet most of that 5MB is the gluey goop between the Mono APIs and the Cocoa Touch APIs. – bbum Sep 18 '09 at 19:34
  • 1
    bbum: Yes, that is definitely the case. Just like Cocoa, Java and the .NET frameworks before it, Mono is 99% libraries, 1% runtime (if you measure in disk usage that is) – rpetrich Sep 19 '09 at 15:26
  • 2
    I think it would be very smart for Apple to give some support to Mono Touch just like they did to Bootcamp: yes, people can easily install Windows on a Mac now, but that's the reason I got started on Mac! I bought one thinking I would probably drop it and just install Windows on it... I thought I wouldn't like OS X as much as I loved the hardware. 6 months later, I dropped Windows completely! Supporting Mono Touch could have similar benefits for Apple. I don't plan to use Mono Touch, but it's a fantastic thing to have. They should bundle the Mono runtime with each iPhone, starting at v4.0 – Zoran Simic Sep 20 '09 at 01:16
  • @OrbMan Apple does not allow the use of a virtual machine such as mono, hence the need for MonoTouch to embed part of the VM that are required by the application. – Julien Sep 23 '09 at 23:56
  • 1
    Ok, so you get GC at the cost of five megs. If I had a five meg leak, I'd consider that a pretty major bug. – NSResponder Dec 04 '09 at 14:20
  • 9
    The apps are not that big, I'm not sure where "5meg" comes from. Unless you include the entire monotouch API set, but most apps use an area only. I produce more apps and sell more apps and make more money now that I switched from XCode to Monotouch and in the end, that's the best benchmark for a commercial developer. Happy, paying customers and lots of them. – Ian Vink Feb 28 '10 at 22:49
11

In 1.5 Monotouch

A release build - that is a an application built with a distribution license - and with nothing but the default project settings, is 5 MB. Of that 4.3 MB is the binary executable.

They often rise to up to 10 MB in my experience, and the forums paint the same picture. The appstore reports the unzipped size, however they are downloaded zipped. Zipped it is around 3 MB which, even on a 3G, is fine.

In my view, most people won't look at the filesize before downloading an app, nor particularly care. The appstore limit for 3G downloads is now 20 MB which is well within the MonoTouch size.

To play devil's advocate, yes, it is many orders bigger than the Objective-C equivalent and could scare off a few people worried about occupying 4-10 MB more of their 16 GB space. However there is also time to market and the existing tools available for .NET. I develop and build all my MonoTouch apps in Visual Studio 2010 then test them on the Mac, and I don't think even Apple would argue their IDE is close to the industry leader.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Chris S
  • 64,770
  • 52
  • 221
  • 239
  • Hey, Chris -- I'm a bit frustrated with MonoDevelop and interested in the VS approach. Do you have a writeup anywhere on what you've found to be a good way to set that up? Or should I rephrase that as an SO question? :) – David Moles Mar 10 '11 at 19:04
  • 1
    @David I've got a small section on VS2010 at http://www.shrinkrays.net/code-snippets/csharp/monotouch-tips-and-snippets.aspx scroll down to "Using a monotouch project in Visual Studio 2008/2010" – Chris S Mar 11 '11 at 12:29
  • Cool, thanks. Looks like I already bookmarked your page and didn't make the connection. :) – David Moles Mar 11 '11 at 16:59
  • @David Full howto: http://blog.binaryfinery.com/pages/monotouch-visual-studio-productivity – jamie May 29 '11 at 00:56
  • 2
    To anyone wanting to use Visual Studio 2010 with MonoTouch. Many of those workarounds involving hacking the cproj file and having to maintain two versions of the project and solution files have been made obsolete by this fantastic VS2010 addon: https://github.com/follesoe/VSMonoTouch – Oliver Weichhold Nov 23 '11 at 11:43
8

From this question on MonoTouch and Size of Executables:

MonoTouch doesn't translate to Obj-c. It compiles to .NET IL, then compiles that (in the same way a JIT compiler would, but before it's run - hence "ahead of time" compiler) into native ARM code.

so:

Obj-C -> GCC (or LLVM) -> ARM code

vrs MT:

C# -> IL -> (AOT compiler) -> ARM code

The output binaries in 3.x are larger because you are also including a lot of the .NET framework (well, Mono Framework, but same-same), so if you, for eg, use System.Xml, it has to include that into the output - same with System.dll etc. The linker is pretty smart, but the output binaries are always going to be larger.

For me, the only size thing that matters is load time, and zipped binary size. Zipped binary for a "hello world" app is about 2.5-3meg (smaller in 4.x I'm told) vrs about 300k for obj-c. The difference gets less and less the more you add, as it only includes the likes of system.dll once. Load time for MT vrs Obj-c, doing the same things at the same time, is close enough to the same. Either one can be made to load slowly (just do something long running in your FinishedLaunching without putting it on another thread).

The answerer goes on to say that he feels that he is more productive with MonoTouch than Objective-C. YMMV.

  • @RedFilter: Wouldn't of known about it if it wasn't for Jeff Atwood pointing it out in a blog post. –  Jul 14 '11 at 13:30