C++ or C#

samuelhogg

Well-known member
Messages
259
Likes
5
I want to start learning either C++ or C#. This would be for my personal use for programs like Ninja but I want it also to help me progress in my work life. Currently only working in fund administration and I hope with a basic programming knowledge along side the CFA I am studying that I would be able to achieve this.
What do people recommend, C++ or C#? I seem to find more jobs that quote C++ but I believe C# is a more up to date language.
Are there any good courses in the City?
Many thanks.
 
My understanding is that C++ is much more difficult to learn than C# but ultimately better depending on the requirements of the application being developed.


Paul
 
Difficulty is subjective. I don't think there is a single answer other than 'It depends'. If you are planning on working as a freelance software programmer then the choice is whatever you like best and feel most comfortable with. I like Visual Basic and VBA and find it ‘easy’ and intuitive, I struggle with C# but I haven’t devoted much time to it.

Take a look at

Rent A Coder: How Software Gets Done -- Home of the worlds' largest number of completed software projects

It might give you an idea of what types of language programmers are in demand.
 
It all depends on what types of applications you're planning to write. If you want to be able to write device drivers or other low-level things then C++ is the way to go. If you're focused on GUI and webbased applications and webservices and the like C# is definitely the way to go. There's not many things you can do in C++ that cannot be done in C# and the average development time in C# is lower.

Best regards and good luck,
Ruben.
 
Thank you for all comments. Thank you new_trader for the link.
GammaJammer here is my plan, I currently work in fund admin for an asset management in the city but I have desires to do more. I trade FX/index futures in the evenings when I get chance using basic TA but I let myself down by getting to emotionally involved and have poor money management skills. I would like to program some basic automated trading strategies for myself.
I want to get a more involved role in the city to learn more and meet like minded people, people who enjoy the stock market and not people just doing a job. I chose CFA (paying myself) as it will increase my knowledge and my salary, so I will be able to save to increase my trading capital. From searching I have noticed some roles requiring programming skills, I have a programming interested so I thought I could kill 2 birds with 1 stone.
I plan to move back to the NW in 2010/11, so I hope I will be able to find a half decent role up in Liverpool or Manchester with the CFA behind me. Also with the larger trading pot and knowledge, I hope I will be able to trade more successfully at home.
I will be using programs like Ninjatrader/Tradestation at home but I am not sure what will be required at different companies.
Thank you for all your advice.
 
I'm a professional C++ developer, C# is definitely flavour of the month at the moment in investment banks & at lot of new projects are utilising this language. However as my speciality is server side software which runs on unix/linux - c# isn't an option.

Personally I would recommend a beginner should go down the c# route as c++ is definitely not an easy language to master.

To be honest if you plan to take a more business oriented role in the banks I would suggest you learn excel VBA programming as you will find it a great asset in working with spreadsheets and large amounts of data in the bank and it's a skill that will be valued. Leave c++ and c# to the programmers.
 
I thought Visual Basic was redundant now?
I don't think you really meant "redundant" did you? M$ have kicked it into the long grass, but there are still zillions of VB applications, you just can't buy it any more. There are quite a few alternative BASICs around, the best IMO PowerBasic, best because it produces fast executables and has a very good users forum.
 
I used to do a ton of 'c' coding and have done some c++ in the past as well. For my home use, c# has served me quite well: it's a nice combo of the simplicity of Visual Basic and the object-oriented nature of C++. I'd go with c# versus VB, but I was always more comfortable with C, so that's just a personal preference.

I like the "C# for Visual Studio 2005 (or 2008)" books (I think they are SAMS publishing?). You can get them cheap off Amazon and they are great learning tools. The internet is great, but I like to have a physical copy at my desk as well and $39 or so is money well spent.

A great resource that I use for c# is the CodeProject website, as you can find lots of little cool tips/tricks with sample projects. The Visual Studio and MSDN help is good, but that's more as a reference guide, and not a learning tool.
 
If you just want to be able to code up your ideas quickly and see if how they work, definitely choose C#. It is much more flexible, has much better support for integration with other systems, and will be easier for you to use.

If however you'd like to actually become a good programmer and make quality software, I'd personally recommend C++ since you get a better understanding and appreciation for the more low level concepts like memory management and OS behaviour.

People tend to get into bad habits with C# since you don't really need to understand it properly to use it.
 
As with most things these days, programming is being dumbed down so you'll find that C# is rapidly gaining popularity. It's far easier to use than C/C++ and you'll find more and more jobs asking for it so I would go that route personally.

What you will find though is that C# is only programming at a superficial level and you'll never really learn deeply about the underlying hardware and lower level software stacks which will ultimately limit your capabilities as a developer.
 
Go for C#. C++ simply is not worth it in the trading envirnoment - and in most areas. Problem is: it is too slow. To program. Fast enough execution is good enough. C# is slower in execution, but this may not even be relevant, and you are a lot faster to program ;)

