What is the advantage of C# compared to C++?

  • Thread starter Thread starter Eric.Z
  • Start date Start date
Joined
12/13/11
Messages
83
Points
18
I have some experience with C++. Is it necessary to learn C#? What is the advantage of C# compared to c++?
 
C# is not hard to learn if you already know C++. I am not an expert, but I use C# quite a bit for work, and from what I can tell the big advantage is automated garbage collection.

So I don't spend as much time in C# (if any) thinking about pointers or explicitly freeing memory.

From a career development standpoint, I think some notable posters here have written about the importance of understanding pointers and memory allocation. What I've found is that when you are dealing with problems where complexity / memory issues are not a bottleneck, C# is a much easier sandbox to build in than C++. However, I don't have an extensive knowledge of the STLs in C++ and I've seen the opinion that the containers in the STLs provide more flexibility than C#.

C# is often compared to Java in this regard.

The lack of memory bottleneck doesn't necessarily mean the problem or application is simple; the processors on computers have become very powerful and RAM capacity has grown very large, so many things people worried about in coding ten or fifteen years ago can be gotten around with brute force on today's machines.

Bottom line is that C# should not be a problem for you to learn if you know C++. Is it necessary to learn? I'm not sure, but it is certainly a useful tool and given the similarity to C++, there's no harm in learning it.
 
From what I understand, and please feel free to correct me where I'm wrong -- a lot of buy-side shops (specifically algo shops) tend to lean toward C++ in usage, whereas a lot of smaller brokerages might end up using C#. Depends on what you want to learn and where you want to take it I guess. C# was favored in smaller shops just because of more libraries, and not having to deal with garbage collection (as much) as Jose stated above.

It's quicker for teams to implement solutions with C# (more libraries available), but C++ is considered to have some advantages in speed. In addition, memory usage can be a bit of an issue in C#. A large portion of this is relative though. Whereas some languages are better in certain situations, a lot of it depends on the programmer/team doing the work, ie. if the programmer knows Boost really well, C++ becomes even more effective for a lot of uses.
 
I don't really buy the "more libs available in C#" part as far as quantitative finance is concerned.

Sure, if you're writing an "enterprisey" app then XML and GUI libs in C# are going to come in handy.
On the other hand, it's my impression (correct me if I'm wrong) that as far as numerics are concerned (numerical linear algebra, (pseudo|quasi)-random number generation, numerical optimization, numerical differentiation & integration, solving ODEs/PDEs, etc.) most of that is available for C++ with several high-quality implementations to choose from. This is important, since more choices allow you for a finer tuning considering various trade-offs involved -- consider just numerical linear algebra, where the ease of use, availability of sparse matrices, support for distributed computing, GPUs, license, interoperability with other libraries, quality of documentation, performance for task X, performance for task Y are *all* valid choice variables, as considered here. Is there a similar variety of numerical linear algebra libs for C#?
 
C++ is the language of choice indeed for hard maths.

These C++ libraries are often not well documented enough for the busy/average developer which can be offputting.

But, Microsoft integrates its tools and libraries into an easy-to-use whole.

So, it all depends on the applications.

I like both, for different reasons.
 
I once used ADO to connect Oracle database in C++. It seems more inconvenient than that in C#. No idea about other aspects.
 
Back
Top Bottom