c++ or java for trading app development

Discussion in 'Automated Trading' started by cassidpp, Mar 19, 2007.

  1. cassidpp


    does anyone have an opinion on the development of a system in either java or c++. Its been a while since i've programmed and i'm only getting back into it now. At the time there was quite a difference in the speed of execution of the two, but perhaps there is less difference now.

    Also, does anyone have an opinion on which is generally better for the development of trading applications!
  2. Java really is a lot easier. You will end up with robust code sooner and with less effort, especially if you don't have a background in C/C++.

    Unless you are doing something fairly exotic, performance in Java will not be an issue. The JVM has come a long way and performance these days is very good.

    I have quite a few years experience developing C and C++ code on *nix systems for a living and there is no way I would choose C or C++ over Java without some compelling reason.
  3. I'm with dcraig.
  4. slacker


    I have several years of experience in MFC and C++. I have also done some internet development in Java, very little GUI but a lot of sevlet and database stuff.

    In the past year Java 1.6 has received a lot of good press on how performance was improved. I installed Java 1.6 and did notice an improvement in my Interactive Brokers TWS application. I purchased a copy of 'Killer Game Programming in Java' by Davison to see just how fast I could get a Java app and possibly a GUI running. I wanted a trading application that was designed around a 'game' pattern than a 'word processor' pattern.

    Interactive Brokers's API is in java so having a single language for IB and the user interface is attractive. One of the demo apps in the Java book was used as a GUI shell. In my trading front end I get data from an MySQL database and throw it on the screen. The app shows frames per second and I can maintain 15 FPS filling the screen with dense data bars and calculating indicators. My CPU load remains below 10%. I have no interest in pushing the CPU to get more FPS but it could be done. I cannot act on anything faster than 15 FPS!!! This prototype demo app is drawing data from a SQL query which I thought would slow everything down.

    It will take me some time to move everything from MFC/C++ to java but my new projects will be done in Java.

    Save yourself some trouble use Java, everything is free, and the documentation is very good.

    Still working on this, but it looks good from where I sit.

    Good trading.
  5. I agree/disagree...... The performance between the 2 is a lot closer than it used to be. A great system trading app can be developed in either language, and without a doubt java will significantly cut down the development time. This is especially apparent in the amount of time it takes to get a working prototype up and running to build off of.

    However, if your system TRULY needs power and speed, you are not going to beat C++. A real life example, I have had multiple iterations of my bot. My very first version was written in C++, my second version in java. I perform a lot of backtesting with my bot and speed was starting to become an issue. Was starting to take way too long to go through the data sets. So now i'm no my third itteration and this one is written in c++ again. My last two versions are nearly identical function/feature wise except the languages of each is different. The c++ version backtests nearly 12 times faster than the java version...... These results will not be the same for everyone however. If you are not used to c++ and especially optimizing code in c++ then you probablly won't see the same gap in speed, but it goes to show that in the right hands the speed difference can be huge.

    Funny thing is I do all my strategy development using my c++ version and I run the actual automated trading with the java version. I do this primarily because I feel more confident in the java version being stable.... Stability is a big componet when it comes to trading software...

    So, bottom line is I recommend Java unless you absolutely need the extra speed for some reason.
  6. slacker


    I agree with this without a problem.

    If you know you are going to be bound by speed use C++.

    Otherwise, give yourself a break and go java. In the past I did a lot of number crunching and needed C++. Today, I am more interested in information display and price action. Java is fine for that.

    At the end of the day it depends on what you want. A first app with a newbe programmer would probably be best in Java.
  7. lwlee


    I recently had to do some stuff in C++. God I forgot how much I hated pointer arithmetic. Also that BS with const. C++ has some of the worse syntax. Code can get convoluted and make your head spin reading it.
  8. A thread with every post more or less in agreement. Must be unique.
  9. Have you profiled the Java code ? There is a decent profiler for Netbeans available free. Doesn't affect execution speed too adversely, and is very easy to use.
  10. C# better than both...
    #10     Mar 20, 2007