C vs Java programming for IB

Discussion in 'Automated Trading' started by thesharpone, Nov 17, 2007.

  1. segv

    segv

    An eternity for whom? I will accept the argument that 100ms would be an awfully long time for an exchange to transmit a quote or acknowledge an order, but what do you think that this means to a customer of IB using TWS?

    I must have missed that trend in the last 15 years when I was building all of those data centers, but thank you for finally filling me in. Would you please explain to me how does a colocated "algo" in New York get the edge on an institutional trader at Barclays in San Francisco?

    Where is the data to support your claim? Why is C++ "just better" for high-frequency trading? My argument is that language latency is insignificant for an automated or high-frequency trader developing a system for the IB TWS platform. Go ahead and write it in assembly if you want to, but it is still going to get routed through TWS.

    BTW, no offense, but you are totally ignorant.
     
    #31     Nov 19, 2007
  2. segv

    segv

    Because you are feebly attempting to refute the existence of two Java-based operating systems you did not know about.
     
    #32     Nov 19, 2007
  3. segv

    segv

    IB TWS is written in Java and has a thoroughly tested Java API. As I told the other poster, you can write it in assembler and backport it to the VAX if you want to, but the data is going to get routed through TWS anyway. It does not seem to be worth the effort to do something else when you can have the application up and running in a couple of hours with the API.
     
    #33     Nov 19, 2007
  4. Gustaf

    Gustaf

    I agree to most of the things you have written above but as a side note I can just add that getting started and having a little scalper that automatically placed orders was not complicated nor took a long time for me to do in C++.

    Id say use the language which is most comfortable. As segv pointed out, TWS is still written in Java and we are not talking a fighter jet system control system here.

    (I use both Java and C++ at work and have done so for the past 8 years).

    Br
     
    #34     Nov 19, 2007
  5. Corey

    Corey

    You just really are not understanding what I am saying. TWS has a C++ API. The original poster is more comfortable in C. Why, oh why, would he want to write it in Java then?

    Now, if this application were tens, or hundreds, of thousands of lines long, then programmer efficiency and capability is of the utmost importance. I would still argue that writing a socket implementation in the language you are most comfortable in would be worth it. But, considering most languages can interface with shared libraries, you could probably just take the TWS C++ API, write an interface, and compile it into a shared library -- then write the whole thing in whatever language you want.

    You seem to think I am having some argument about the efficiency of Java. I am not. At all. I am having an argument about the efficiency of the programmer.

    I don't really care that the actual application you will be interfacing with ultimately uses Java. That is a fixed cost. The rest of the process is all variable costs. A programmer should do everything they can to decrease their variable costs.
     
    #35     Nov 19, 2007
  6. Am I glad you don't run a company and thank god for Microsoft. WTF, so you want everyone in the world to program in one language? Kudos to Microsoft for the ability for people to choose how they want to express their code (VB, C#, C++, etc.).

    But I agree, TWS should be written in C/C++.

    For all you Java lovers out there, you do realize where Java came from, it's not an original idea that Sun invented, nope. It's basically SMALLTALK, think of it as version 2.0.
     
    #36     Nov 24, 2007
  7. GTG

    GTG

    And C# is basically 3.0 :D
     
    #37     Nov 24, 2007
  8. Well...just to be a stickler..:D
    ...The Java programming language is actually written in C and includes another layer of compilation that happens converting the intermediate byte code to assembly language at runtime.

    The JVM is also another subsystem which sits between the process and the OS, so technically, it would be impossible for Java to be faster than C++...

    ....but having said that, the real latency in a network process is the TCP/IP communications that happen over networks. Those latencies are hundreds of times longer than the differences in a process running C++ vs. Java.

    Secondly, it's false that C++ will be faster at this layer, because Java obviously uses the OS network stack just the same as C++ does, so once the process has made the network request, they are both at the mercy of the OS drivers just the same.

    Java and C++ are two different animals altogether. Java is best to write code that is easy to reuse and extend. It's a great language for ease of design.

    It's true that C++ is the better "real-time" language, but that more applies to running processes that have critical time constraints within the same process space.

    C++ is good if you need performance in the milliseconds, but since trading by its very nature is highly network sensitive, the gains that you'll make within the same process space are so tiny as compared to the network latencies, that IMO, I wouldn't factor that into making a decision.

    Now, if you're running a "hub" of ECN's, well that's a different story. In this case, most of your processing is probably happening on the server to handle so many requests in parallel. So in that environment, you'd be nuts to use Java. But for your average trader who is making basically only a few requests at a time, I don't see how you'd even be able to measure the difference with any validity.

    My 2cents.
     
    #38     Nov 24, 2007
  9. Corey

    Corey

    I think you misunderstood what I meant. Most of the time it isn't the language that is slower -- it is the programmer.

    If you test silly things like 10000000 iteration for loops, then C will win in speed, hands down. But those are contrived examples.

    What people fail to realize, and what you say well, is that no general purpose language exists. If it did, we wouldn't have all the languages we do. Each language is a tool in the toolbox -- the more you know, the more likely you are to choose the right tool (and therefore have the most efficient solution) for the job.

    But you are wrong in saying that Java cannot be faster than C, or C++. Very wrong. Java can be much faster -- even if the programs are a solution to the same problem. "How can this happen?" you ask. As I said: the algorithm. Whoever wrote the C code wrote it inefficiently. Where the C programmer might have written map[x][y], the Java programmer wrote map[y*MAX_Y + x]. Its all about the most efficient solution -- and most programmers aren't good enough to even take 'language speed' into account.

    I know I am not.
     
    #39     Nov 24, 2007
  10. Well, technically that is not quite 100% correct. While I doubt that anybody will dispute that C++ is in gereral faster than Java or C#, there could well be instances of certain operations where C++ is slower. C++ code is statically optimized at compile time. The JVM via Hotspot can do dynamic optimizations on how the code is executed. There is some discussion of this stuff in the articles and blogs on java.net.

    Another example where Java is claimed to be quicker is in object creation and destruction, the automatic inlining of getters and setters etc.

    I'm not trying to start an argument on which is best or better or fastest, but to underline the fact that system performance is a very complex issue, and really does take some expert knowlegde to come up with useful analysis (as opposed to just running it and see how long it takes).

    And yes, I completely agree that the data comms side of things is the dominant factor in latency.
     
    #40     Nov 24, 2007