Search code examples
c#.netperformanceprogramming-languages

Why do .net languages vary in performance?


I have heard that C++ .NET is fastest , C# is next, followed by VB .NET and Languages like Iron-Python and Boo come last in terms of performance. If all .NET languages compile to intermediate byte-code which is the same, why the difference in performance?

It is understandable for Boo and Python as all the types have to be evaluated at runtime. But why the difference between languages like C++ and C#?


Solution

  • Python performs worse because it is interpreted, not compiled. Instead of being converted to CIL (common intermediate language) before being run, it is converted at run time, which obviously will incur performance overhead.

    Also, since IronPython is dynamically-typed, fewer optimizations can be made when compared to statically typed languages (which C++, C#, and, despite the Pythonesque syntax, Boo as well, are).

    You also have to consider the amount of effort put into making optimizations to each implementation. C# and C++.NET have huge teams at Microsoft working on making their compilers produce the fastest bytecode possible. IronPython and Boo are volunteer projects that don't have nearly as much manpower or resources, so they won't gain optimizations as quickly as something MS-funded.

    Essentially, language features can have performance/memory costs at both compile-time and runtime. That is why .NET languages vary in performance; because they vary in features.