SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
futureoptions
Topic Author
Posts: 42
Joined: March 29th, 2010, 8:46 am

Quants : C++ vs. C#

September 26th, 2010, 7:07 am

Friends,Guessing this question might have been asked around several times, but I can't locate any answers. I realize that C++ is relatively faster then C#, and Quants trading desks still prefer to use the former to achieve low latency. However, job search sites are littered with Quant jobs with experience/background in C#. Both have a GUI interface so that isn#t an issue. C++ is of course known to be more difficult to master than C#. The latter does garbage collection and memory alloc/dealloc automatically and makes easier debugging than in C++.Problem is I know a little bit of C++ and a little bit of C#, and am facing a dilemma as to which of those two languages I should study indepth. Which of those two has greater longevity, and has an increased future demand in the Quants world? Going into depths of both C++ and C# isn't making the best use of my time, and also diluting my efforts. Most grateful for your views.Regards,S.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 26th, 2010, 8:02 am

Here's one answer->Prediction is difficult, especially the future It depends on your short-term and medium-term goals.Both C++ and C# are excellent languages. One issue which is important to note is that - all things being equal - the turnaround in C# is [3,4] times less than that of C++. And C#-Excel integration is relatively straightforward. It's just so easy to use.Your question on longevity: C++ will be with us forever. C# allows all-round developers to write applications without the hassle that you have in C++.I had a blog on this some time ago: blog C# versus C++ hth
Last edited by Cuchulainn on September 25th, 2010, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
futureoptions
Topic Author
Posts: 42
Joined: March 29th, 2010, 8:46 am

Quants : C++ vs. C#

September 26th, 2010, 9:15 am

Hi there/Dan,Thanks for your response. I found the blog very informative. In any case and even before reading your blog, I have been strongly inclined to stick with C++ than pursue C# (although the former is allegedly difficult to master, I am prepared to put in the efforts). Moreover, I have been through a week-long C# and .NET training last week, and I don't find C# to be a "serious" language (relative to C++). It might be easier to code in (with the Intellisense feature), but we're pretty much at the mercy of Microsoft's future strategy & marketing. Also, it allows less control as C++ does.However, what will really help finalize my decision is to know how easy it is to display charts/graphics at run-time in C++! In this instance, I am conducting an optimization exercise on an S&P 500 portfolio diversified with options & futures based on historical data (to start with). You can see that I don't need speed here as it's just an optimization exercise, and therefore I can use C++ or C#. But that is not a factor at all, as I personally prefer C++ anyway. My existing program in C (with some C++ code but very little) outputs pages of optimal weights vs. time frames in tabular form. Instead, I would like the C++ program to automatically display the data in a form a chart/graph at run-time. How easy is it to achieve this in C++? My guess is I might have to implement my C++ code on Windows Forms as opposed to Win32 Console to achieve this? Most grateful for your insight.Regards,S.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 26th, 2010, 9:48 am

You're welcome.Regarding charting; there are zillions of options but seeing the preference for C++ some options are GDI (C++ library, I have not looked for a while) and what might be useful is the QT package from Nokia that has lots of stuff and seems to be really at the forefront of C++ technology. It can be used for big screens right down to those modern walky-talky devices. The event notification patterns in QT might be useful as well? Interesting to see that Trolltech (QT inventor) was also the inventor of Boost Signals and Slots.Qt Another option is a CLI wrapper on a super C# package but that could be a lot of work, depending on how much functionality you want. It's not difficult but just tedious.
Last edited by Cuchulainn on September 25th, 2010, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
futureoptions
Topic Author
Posts: 42
Joined: March 29th, 2010, 8:46 am

Quants : C++ vs. C#

September 26th, 2010, 3:22 pm

Thanks again. Can it not also be achieved by using Windows Forms for C++ as opposed to using Win32 Console? I ask out of ignorance. Thanks in advance.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 26th, 2010, 3:34 pm

QuoteOriginally posted by: futureoptionsThanks again. Can it not also be achieved by using Windows Forms for C++ as opposed to using Win32 Console? I ask out of ignorance. Thanks in advance.You can call C# from umanaged C++, no problem. This note might be useful.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
renorm
Posts: 886
Joined: February 11th, 2010, 10:20 pm

Quants : C++ vs. C#

September 26th, 2010, 7:55 pm

