Home Jonas Albert Rafael Noam Grasshopper Dekel Yaacov Roei Philippe Tal
 
  

Where Mono fits into Grasshopper

August 8th, 2007 by Roy Osherove

One question that really bogged me about Mainsoft when I first heard about it was “Where does Mono fit in?”. What do I mean by that?

Mainsoft helps “cross-compile” your .NET Code into Java Bytecode. The process means you use .NET (Microsoft, not Mono) to write your code, but you compile to java bytecode using the Grasshopper addin and the Mainsoft project templates. All fine and dandy, for sure. But Mainsoft is also a big contributor to the open source .NET implementation on Linux called Mono. Where does contributing to mono fit into the Mainsoft business? more specifically, where is the technological dependency that requires Mainsoft to use mono as part of grasshopper? clearly, you don’t see mono as a .NET developer writing grasshopper enabled applications, so where can it be found in the process?

After a relatively long lunch discussion with Kosta (who’s blogged here before) the answer lies here:

  • One of the things Mainsoft does is create a .NET framework API written in Java
  • that API is used by your cross-compiled code when you compile it in visual studio 2005 (for example, when you add a reference to System.Xml in your Grasshopper project, you are actually adding two references - one for system.xml and the other is a jar reference to the system.xml implementation in java)
  • That API implementation had to come from somewhere. it is based on the Mono implementation of the .NET framework (no, we don’t use Reflector to copy .NET framework code. It’s strictly prohibited).

So, Mainsoft Contribute to the Mono Implementation ,and then implement the same thing in Java, based on the “reference implementation” found in Mono. That Java implementation is used and referenced from your grasshopper cross compiled applications, so that the APIs you use for System.Xml will transfer seamlessly into the Java world.

Here’s an image I made that I hope can help clarify this:

image

Update: As kosta explains in the comment, there is obviously a compilation step of mono to IL, and from that the java source code is generated. As he says (with my own little slant in there) “when developing mono we are effectively developing our own library references for the Java API as well”

Simple. Powerful. Any questions?

Share This
Related Posts

2 Responses to “Where Mono fits into Grasshopper”

  1. Konstantin Triger Says:

    There is no intermediate Java Source Code. To be precise, Mono Source Code (e.g. for Sys.Xml) is compiled to IL using standard MS C# compiler and then converted to Jar by Mainsoft converter. In some special cases we need some platform specific changes, we use PLATFORM_JVM, PLATFORM_J2EE defines for ifdef during initial compilation. For the rest, the Grasshopper runtime logic is exactly same as in mono runtime. Thus, by contributing to mono we actually develop our runtime libraries.

  2. Ted Burrett Says:

    I read your blog for quite a long time and must tell that your posts are always valuable to readers.

Leave a Reply

  
 

Close
E-mail It