C# software performance RRS feed

  • Question

  • User-1350516731 posted

    Hello all!

    Does the Microsoft work on the .NET programs performance and C# functionality to beat C/C++?

    Thank you. 

    Saturday, September 5, 2020 4:22 AM

All replies

  • User475983607 posted

    Does the Microsoft work on the .NET programs performance and C# functionality to beat C/C++?

    Your question is very vague and it makes an assumption that there is a mysterious problem.   Both C# and C/C++ are used to write programs.   The first step is sharing the C# and C/C++ programs you've written.  Please define the performance measurement and the test you are using to measure performance.

    For example, given an MVC application written in C# and C/C++, the C++ response is X seconds while the MVC is X seconds.  Please do not make the community guess what you're asking.

    Saturday, September 5, 2020 11:49 AM
  • User-474980206 posted

    MS does work on .net performance. But the performance of an app is typically the skill of the developer more than the compiler. Because C/C++ uses a stack and a heap it has predictive performance unlike C# which uses a GC.  Also the language will not make network, database  or file I/O faster. 

    but in general a skilled developer can write more performant code in C/C++ due to the simpler data structures and memory allocation.

    modern languages with the performance of C/C++ are rust, go and swift (which all use the same c compiler tool chain)

    Saturday, September 5, 2020 3:37 PM
  • User303363814 posted

    Of course.

    If you worked on the C# team wouldn't you want the result of your work to be better than everyone?

    And the C++ team work to beat the c# team.

    And the F# team work to beat the VB team

    And the VB team work to beat the Python team

    And the Python team work to beat the VB team

    And the Typescript team work to beat the F# team

    etc, etc, etc

    Saturday, September 5, 2020 10:11 PM
  • User-474980206 posted

    that not really how it works.

    for example, c#, vb, and f# all use the same compiler, just different lexical analyzers. but C# & F# added support for unmanaged types, which if the application has a use case for, is faster than managed types.

    compilers fall into groups 

    system languages, which compile to machine code and support low level operations and datatypes. these languages are designed to write operating systems. some examples are C/C++, objective-c, swift, rust and go.  on linux and os/x these all use the same compiler tools. the performance difference is typically the runtime and data binding. Microsoft uses their own c/c++ compiler, so they are competing with the osx/linux c/c++ compilers. for example windows and linux are written in c/c++ and os/x is written in objective-c. rust and go are used to write cloud services.

    high level compiled languages. these are high level languages that are compiled directly to machine code, but don't support low level operations required to write system code.  examples are cobol, pascal, fortran, algol, ada.

    vm languages with a GC. these are languages that compile to a VM and use a GC. some examples are c#, vb, f#, java.  its common to add JIT compiler support to these languages, so that the performance is more limited by the GC, memory allocation and support of low level data structures.

    interpretive languages with. these languages support dynamic code. some examples are python, ruby, javascript, lisp, smalltalk. again many of these are supporting JIT compilers (javascript). 

    as compiler optimization is pretty well known, the performance of a language is more the data structures its supports and memory allocation and deallocation.

    also the hosting framework can make a big difference. while C# is generally faster than javascript, classic asp.net (webforms and MVC) was an order of magnitude slower than node.js web applications (when well written). one of the goals of asp.net core was to be faster than node.js. it started by using the same hosting framework as node (written in C). then unmanaged types were added to C# so the node library could be replaced with one written in C#. so asp.net core is now faster than node.js



    Wednesday, September 9, 2020 3:55 PM
  • User753101303 posted

    According to  https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-5/ they still work on improving performance for .NET 5.

    Even thiugh have also a look at https://ericlippert.com/2012/12/17/performance-rant/. I saw once someone suggesting to avoid method calls because he found they are much slower than doing nothing at all !!!!

    Wednesday, September 9, 2020 6:23 PM