Comparing Lua with Mono

4.6k views Asked by At

I wanted to do some research but i could not find any information about this topic.

The only information that i found -> http://benchmarksgame.alioth.debian.org/u32/compare.php?lang=csharp&lang2=lua

And I'm not sure how i can interpret this chart. If I'm right it basicly says that Lua is 10times faster than Mono. But Mono's memory usage is ~8 times better than Lua.

What does this say about perfomance ?

Comparing Lua with Mono -> Advantages/Disadvantages

Edit: [Gamedevelopment] Cryengine 3 uses c++/lua atm. But some guys releasing a mono port for this engine. I'm very familiar with Mono. But now i wanted to do some research on Lua to see if its worth to learn this language or if I should stick with Mono

2

There are 2 answers

3
Thomas On BEST ANSWER

You're comparing apples to oranges. C# is a statically typed language, compiled to CIL which is a bytecode language, run (or usually JITted) by a virtual machine, and used for web and standalone application development. Lua is a dynamically typed scripting language typically run by an interpreter, often embedded as an extensible scripting language into a larger application.

Also, your interpretation of the benchmark is wrong. The bar chart shows that the Mono program takes around 1/10th of the time to run compared to an equivalent Lua program.

That said, this kind of microbenchmark is largely useless. Don't take my word for it; read what the Shootout itself has to say about it. You should read the whole thing, but I'll pull out some juicy citations:

"The performance of a benchmark, even if it is derived from a real program, may not help to predict the performance of similar programs that have different hot spots."

"It may seem paradoxical to use an interpreted language in a high-throughput environment, but we have found that the CPU time is rarely the limiting factor; the expressibility of the language means that most programs are small and spend most of their time in I/O and native run-time code."

"Programming languages are compared against each other as though their designers intended them to be used for the exact same purpose - that just isn't so."

Long story short: select your language based upon whether it does well at what you want to do with it, whether it lets you express your intent clearly, whether it lets you write clean, maintanable code; not based upon some largely meaningless numbers.

2
Matten On

This says: Apples are greener than bananas.

You can't just say something like "Lua consumes less memory than C# but takes about 50% more CPU cycles". You have to compare them in respect to your context, e.g. what you want to build.

When you want to calculate 5*5, okay, Lua may be faster (in terms of implementation). But if you want to build an ERP-application with many clients, I wouldn't recommend Lua.

So we can't give you a definitive list of advantages and disadvantages, because it heavily depends on what you want to do.