C++ vs. C#

emk

Newbie
Messages
3
Likes
0
Hi All,

I would like to know if someone knows the advantages and disadvantages of the C++ and C# programming languages.
 
Comparison between C++ and C#. Some says C++ is harder to learn, but it is more flexible and robust than C#. Is there any other thing that I should know?
 
C++ does not come with garbage collection.

C# if you love Microsoft.

Otherwise it has to be Java.
 
Wrt IT in the City, I'd say it's still it's C++ for the hardcore analytic libraries with C# being what you write the front end in.
 
emk said:
Comparison between C++ and C#. Some says C++ is harder to learn, but it is more flexible and robust than C#. Is there any other thing that I should know?

Yes, lots. But first a disclaimer. I am not a C# programmer, but I have a decent knowledge of Java, have spent a quite a number of years as contract C/C++ programmer, worked as a third level tech support manager, have a degree in CS etc.

1. C++ is not just harder to learn, it is MUCH harder to learn.

2. C# is very much a derivitive of Java. Most things that can be said of Java can be said of C#, with the exception that Java is cross platform and backed by the likes of Sun, IBM, Oracle, BEA etc. Java is also open source.

3. C# and Java are "managed environments". They compile to so called byte code not to native machine language. A virtual machine machine executes the byte code. The JVM has become quite sophisticated, performing on the fly optimization etc, often giving performance that is not far short of C++ code. Because the VM controls execution many programming errors can be trapped and managed. Similar errors in C++ code would cause a crash. Code executing in a VM is generally more secure, and not vulnerable to a lot of the techniques (such as buffer overflow) used to attack code written in C or C++.

4. Following on from point 3, applications written in C# or Java are likely to be more robust than C++ - especially code developed by a novice programmer. Development time is likely to be shorter, and there is likely to be fewer of the really pernicious bugs that can occur in C/C++ code.

5. For nearly all applications, C++ is not more flexible. You will not be constrained by limitations in the C# or Java languages. If one is talking about operating system kernel development, then it's a different story, but for applications C# or Java will nearly always be quite adequate.

To sum up, I really can't see any good reason to begin to learn to program in C++. You will find it initially hard enough, without the complexity of C++. I'd recommend getting a Linux box and using Java (or perhaps even easier Python). That way you will learn a little about operating systems too, which is not going to happen by clicking buttons in Windows. Both Java and Python are completely free and open source and will run on Linux, Windows, MAC etc.

If you want to start fiddling around there are very good free Java IDEs at

http://www.netbeans.org

http://www.eclipse.org
 
Excellent post dcraig. The only two things I would add to your post are:

1) If you are planning any sort of gui frontend for your program then you would be completely mad having never programmed before to use C++/MFC. C# or Java is definitely the better way to go. I personally still find Java gui's to not be as flexible or as easy to use as .NET developed ones but maybe thats a personal thing.

2) The only downside I can think of for using C# is for performance critical applications. It is true that for 95% of programs C# is going to be fine but if you have a lot going on and performance is very important then getting equivalent performance out of a C# program versus a C++ one may be almost impossible without very in depth knowledge of the .NET CLR platform.

Also as a final thought you can get C# Express for just as good a price as Java or Python (i.e free) from microsoft to get started with.

Best of luck!.
 
Unless you're a very experienced programmer stay away from C++. It's a large, complex language, and you have to manage the memory usage yourself. Expect to spend a significant amount of time fixing memory issues. Bottom line: a great deal of power but all too easy to scuttle yourself.

The performance argument is overdone. CPU power and memory are cheap to add.

Java or C# should be the first choice languages - droves of professional programmers have moved on from C++ to these. Other possibilities are Python or Ruby.
 
or even vb.net .... it has the same power'ish, but easier to learn.

I've been coding with C# and Vb.net for some years now and say as your a non coder (which I presume you are otherwise you wouldn't be asking these questions) go with VB.NET.

Stay away from C++, it'll take years of constant use to gain experience to do anything financial related ...
I've over 10yrs experience with C++ and still learning !!!
 
Thank you all for the comments and suggestions. I have a little experience in programming (Excel VB), but now I need to have a more powerful tool to process a lot of data.

I also have another question regarding to database. Many advise me to use SQL. Anyone have any comment about it?
 
Don't listen to them. _Real_ programmers use C++ everywhere. It is not that hard to learn and it is not big at all. But it is flexible and it gives you the full control over the program you write. Also by being C++ programmer you will be able to use/learn any language if the need arises. I am primarily C++ programmer and occasionally need to use Java, Perl, xslt, SQL and even assembler - it all comes easily whenever I need something to be done in these languages. Knowing C++ gives you an understanding of programming of any kind (except may be something like Prolog or Lisp - but that is not for finances anyway).
The biggest drawback of using "application" type languages like C# or Java is that you very often don't have any control over some features/bugs in your application. When you use ready-made components like user interface controls they usually have quite a few problems - and there is no way you can fix it. If your clients complain about menu items not dropping down when you hover your mouse over it - that is it, you'll have to live with it. If two threads don't work properly together and one part of the application freezes - that is a problem in task scheduler in Java on a particular platform - you will have no workaround. This sort of problems is specific to "multi-platform" java, which is not truly multiplatform. C++ is the only multi-platform language I know today.