Garbage collection is overrated and has nothing to do with debugging. It helps only with memory leaks, which is not a big problem anyway. In C++ automatic garbage collection can be delegated to smart pointers and allocation/deallocations to library containers. You can avoid explicit memory management, if you want. For example, QuantLib has about 100K lines of code and 0 delete operators. Consider pointers and explicit memory management as a bonus, not a burden.In Java/C# everything except POD (plain old data: int, double, char, etc) is handled by reference, something similar to smart_ptr. I have a feeling, that it can be a scalability bottleneck in multicore environment. In reality, garbage collection could be a liability, not an advantage.Regarding multithreading. OpenMP is very easy to use and supported on all major platforms. TBB is fancier, but more flexible then OpenMP. IMHO, TBB is better then Java's concurrency. C# 2010 has improved support for parallel programming. But multithreading takes you closer to hardware, which inevitably leads back to C/C++.C++ is richer and more expressive then Java/C#. If you want to master all of it, the learning curve can be very steep. But if you stick to 80/20 rule (80% of time you need only 20% of features), the learning curve similar to that of Java/C#.
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Quants : C++ vs. C#

September 26th, 2010, 11:14 pm

I recommend focusing and getting good at C++ first then have a look at C# when you are quite comfortable with C++. Then it's like Diet C++ but of course you'll need to spend time learning .NET at that point.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 27th, 2010, 8:12 am

QuoteOriginally posted by: HansiI recommend focusing and getting good at C++ first then have a look at C# when you are quite comfortable with C++. Then it's like Diet C++ but of course you'll need to spend time learning .NET at that point.The 'sugar' is..?
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Quants : C++ vs. C#

September 27th, 2010, 8:34 am

QuoteOriginally posted by: CuchulainnQuoteOriginally posted by: HansiI recommend focusing and getting good at C++ first then have a look at C# when you are quite comfortable with C++. Then it's like Diet C++ but of course you'll need to spend time learning .NET at that point.The 'sugar' is..?None, just more calories
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 27th, 2010, 9:34 am

QuoteOriginally posted by: HansiQuoteOriginally posted by: CuchulainnQuoteOriginally posted by: HansiI recommend focusing and getting good at C++ first then have a look at C# when you are quite comfortable with C++. Then it's like Diet C++ but of course you'll need to spend time learning .NET at that point.The 'sugar' is..?None, just more calories What is a big pity is no operator overloading support for generic classes (==> use Reflection to emit code )
Last edited by Cuchulainn on September 26th, 2010, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
quantmeh
Posts: 5974
Joined: April 6th, 2007, 1:39 pm

Quants : C++ vs. C#

September 28th, 2010, 2:54 am

forget C++, you're too late to a party.
 
User avatar
Cuchulainn
Posts: 62626
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

Quants : C++ vs. C#

September 29th, 2010, 8:10 am

QuoteOriginally posted by: quantmehforget C++, you're too late to a party.Very hard to say. C++ is used in many domains, so it is a very useful skill to have. It is generic. Other languages ==> stereotyping??? It is very hard to find good C++ programmers in certain fields.
Last edited by Cuchulainn on September 28th, 2010, 10:00 pm, edited 1 time in total.
Step over the gap, not into it. Watch the space between platform and train.
http://www.datasimfinancial.com
http://www.datasim.nl
 
User avatar
renorm
Posts: 886
Joined: February 11th, 2010, 10:20 pm

Quants : C++ vs. C#

September 29th, 2010, 8:28 am

I have IT friends who think that C++ is ancient and that Windows Vista was written entirely in C#. And don't even mention them Knuth's book. Oh, kids these days!
Last edited by renorm on September 28th, 2010, 10:00 pm, edited 1 time in total.
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Quants : C++ vs. C#

September 29th, 2010, 9:01 am

QuoteOriginally posted by: renormGarbage collection is overrated and has nothing to do with debugging. It helps only with memory leaks, which is not a big problem anyway. In C++ automatic garbage collection can be delegated to smart pointers and allocation/deallocations to library containers. You can avoid explicit memory management, if you want. For example, QuantLib has about 100K lines of code and 0 delete operators. Consider pointers and explicit memory management as a bonus, not a burden.What's my best option to learn this correctly? Tutorials? Books (doubt it)? Reading through open-source source code?@Daniel: I know your new book contains a short chapter on smart pointers might that be a good option?
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On