MonoSpace Conference in Austin - October 27 through 30

by Miguel de Icaza

Over the past few weeks, the final details of the program for the Monospace Conference have been announced, and now the event is just less than two weeks away. Some key details you may have missed:

  • The Monspace conference features 2 days of workshops and 2 days of Open Space sessions.
  • The full conference agenda has been posted, and now includes a full day of MonoTouch training (Mono for the iPhone).
  • The two-day open space sessions will be kicked off on Thursday with an Open Source Panel featuring Sam Ramji (CodePlex Foundation), Ayende Rahien (NHibernate and Castle Contributor), and Glenn Block (Managed Extensibility Framework) and moderated by Rod Paddock, Editor of CoDe Magazine.
  • The famous, prolific and thorough Ayende Rahien will be speaking on NHibernate.
  • Microsoft's own Glenn will be talking about the Managed Extesibility Framework.
  • M David Peterson will be discussing Mono on Amazon EC2.
  • The ThoughtWorks crew will be talking about F# on Mono.
  • Eric Hexter from Headsprings will be covering ASP.NET MVC.

From the Mono team, various engineers will be presenting on special topics:

  • Larry Ewing will talk about the Moonlight, the open source implementation from
  • Aaron Bockover will talk about cross platform GUI development with Gtk#.
  • Geoff Norton will discuss development with MonoTouch on the iPhone.
  • Jackson Harper will talk about ASP.NET MVC development with Mono and Joseph Hill will discuss Mono Tools for Visual Studio.
  • Rodrigo Kumpera from our JIT team will do a low-level talk on Mono's Virtual Machine covering some of the innovations on the VM that are Mono-specific.
  • And I will focus on the schmoozing.

The Monospace conference will be held in Austin, TX on Tuesday, October 27 through Friday, October 30. To register for the event, visit the Monospace Conference Registration Page.

Check the program for more information.

Registered Monospace attendees will receive a $150 discount on MonoTouch, if they purchase in the month of October.

Posted on 16 Oct 2009

Event mapping in MonoTouch

by Miguel de Icaza

When we were designing the MonoTouch APIs we had to map some of the constructs used by CocoaTouch and Objective-C to what C# developer expect.

Like other modern toolkits, the behavior of a control can be customized by the programmer by hooking up to events and the responses to those events.

This is a common pattern used in other toolkits. In Gtk+ objects emit signals, and the programmer can connect event handlers to individual signals, for example this is how you would connect

void pause_player ()
	// pause the player.

void configure_pause ()
	button = gtk_button_new_with_label ("pause");
	gtk_signal_connect (button, "clicked", pause_player, NULL);

In the ECMA CLI world developers hook up to events by connecting to events directly in the object, it is similar in spirit:

