[Mono-dev] New Language Integration

Rafael Teixeira monoman at gmail.com
Mon Jan 11 13:42:05 EST 2010

I'll try to summarize it:

The Mono VM is basically the same for all the platforms supported.
There's just some IFDEFs around, mostly in the native code part, for
MacOSX, and configuration macros to enable building it for that
platform (OS plus CPU choices);

The native part of Mono, is contained in a big library (libmono), and
contains, among others,  three fundamental pieces:
1) an OS abstraction layer
2) the JIT (Just In Time) compiler that translates IL to native code on the fly
3) the GC (Garbage Collector) that manages memory allocated to hold
objects' contents.

Above this native underpinning lies the biggest part of Mono, it's
class library, which is mostly managed code written in C#, or managed
wrappers over native libraries. This part is huge I mean more than 3
million lines of C# code, taking comments out (see

Particularly for MacOSX, the P/Invoke mechanism that enables easily
wrapping native C code was used to further build integration with
Objective-C, allowing wrapping of Objective-C objects and use of its

MonoDevelop has also a layered design with a platform layer that tries
to abstract some OS specifics like having the Out-Of-Window-Top-Menu
in the Mac and the In-Window-Main-Menu in Linux and Windows.

If your desire is to write a new language that works in Mono, you can
almost forget to deal with MacOSX specifics, and just code against the
class library that abstracts the OS and CPU and makes your code
binary-portable both the code in your compiler as the code it
generates when compiling. That is what I recommend you to do, unless
you are trying to do an "Objective-C#" type of language that would try
to integrate more easily with Objective-C libraries and frameworks,
and so would be platform-specific.

Another thing not clearly stated in your questioning is if you would
like to also integrate your compiler/language in MonoDevelop, to
enable developing applications/libraries written in your language
using MonoDevelop's IDE. That is kind of another project to develop an
Addin that can be installed in MonoDevelop to support your language.
This addin can be developed with any managed language, including your
own, and can range in features from simple templating of projects and
building integration, to full code completion on editing and GTK#
designer integration.

Well know I invite your to Google Mono's and MSDN's sites on the key
subjects I outlined above, and start some new threads on the list with
some more specific questions.

Have fun,

Rafael "Monoman" Teixeira
"To be creative means to be in love with life. You can be creative
only if you love life enough that you want to enhance its beauty, you
want to bring a little more music to it, a little more poetry to it, a
little more dance to it."

On Mon, Jan 11, 2010 at 3:37 PM, London Disney
<disney.london at googlemail.com> wrote:
> @ Rafael
> Thanks for the information. It was very useful indeed.
> I'll need to learn about the IL, which I think I can find lots of
> resources out there.
> But I also like to understand, a bit more, how the Mono VM for
> MacOSX works; could you show me what resources are good please?
> The Mono Hackers page on the wiki is very old...
> I can start building the VM but then that doesnt give me much
> information about the design ?
> On Mon, Jan 11, 2010 at 4:34 PM, Rafael Teixeira <monoman at gmail.com> wrote:
>> Hi London,
>> First answering your latest question: Yes, Monodevelop is mostly written
>> in C#.
>> Back to what I could understand as your main question:
>> To write a compiler for a new language that will run on Mono/,NET, you
>> can:
>> -1- Write it in C#, or another Managed Language. The main advantage
>> here is to have access to libraries that already do the hard work of
>> generating the binaries (IL code) that your compiler should produce.
>> Additionally if you choose C#, you can look at some good compilers
>> already written with like Mono's own C# compiler (mcs) or Boo's
>> compiler (booc).
>> -2- Write it with some non-managed but well supported language, like
>> C/C++/Objective-C/Java. It is quite harder to generate managed-code
>> binaries this way.
>> -3- Write it with your own language (that was what we at Mono did with
>> our C# compiler), but that mandates that you have some other compiler
>> for your language available to "bootstrap" the process (we used MS's
>> csc in Windows until the point that mcs could compile itself at which
>> point we switched to use a previous stable version of mcs to build the
>> newer versions).
>> For a totally new language, you probably could use a mix of 1 and 3:
>> build a minimal compiler in some stable language and them use it to
>> build a compiler in your own new language. That was the intent with
>> Boo, but AFAIK Boo devs could not find time yet to migrate the
>> compiler from C# to Boo, itself.
>> Another take on an educational project, you could use Boo
>> extensibility features to cook a derived-tailored-improved language
>> (Boo makes it easy to write DSLs Domain Specific Languages).
>> Hope it helps,
>> Rafael "Monoman" Teixeira
>> ---------------------------------------
>> "To be creative means to be in love with life. You can be creative
>> only if you love life enough that you want to enhance its beauty, you
>> want to bring a little more music to it, a little more poetry to it, a
>> little more dance to it."
>> Osho
>> On Mon, Jan 11, 2010 at 7:56 AM, London Disney
>> <disney.london at googlemail.com> wrote:
>> >
>> > That thread has lots of useful information actually but I might
>> > have confused you. We use Mono/C# to make addins don't we?
>> > I like to go a bit deeper to C/C++/ObjC level in MacOSX.
>> >
>> > What I was asking in my first email was something mentioned
>> > in this page:
>> >
>> > http://www.mono-project.com/Contributing
>> >
>> > at the end it says "The educational way is an interesting one...".
>> >
>> > I was looking for an "educational" project and so my question
>> > was if you could show me a road map to get started on something
>> > like that.
>> >
>> > I am interested in "a compiler for a new language" but
>> > "Mono VM extensions in C" or
>> > "improving Mono performance" are also very educational...
>> >
>> > Let me put it this way: How did you write C# itself before it existed ?
>> > That's what I like to learn.
>> >
>> > I guess my source of confusion is that MonoDevelop is written
>> > entirely or mostly in C# ? Is that right ?
>> >
>> >
>> > On Mon, Jan 11, 2010 at 5:34 AM, Michael Hutchinson
>> > <m.j.hutchinson at gmail.com> wrote:
>> >>
>> >> On Sun, Jan 10, 2010 at 7:47 PM, London Disney
>> >> <disney.london at googlemail.com> wrote:
>> >> > @Michael
>> >> > Hi
>> >> >
>> >> > I'm not intending to be a Mono user. Getting involved with Mono
>> >> > and MonoDevelop under MacOSX is what I am after.
>> >> >
>> >> > I chose implementing a front-end because it can get me involved
>> >> > a lot -- or may be I'm wrong? This can, say, tell me how to alter
>> >> > some part of the implementation to suit my needs.
>> >> >
>> >> > So do you have a better suggestion ?
>> >>
>> >> Just to clarify, do you mean a MonoDevelop addin as a frontend for an
>> >> existing language, or a new compiler?
>> >>
>> >> If the former, you may find
>> >>
>> >>
>> >> http://lists.ximian.com/pipermail/monodevelop-list/2010-January/011003.html
>> >> useful (and the preceding thread on the MonoDevelop list).
>> >>
>> >> --
>> >> Michael Hutchinson
>> >> http://mjhutchinson.com
>> >
>> >
>> > _______________________________________________
>> > Mono-devel-list mailing list
>> > Mono-devel-list at lists.ximian.com
>> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
>> >
>> >
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list