c++ or java for trading app development

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

  1. #11     Mar 20, 2007
  2. I originally wrote my backtesting code in C++. Then decided to move to C# (Microsoft's analog of Java). The program ran 10 times slower! I looked into it - it wanted to verify every array boundary, couldn't do any inlining, couldn't use any MMX instruction. After tweaking with compiler options, using some "unsafe" code etc, I was able to reduce that difference to about x2.

    But it really does save development time, primarily because the library (.NET) is very large and very convenient. I think as long as the time my computer spends on calculations is not too large compared to time I spend on writing code, C#=Java is the way to go.
     
    #12     Mar 20, 2007
  3. wave

    wave

    For fast loading and snappy performance, native win32 code cannot be beaten. Having coded in c, c++, java, and now c#, it's hard to go back to c/c++ after coding in java or c#. I would also advise going with java or c# for most projects. You will find that the actual code is the bottleneck most of the time and not the language. If you still feel your app or process requires more speed, code it in c or assembler and you can call unnmanaged DLLs from c#. Just remember, the called dll will be unmanaged and you will have to take care of cleaning it up yourself.
     
    #13     Mar 20, 2007
  4. gwb-trading

    gwb-trading

    First let me state that I come from a background of coding C/C++ for embedded systems.

    Coding in C++ will give you at least 2.5X the performance of an equivalent JAVA application. We found this out recently when we needed to port a JAVA application which was just not cutting it in real time, and then measured the delta.

    This being said.... usually JAVA will meet the needs of most programmers for desktop applications. If you are not comfortable with C++ and do not require real-time intensive processing, I would urge you to take JAVA for a spin for development.

    There are also some good things to be said for C# in an MS CLR environment.... however keep an eye on your real-time requirements.

    Discussions over programming language selection tend to become a "religious debate". I would tell you to select something that appears to be reasonable for the constraints of your application (memory, real-time, interface, etc.) and run with it. Programming languages are sort of like riding a bike... once you rode one then you can figure out the others, just a matter of complexity and syntax.

    - Greg
     
    #14     Mar 20, 2007
  5. I wanted to say one more thing to the OP...

    If you have to ask this question on a public board, then your system is NOT so speed-sensitive as to require C++ over Java.
     
    #15     Mar 20, 2007
  6. Ill take that one step further.
    If you have to ask on a public forum, C++ is far too complex/difficult a language for you to be writing systems that could lose all your money automagically
     
    #16     Mar 20, 2007
  7. andread

    andread

    Well, with generics and annotations and other stuff Java isn't turning exactly in a piece of cake. Thankfully.
     
    #17     Mar 20, 2007
  8. cmaxb

    cmaxb

    Interesting discussion. I agree that Java makes for a nice development environment (particularly as how NetBeans is evolving). C# is also nice w/ dev studio. I personally prefer Qt/c++. But I'll never forget my first backtesting app written in c with pointer arithemtic. I could backtest 7 years of 1-minute bars on ES in 2 seconds. Yes, 2 seconds.
     
    #18     Mar 21, 2007
  9. wave

    wave

    if your project involves capturing streaming times series data, consider that java and C# are not real-time languages.

    They run on an underlying virtual machine which controls execution. The java and C# VMs will halt your program for short periods of time while it does things like garbage collecting memory. This is not like using standard 'C' where you have more control over these things. Something to consider.

    If you will be dealing with time series, go with Linux and C.
     
    #19     Mar 21, 2007
  10. wave

    wave

    yes that says it all cmaxb. java and C# are nice and easy for most general projects. But for performance in backtesting and capturing streaming data, C/C++ is the way to go.

    Yes QT4 is nice.
     
    #20     Mar 21, 2007