Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you want to use C# if its slower than C++? [closed]

I'm looking for a new language to learn after C++ and Java. I was going to try C#, but a bunch of people say its really slow because its a high level language. So why would anybody use C#? Isn't C++ much faster? Does it make development easier, but just have a slower final product?

Also, what can C# be used for? You use it with a lot of .NET stuff on windows, and with ASP.NET, but what are other situations where one would use C#? Will there be a lot of job opportunities for it?

like image 284
Gordon Gustafson Avatar asked Apr 24 '09 20:04

Gordon Gustafson


2 Answers

Who exactly is this "bunch of people"? What are they comparing it against?

For the vast majority of things, C++ is not "much faster" than C#. It certainly has benefits in various situations, particularly where you want more deterministic memory handling, but in my experience the bottleneck in most applications isn't in places where C++ would help. As spoulson says, a lot of performance is in the design instead of the exact implementation - and there, it helps to be able to try different designs easily.

Why would we use C# when it's a bit slower than C++? Because it's generally reckoned (i.e. some disagree :) to be a lot easier to develop in without shooting yourself in the foot.

As for what C# can be used for... what do you want to use it for? Unless you want to develop drivers and kernels, it may well be fine for you. (Even OS development has some folks using C#...)

Job opportunities? Loads.

Downsides? Well, .NET itself is only available on Microsoft platforms. There's Mono, but it doesn't have quite the same degree of portability as Java (no doubt another "slow" language according to the same bunch of people).

like image 71
Jon Skeet Avatar answered Oct 03 '22 22:10

Jon Skeet


Code written in assembly can be blazingly fast. Why not just write in assembly?

Don't believe everything you hear. C# has been plenty fast for all my projects. Typically, performance is more a factor of design than raw platform performance.

like image 20
spoulson Avatar answered Oct 03 '22 21:10

spoulson