void configure_pause ()
	button = new Button ("Pause");
	button.Clicked += delegate {
		// Pause the player here.

In both the Gtk+ and the ECMA CLI worlds there can be multiple subscribers to the event.

In CocoaTouch, instead of having an event per action they use a pattern where the components emits all of its messages to an instance of an object. If a button were to emit messages like "clicked", "clicked_violently" and "caption_changed" all of those messages will be sent to an object that implemented the required interface.

I am going to give myself a literary license and use some terms loosely and write a little bit of imaginary C#.

A button implementation would look like this:

interface ButtonDelegate {
	optional void clicked ();
	optional void clicked_violently ();
	optional void caption_changed ();

class Button {
	public ButtonDelegate Delegate { get; set; }

	public Button (string text) { ... }

	public string Text {
		get { return text; }
		set {
			text = value;
			DoSomeRepainting ();
			Delegate.caption_changed ();

	public EventHandler ()
		if (event_this_is_the_user_clicking){
			// Send the message to the Delegate
			Delegate.clicked ();

The user of the Button class then needs to implement the interface ButtonDelegate to respond to messages. This in Objective-C is made simple by allowing this interface to have optional methods.

This would not work with C# interfaces as those require that all the methods on the interface are implemented.

So we came up with a design that would blend those worlds together.

Supporting the Objective-C approach

We can support the Objective-C model where a class can satisfy the contract by just registering methods to respond to the actions. A user could respond to some events like this:

class Foo : NSObject { 
	void ConfigureButton ()
		button = new Button ("pause");
		button.WeakDelegate = this;
	[Export ("clicked")]
	void pause_clicked ()
		// Pause the button.

In MonoTouch we expose the "WeakDelegate" property as the weakly-typed version of the delegate, that means that you can assign to it anything that derives from the NSObject class, and respond to messages by just annotating your method with the [Export ("name")] attribute.

But weakly typing could introduce errors. What if the parameters of the method or the return value do not match the actual signature of the selector. If the developer introduce a typo, the compiler would not be able to point this out, and you would get a nice crash or some corrupt memory.

So we introduced strongly typed delegates, these require the programmer to implement a class and override methods that have a very specific signature. The code would then look like this:

class Foo : ButtonDelegate {
	void ConfigureButton ()
		button = new Button ("pause");
		button.Delegate = this;

	// strongly typed: override ensures that this method exists in
	// the base class, or the contract is not satisfied. 
	public override void pause_clicked ()
		// Pause the button.

The ButtonDelegate class is flagged with a special attribute, the [Model] attribute which informs the MonoTouch runtime that only methods that are overwritten from this class will be dispatched, any other methods will be considered optional and treated like optional methods.

The problem of course is that if you wanted to respond to multiple buttons, you would have to actually distinguish them somewhere in your pause_clicked with some sort of closure value, or use helper classes, one for each button that you want to respond to. But that is a minor detail.

So Objective-C developers that like the separation between model, view and controller can continue to use those patterns.

That being said, although there is a lot of literature and discussion about the clean separation of Models, Views and Controllers, most samples I run across are a hodgepodge of Controller code for all sorts of things. At least the production code and the samples I have seen make it obvious that the separation of concerns is mostly academic, and in practice an instance object becomes a general purpose responder to all events, very much like you see in Gtk+, Qt, or Winforms.

Our approach also has a limitation: the hodgepodge approach does not really work with the strongly-typed signatures as you can only derive from one class at a time. The solution is to use separate classes for each controller. Although that cleans things up and has some aesthetics associated with it in terms of clean separation of concerns, in my opinion, it is not very practical.

Supporting the C# style

With MonoTouch we wanted to preserve the C# style of programming where you could attach code to these notifications one-by-one.

With C# you can use anonymous methods or lambda functions. These are incredibly powerful as they are able to capture the environment in which they were created. This means that you can trivially pass information and share information between multiple handlers.

Additionally, you more than one method can "subscribe" to the same event, you are not limited to a single method being the receiving of the events.

This means that in MonoTouch you configure buttons like this:

void configure_button ()
	button = new UIButton (dims) { Text = "Pause" };
	button.Clicked += delegate {
		// Pause the video

What MonoTouch does internally is that the first time that you attach to a C#-like event, it create an instance of the ButtonDelegate that merely raises the event in the C# style.

This means that you only pay for the memory usage if you use the feature. But when you do, you can subscribe to individual events and you can have more than one listener attached to the event.

The Pattern

Although we brought the pattern to most places in MonoTouch where a delegate was used, it is notably missing from the UITableView as we felt that the number of methods that had to be overwritten were too big for the model to make sense.

In a few instances like UITableView, we suggest that developers just use the strongly typed version of the delegate classes and override the methods accordingly.

One of the things that I would like to see is a UITableView derived class that can present the data and style the data entirely based on properties discovered at runtime with System.Reflection.

Another thing that I want to see is support for System.Data data binding style versions of the UITableView and other UI controls in a single page.

More details on the low-level implementation are available on the API design document on the web site.

Posted on 15 Oct 2009

Git# - First Public Release

by Miguel de Icaza

Meinrad Recheis has lead the effort to bring a full managed GIT implementation to the .NET and Mono worlds and he just announced the release of GitSharp 0.1.3, the first public release of Git#.

The code is based on the original work from Kevin Thompson who ported the JGit Eclipse plugin to C#. Meinrad has put together a great community of contributors that integrated every JGit improvement, the credits for the first release are as follows:

  • Dave Cameron: for fixing bugs
  • Bj√∂rn Carlson: for killing bugs that crept into the core
  • caytchen: for porting huge parts of the transport layer, and hunting down nasty bugs. btw, what's your real name?
  • Emeric Fermas: for eliminating some of the hardest to find bugs and for verifying the complete test suite against jgit
  • Martinho Fernandes: for fixing bugs
  • Andriano Machado: for porting massive amounts of code and tests, also fixing many bugs
  • Jim Radford: for the continuous integration server account and the support
  • Gil Ran: for porting and fixing lots of tests and initial efforts on Mono
  • Dan Rigby: for porting and fixing tests
  • rolenun: for the command line interface framework. hey, what is your real name?
  • Mauricio Scheffer: for the testing and build server expertise and CI server trouble shooting
  • Neil Stalker: for holding up the flag for git# on Mono compatibility and squashing bugs
  • Kevin Thompson: for initially porting large amounts of code and letting me rise the baby

An easy to use API is being developed on top of the GIT core, check out some of the examples.

Posted on 12 Oct 2009

Your anthropological tidbit of the day

by Miguel de Icaza

In 1991 or 1992, I wrote a curses-based file manager for Unix, a clone of the DOS Norton Commander.

Unlike the Norton Commander, curses, xterms and Linux did not support the mouse. So I called my file manager "The MouseLess Commander".

Linux at that time was a cauldron of hot ideas. And Alessandro Rubini created a library for console applications to get mouse support on Linux. We worked to add mouse support to the MouseLess Commander and by the end of this exercise we renamed the file manager to "The MouseLess Commander With Mouse Support".

Somehow I was talked into changing the name of the Mouseless Commander with Mouse Support. Since I was pretty bad at naming, we organized a vote on the mailing list and eventually the current name "Midnight Commander" was picked.

I miss the previous name.

Posted on 06 Oct 2009

World Views

by Miguel de Icaza

Richard Stallman does not seem to have anything better to do than launch personal attacks against me. In his last piece he has decided to call me a Microsoft apologist because I do not participate in his witch hunt.

I merely happen to have a different perspective on Microsoft than he has. I know that there are great people working for the company, and I know many people inside Microsoft that are steering the company towards being a community citizen. I have blogged about this for the last few years.

At the end of the day, we both want to see free software succeed. But Richard, instead of opening new fronts to promote his causes, attacks his own allies for not being replicas of himself. To him, ridiculous statements like Linus "does not believe in Freedom" are somewhat normal [1].

A Matter of Perspective

A few years ago, I had the chance to listen to Benjamin Zander in person talk about his world of possibilities. His book "The Art of Possibility" had a profound effect on me.

Benjamin tells this story in the book:

Two shoe salesmen were sent to Africa in the early 1900's to scout the territory.

One telegraphed back: "Situation hopeless. Stop. No one wears shoes."

The other telegraphed: "Business opportunity. Stop. They have no shoes."

Since we only have a limited time on earth, I have decided to spend my time on earth as much as I can trying to be like the second salesman. Looking at opportunities where others see hopelessness.

This is why I love my work, because I work with friends that have consistently beat the odds and we have consistently proved our critics wrong. Because everyone that I work with wants to change the world and nobody I work with is dominated by fear.

Far too many times, fear has prevented people from coming up with creative solutions. I rather work on constructive solutions to problems than moan and complain.

Fear mongering is a vibrant industry, it is the easy way out for those that can not lead with the example. Create a bogeyman, make things up, lie, or tell half-truths, and demonize and you got a recipe to energize your base.

Richard's Fear Mongering

The documentary "The Power of Nightmares" is a fascinating view at the industry of selling "safety" to the scared population and how leaders like to scare people to push their own agendas. Richard's fear mongering is no different.

Richard Stallman frequently conjures bogeymen to rally his base. Sometimes it is Microsoft, sometimes he makes up facts and sometimes he even attacks his own community [2]. His language is filled with simple, George W Bush-eque terms like Good vs Evil, Us vs Them.

The creation of the CodePlex foundation was an internal effort of people that believe in open source at Microsoft. They have been working from within the company to change it. Working at CodePlex is a great way of helping steer Microsoft in the right direction.

But to Richard, this simply does not compute.

To Richard, the state of the world is hopeless. I on the other hand see possibility and opportunity.

Not only you attract more bees with honey than with vinegar, there are lots of shoes to sell.

[1] Plenty of attacks on other open source/free sofftware advocates/developers are readily googable.

[2] the "open source" vs "free software" non-issue and the "Linux" vs "GNU/Linux" wars of the 90's that haunt us to this day.


I am now closing the comments for this post. Feel free to move this to the Slashdot forum.

Posted on 05 Oct 2009

Feedback wanted: StackOverflow DevDays in Boston

by Miguel de Icaza

I will be presenting at StackOverflow DevDays in Boston, on October 7th at 4.20pm.

As usual, I will be talking about Mono. But since Mono is an giant universe, I would like to know what the audience would like to hear about.

Please fill in my small survey to provide feedback.

See you there!

Posted on 30 Sep 2009

Pictures: ECMA 334/335 January 2003

by Miguel de Icaza

At the ECMA meeting in January of 2003 Anders was presenting C# 2.0:

Todd Proebsting had just developed iterators for C# and was presenting, it was inspired by his previous work on Icon's iterators. Sam Ruby (from IBM), Thomas Plum (from Plum Hall) and Todd:

Anonymous methods, the foundation for lambdas in C#, used a beautiful code generation technique. Anders who has a beautiful hand writing was explaining the design to the committee:

Jim Hogg presented the design for generics in the ECMA CIL. Here he is discussing with Arch (at the time with Intel, and the guy behind ECMA's System.Parallelization), Jon Jagger and Emmanuel Stapf (ISE Eiffel):

Joel Marcey, then at Intel and Jim Miller:

Todd and Chris Fraser. I was fanboying them. Mono's original JIT design was based on a lot of his work. At dinner Chris recommened Csikszentmihalyi's book on Flow, which I loved:

Posted on 26 Sep 2009

Comment Policy on my Blog

by Miguel de Icaza

Here is a rough draft of the comment policy for my blog.

When you come to my blog to comment, you are a guest in my blog and your opinions are hosted there in the same way that you would be hosted if you showed up at my place to chat.

So standard rules of social engagement are required. If you are unable to operate under regular social situations and you feel the need to insult others or myself in my blog, not only you are not welcome, but your comment will not show up and will be promptly deleted.

Constructive criticism is always welcome on my blog, now

If you feel the need to be rude, offensive, lie or you are intentionaly trying to start a fight, I encourage to do that in your blog.

If you can not articulate your thoughts without attacking and you can not keep your temper in check, I encourage to do that on your own blog.

Trolling will be removed.

Posted on 25 Sep 2009

Branching for Mono 2.6

by Miguel de Icaza

Today Andrew branched Mono trunk for the Mono 2.6 release.

Mono 2.6 is the last release that will support the mscorlib 1.1 profile and the C# 1.0 compiler. We are now moving to a pure generics world with Mono.

Update: Specifically, we will be removing the 1.0 assemblies from the build, the mcs.exe command will now point to gmcs.exe, all of the xxx1 command versions will be eliminated and all of the conditional code in the Mono class libraires that depended on NET_1_0 and NET_1_1 will be removed.

As for the Mono 2.6 release notes: we will put those together in the next few days. Please be patient.

Posted on 25 Sep 2009

On Richard Stallman

by Miguel de Icaza

I want to say that God loves all creatures. From the formidable elephant to the tiniest ant. And that includes Richard Stallman.

As for me, I think that there is a world of possibility, and if Richard wants to discuss how we can improve the pool of open source/free software in the world he has my email address.

Love, Miguel.

Posted on 23 Sep 2009

« Newer entries | Older entries »