Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding: mono vs lua

I am interested in hearing about peoples experience with embedding mono (open source implementation of .NET) in a C/C++ application. How is it to distribute such an application and what are the dependencies? I have tested on OS X and mono comes as a huge framework (hundreds of MB). Do users of my app all need this big framework or can it be stripped down or everything be compiled into the main executable.

I previously have experience with embedding Lua in a C++ app, and that works really well because I can link statically the whole lua interpreter in with my main executable. So I have no external dependencies. Is it possible to do something similar with mono?

Any Lua people here who can comment on how they found mono compared to Lua?

PS: By embedding I mean a C++ application which initializes a mono environment and loads a .NET assembly and executes it and then allows for communication between say C# code in assembly and C++ methods in main executable.

like image 446
Erik Engheim Avatar asked Feb 19 '09 09:02

Erik Engheim


2 Answers

You should probably also take a look at Mono's Small Footprint page that describes how you can embed a smaller runtime. Heck, they do it themselves with Moonlight.

I hope that helps.

like image 70
Dave Van den Eynde Avatar answered Sep 22 '22 15:09

Dave Van den Eynde


This is 2 years old question. So situation may become different now.

For me, most important point was GC. I embedded Lua for interactive-apps and games, because incremental GC required. Currently Lua 5.1 has precise, incremental GC, but I couldn't found any proof of incremental or precise GC on Mono. So memory will leak (even it's very tiny!), and apps will struggle intermittently.

People says GC pause can be solved by tuning some parameters and pooling objects, but as I experienced, It never be solved without any kind of distribution GC load over time approach in GC. Generational GC is one of distribution algorithm, but it's too rough, and almost not helpful.

Because you can't control lifetime pattern or reuse instance by pooling the objects used in code that not yours. (such as basic class library)

So I don't recommend the C# platform (Mono or .NET, at least yet) for interactive/(soft)realtime apps.


Edit

I don't know whether any incremental/concurrent approached GC is presented on Mono or .NET. If you can sure about they offer the kind of GC, of course, it's fine to use :)

like image 25
eonil Avatar answered Sep 24 '22 15:09

eonil