Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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#?

like image 774
ApprenticeHacker Avatar asked Jun 28 '11 15:06

ApprenticeHacker


People also ask

Why is C# slower than C++?

C++ is considered a native language because it compiles directly into machine code that can be understood by the underlying system. C# must first compile into Microsoft Intermediate Language (MSIL) before the just-in-time (JIT) compiler generates machine code. For this reason, C++ is typically faster than C#.

Which is faster C# or Go?

C# is more powerful than Go but slower than it mostly because it has heavier features while Go is lightweight. Go has a simpler language that allows it to run fast, whereas C# excels in specific environments.

Why is C# faster than Python?

As a compiled language, C# converts directly into machine code that a processor can execute. No interpreter needed. In some cases, this means that C# code can run up to 44 times faster than Python. And whilst you can speed up Python's performance significantly with PyPy's JIT compiler, C# still holds its lead here.

Is .NET a good programming language?

It's a popular free platform currently used for a lot of different types of applications as it provides the programming environment for most software development phases. . NET best suits businesses that look for a wide range of features like web-based services, desktop software, and cloud infrastructure support.


1 Answers

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.

like image 165
Rafe Kettler Avatar answered Sep 23 '22 18:09

Rafe Kettler