• C++ Programming for Financial Engineering
    Highly recommended by thousands of MFE students. Covers essential C++ topics with applications to financial engineering. Learn more Join!
    Python for Finance with Intro to Data Science
    Gain practical understanding of Python to read, understand, and write professional Python code for your first day on the job. Learn more Join!
    An Intuition-Based Options Primer for FE
    Ideal for entry level positions interviews and graduate studies, specializing in options trading arbitrage and options valuation models. Learn more Join!

C# versus C++

Joined
12/16/08
Messages
3
Points
11
Sorry if this has already been asked somewhere, a quick search turned up nothing.

I'm completely new to the world of programming and want to pick it up to facilitate modeling in finance with an eye to potentially building trading algos later on. Since I am a blank slate without any real knowledge of programming, which should I pick up C++ or C#? Are they really all that different (I'm under the impression that the only difference is that C# is kind of like Java in that you don't need to watch memory leaks etc)? I read through the book reco's on the master reading list that Andy was so kind as to put together and noticed they were all C++ oriented in the programming portion.

Thanks for any and all advice.
 
C# - as well as other object-oriented languages such as C++ – is a descendent of the C programming language (K&R 1988). It is worthwhile to pause and consider whether it is better (in some sense) to develop new applications in C# or C++ (incidentally, it is possible to create .NET applications using a combination of C# and C++ but this topic is outside of the current ‘blog’). In order to help the reader determine how to choose between C# and C++ we discuss the problem from three perspectives:
P1: The skills and knowledge of those engineers developing QF applications
P2: The type of application and related customer wishes
P3: The technical, organizational risks involved when we choose a given language

We discuss each perspective in turn. First, C++ is a huge multi-paradigm language and it supports the modular, object-oriented and generic programming models. It is based on the C language and it would seem that it is the language of choice for many pricing, hedging and risk applications. It is not an easy language to learn; we liken it to a beast that must be tamed and cajoled. Furthermore, even though there are many books that discuss C++ and its syntax there are surprisingly very few books that discuss how to apply C++ to QF.
To this end, one of the authors (Daniel J. Duffy) has written two books that fill this gap (see Duffy 2004, Duffy 2006). C#, on the other hand is a relatively new language and it supports the object-oriented and generic programming models, but not the modular programming model. This implies that everything must be an object or class in C# which may not be to everyone’s liking. Not everything is, or needs to be an object. In general, C# is much easier to learn than C++. It shields the developer from many of the low-level syntax that we see in C++, in particular the dreaded pointer mechanism, memory management and garbage collection. In short, the C# developer does not have to worry about these details because they are automatically taken care of by the garbage collector. This is a mixed blessing in general because there are situations where we wish to have full control of an object’s lifecycle. It is surprising to us that C++ is not in more widespread use in the universities and places of learning given the fact that many of the investment banks in the City, Wall Street and other financial centres throughout the world may explicitly ask for C++ experience from potential employees. C++ is a vendor-neutral language (it is an ISO standard) while C# was originally developed by Microsoft for its Windows operating system.

We now discuss perspective P2. This perspective is concerned with the range of applications that C++ or C# can be applied to, how appropriate they are to these applications and how customer wants and needs determine which language will be most suitable in a particular context.
In general, customers wish to have applications that perform well, are easy to use and easy to extend. On the issue of performance, C++ tends to be more efficient than C# and tests have shown that C++ applications are 20% faster than the corresponding applications in C# in general. This difference may or may not be a critical factor in determining whether C++ is more suitable than C# in a particular context. We now compare the two languages from the perspective of developer productivity. In order to answer this question we need to define what we are measuring. C# has many libraries that the developer can use, thus enhancing productivity. C++, on the other hand does not have such libraries and they must be purchased as third-party software products. In particular, user-interface software for C# is particularly easy to use while in C++ the developer must use libraries such as MFC or OWL, for example.
In general, we conclude that productivity levels are much higher in C# than in C++. In some cases we have seen a three-fold productivity gain, all things being taken into account.

Finally, perspective P3 is concerned with the consequences and risks to the organization after a choice has been made for a particular language. C++ is a large and difficult language, it takes some time to master and C++ applications tend to be complex and difficult to maintain. By the way, this latter problem is not the fault of C++ but it is caused by bottom-up programming mentality and a premature implementation before a proper design was carried out. On the other hand, C++ will be with us forever and this implies that C++ code that works now will still function in 20 years time. With C# the situation is different. It is restricted to the Windows platform (in principle) and it may be superseded by some other language in the future. Of course, it may evolve into a language that will be embraced by both Linux and Windows programmers alike. Time will tell. To paraphrase James Joyce, we could say that “C++ has a great future behind it” and it will be up to the C# community to prove that C# is a viable alternative to C++ for QF applications. This is what we attempt to show in this book.

Daniel J. Duffy's Blog: Comparing C# and C++: which one should I go for in QF?
 
C# and .NET is very suitable for desktop applications in finance. A big plus is that it interoperates with Excel, XML and other external systems in an easy way. And there are lot of libraries you can use.

In general, productivity levels in C# are at least 3 times higher than C++. For example, a trader IR application is more suitable in C# than C++.

And the barriers to learning C# are lower than with C++.

"nice informative snippet!"
I plead guilty, I am the author of that piece :)
 
Back
Top