2

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

igouy
  • 2,547
  • 17
  • 16
Maik Klein
  • 15,548
  • 27
  • 101
  • 197
  • possible duplicate of [Embedding: mono vs lua](http://stackoverflow.com/questions/564480/embedding-mono-vs-lua) – laurent Jun 04 '12 at 11:27
  • checked your link and my question is different. I want to compare the language in general -> coding speed , perfomance, learning curve etc – Maik Klein Jun 04 '12 at 11:30
  • 2
    To me, those charts look like it's quite the opposite - C# is faster, and Lua consumes less memory. – Botz3000 Jun 04 '12 at 11:30
  • Oh you are right :x . Is this chart reliable ? – Maik Klein Jun 04 '12 at 11:33
  • 1
    @MaikKlein, I think it might depend on what you are trying to do, your experience with Lua and/or C#, etc. Benchmarks like the one from the link are not very helpful in general. – laurent Jun 04 '12 at 11:34
  • [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. – Maik Klein Jun 04 '12 at 11:40
  • @Maik Klein >>Is this chart reliable?<< The chart is a reliable summary of how much time and memory are used by those particular programs -- run with those inputs, run with those particular implementations of C# and Lua, run on that OS and that hardware. How much difference is there between those tiny programs and the way they are run, and the kind of program you are interested in? – igouy Jun 04 '12 at 14:47
  • Also, see LuaJIT http://luajit.org/performance_x86.html – igouy Jun 04 '12 at 14:51

2 Answers2

5

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.

Community
  • 1
  • 1
Thomas
  • 174,939
  • 50
  • 355
  • 478
  • I just asked this question because I have the possibility to use Lua or Mono for the CryEngine 3 [GameDevelopment]. I'm familiar with Mono, I just wanted to look for some advantages of Lua. – Maik Klein Jun 04 '12 at 11:59
  • 2
    Oh, why didn't you say so in the first place? http://stackoverflow.com/questions/564665/advantages-of-lua :) – Thomas Jun 04 '12 at 12:13
  • >>largely useless ... You should read the whole thing<< Yes, Maik should read the whole thing and see that it doesn't say it's largely useless :) – igouy Jun 04 '12 at 14:37
1

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.

Matten
  • 17,365
  • 2
  • 42
  • 64