Keep awayfrom VBA - this is outdated, and people recommending it simply... have not kept up on what is current. You want to do excel work? Use C# ;) The same C# (not some funny variant) that you can use fo other things too. VBA is too limited in that it simply - is not stand alone. End of Life ;)

C# is perfect btw. for quite a lot of servers. IIS is written in C# except a small kernel driver (to handle the TCP request side - the interface to the driver is available in C#, this allows multiple programs to listen on one port and distribute requests per URL). As so often, the question is what is really needed - pretty often some % faster execution are mroe than offset by the easier programming (and thus ultimately the possibility to program more efficient code).

People tend to get into bad habits with C# since you don't really need to understand it properly to use it.

Stop joking. You should see some of the horrendous C++ code I have seen. Incompetents and idiots get everything wrong because they dont understand it. THis is absolutely not related to C# ;) Most people loose money trading - same thing.

C# makes a lot of things a LOT easier. Garbage collected memory management is really nice. FOrget the "easy to program easily". Being able to hand objects around and have them autoamtically collectable makes a LOT of caching and other architectures extremely easy. Naturally not too smart programmers (like the ones making NinjaTrader) get a LOT of things wrong. But seariously, most NInja proglems are not intrinsic to C# but simply... NInja issues ;)
 
Thanks for your comments gents. Strange how this thread has come alive again considering I started it almost a year ago. It's funny I haven't done anything regards to programming since I posted (new baby) and just recently I have been looking into it again.

Can anyone recommend a C# book? I have looked at Sam's, Wrox, O'reilly and the like all on amazon but they have mixed comments. Been to local book store to get a better feel for the book but all seem the same. Have been looking at the illustrated ones as I am more of a visual type of a guy and I like pictures :).
 
THen forget programming. It is about abstract concepts, NOT about pictures.

Depending on your skills you could do just with the language description as start ;)
 
Example of Simple Moving Average in Ninjatrader

//
// Copyright (C) 2006, NinjaTrader LLC <www.ninjatrader.com>.
// NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
//

#region Using declarations
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Xml.Serialization;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion

// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
[Description("The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.")]
public class SMA : Indicator
{
#region Variables
private int period = 14;
#endregion

/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Orange, "SMA"));

Overlay = true;
PriceTypeSupported = true;
}

/// <summary>
/// Called on each bar update event (incoming tick).
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
Value.Set(Input[0]);
else
{
double last = Value[1] * Math.Min(CurrentBar, Period);

if (CurrentBar >= Period)
Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
else
Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
}
}

#region Properties
/// <summary>
/// </summary>
[Description("Numbers of bars used for calculations")]
[Category("Parameters")]
public int Period
{
get { return period; }
set { period = Math.Max(1, value); }
}
#endregion
}
}

#region NinjaScript generated code. Neither change nor remove.
// This namespace holds all indicators and is required. Do not change it.
namespace NinjaTrader.Indicator
{
public partial class Indicator : IndicatorBase
{
private SMA[] cacheSMA = null;
private static SMA checkSMA = new SMA();

/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
public SMA SMA(int period)
{
return SMA(Input, period);
}

/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
public SMA SMA(Data.IDataSeries input, int period)
{
checkSMA.Period = period;
period = checkSMA.Period;

if (cacheSMA != null)
for (int idx = 0; idx < cacheSMA.Length; idx++)
if (cacheSMA[idx].Period == period && cacheSMA[idx].EqualsInput(input))
return cacheSMA[idx];

SMA indicator = new SMA();
indicator.BarsRequired = BarsRequired;
indicator.CalculateOnBarClose = CalculateOnBarClose;
indicator.Input = input;
indicator.Period = period;
indicator.SetUp();

SMA[] tmp = new SMA[cacheSMA == null ? 1 : cacheSMA.Length + 1];
if (cacheSMA != null)
cacheSMA.CopyTo(tmp, 0);
tmp[tmp.Length - 1] = indicator;
cacheSMA = tmp;
Indicators.Add(indicator);

return indicator;
}
}
}

// This namespace holds all market analyzer column definitions and is required. Do not change it.
namespace NinjaTrader.MarketAnalyzer
{
public partial class Column : ColumnBase
{
/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.SMA SMA(int period)
{
return _indicator.SMA(Input, period);
}

/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
public Indicator.SMA SMA(Data.IDataSeries input, int period)
{
return _indicator.SMA(input, period);
}
}
}

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
public partial class Strategy : StrategyBase
{
/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
[Gui.Design.WizardCondition("Indicator")]
public Indicator.SMA SMA(int period)
{
return _indicator.SMA(Input, period);
}

/// <summary>
/// The SMA (Simple Moving Average) is an indicator that shows the average value of a security's price over a period of time.
/// </summary>
/// <returns></returns>
public Indicator.SMA SMA(Data.IDataSeries input, int period)
{
if (InInitialize && input == null)
throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

return _indicator.SMA(input, period);
}
}
}
#endregion
 
Top