On the other hand, in some companies the projects are done already mostly in VS.NET (which means C# or VB.NET or "managed C++") or in Java and whatever the arguments are pro or against you might be forced to use one of them. But if you are considering creating your client applications, may be interface it with some financial applications - then C++ is the language of choice. Because existing financial platforms almost always have C++ API.

Although, if you are a complete novice, JAVA might be easier and cheaper to learn/use - that can be a big argument for it.

Databases - depends on your needs. Perhaps, MS Access is all you need? Or even Excel? If not, then MS SQL or Oracle are the options. But using them is like acquiring an additional profession - DB Admin...
 
:LOL: every developer I come across who uses c++ will always talk of it being the "real language", including myself untill I saw the wood from the tree's. Its like the old 'linux' vs 'ms', 'netscape' vs 'ie' ... developers using perl hate asp ... the list goes on ... !!!... !!

We're currently converting all our apps from c++ to c# and vb.net, no trouble at all so far.

I'm not biting ..no more,.. so no reply please ! :LOL:

This is a good book by the way from Apress 'Practical .NET for Financial Markets' or at http://www.amazon.com/Practical-Financial-Markets-Samir-Jayaswal/dp/1590595645

I presume you want to write a trading type app ?
 
egro1egro said:
The biggest drawback of using "application" type languages like C# or Java is that you very often don't have any control over some features/bugs in your application. When you use ready-made components like user interface controls they usually have quite a few problems - and there is no way you can fix it. If your clients complain about menu items not dropping down when you hover your mouse over it - that is it, you'll have to live with it.
That's not quite true in the case of Java. In Swing, you can write your own components if you want to. You can use Java2D if you wish, so you get right down to the 2D graphics level. Furthermore all source for Swing is distributed with the JDK which is very useful if you are having a problem with some component you don't quite understand. There really is no excuse for not getting a Swing GUI right. It does take expertise though.

If two threads don't work properly together and one part of the application freezes - that is a problem in task scheduler in Java on a particular platform - you will have no workaround. This sort of problems is specific to "multi-platform" java, which is not truly multiplatform. C++ is the only multi-platform language I know today.

Much more likely that deadlocks are due to errors in app design than problems with the JVM. In Java threads are part of the language. In C/C++ external libraries implement threads. Posix and Windows threads are different. Unless you wrap the different thread libraries, threads in C/C++ are not portable at all.
 
If it's just for personal use then no need to buy a DBMS like MS SQL or Oracle - take a look at the documentation pages for MySQL (for when you need a client/server configuration) and SQLite (a simpler DBMS for when everything runs on one machine).
 
gc1 said:
If it's just for personal use then no need to buy a DBMS like MS SQL or Oracle - take a look at the documentation pages for MySQL (for when you need a client/server configuration) and SQLite (a simpler DBMS for when everything runs on one machine).

I use MySQL for time series and it works well. For simple use (as in my case) it is quite easy to setup.

Apache Derby is another option for Java developers. Both embedded and client/server. Probably slower than MySQL though.

It is probably debateable if RDBs are the best solution for handling time series. Ultimately roll your own can probably be made to perform substantially better than any RDB. If you are handling large amounts of tick data, then performance will very likely become a major concern.
 
emk said:
Thank you all for the comments and suggestions. I have a little experience in programming (Excel VB), but now I need to have a more powerful tool to process a lot of data.

I also have another question regarding to database. Many advise me to use SQL. Anyone have any comment about it?

@emk,

if you want to get skills, which are necessary for a good IT Job in this times, you have two main possible directions: Java or .NET (which includes both C# and C++). You will use C# because of its higher productivity in most general cases and C++ for more specialized ("unmanaged") code, e.g. "Hardware-near" programming tasks...

But if you need only a lean, fast and easy to learn (you have Excel/VBA knowledge...) programming tool for own purposes, I can recommend you "Consultant's Secret Weapon": PowerBasic.

Compile without Compromise!

http://www.powerbasic.com/

I've decided to write my tools and my trading systems in this language and my just published Monte Carlo Software product seems to be the fastest worlwide...til now.

The main advantages of this environment are:

1. the code is written in basic. It is generally also understandable after years... Talk even with experienced C++, c# or Java programmers concerning their maintenance nightmares... :)

2. the compiled code is lightning fast. In most cases comparable to or better as native C.There is even the possibility to use an additional inline assembler, if you need more power...

3. the code is lean. There's no runtime environment. You can compile exe or real standard windows dlls.

4. despite of the fact, that it is a Windows environment, I've tested successfully my original windows exe under unbuntu linux with emulator wine 0.x (all on an old 128 MB Notebook!)

5. last but not least there's an excellent forum supported. There are very, very good experts which share their knowledge...

Only my two cents...

bye,
zentrader
 
Last edited:
I have a simple question which I hope one of you experts can help me with:

I have an excel chart which has 2 fields automatically populated and continually updated with time and price from a tick chart feed through DDE from prorealtime charting.

How do I process this so I end up with a chart which has 4 columns with open, high, low, close for each minute. i.e. I want a spreadsheet which has the numerical equivalent of a one minute candle.

Thanks very much in advance.

Charles
 
Top