3 ms·
The title of the article and the comments here are conflating several things. We had Peter Lawrey consult at one of my employers, and I've worked on both C++ a
by DrBazza 6y ago
The title of the article and the comments here are conflating several things. We had Peter Lawrey consult at one of my employers, and I've worked on both C++ and Java HFT systems.
We used Chronicle as a high performance messaging system. The secret sauce is just memory mapped files, single threaded processes, and using Java objects as flyweights that just write to the end of the file, or are read from the end of the file. No GC. When taking market data off the wire, or sending messages around a system, that is competitive with C++ and certainly has a fast time to market, and lower defect rate.
The other thing people are conflating is high frequency part: get the market data and... do a complex calculation as fast as possible, and place or pull an order. Placing or pulling orders can be further optimized too.
The fast complex calculation part is where Java isn't as competitive and you run into the GC unless you use object pooling, warming up the JVM and so on. We had a 50-50 system of Java for the bulk of the system, and C++ for the complex algorithms where we mark hot paths and check the assembly on godbolt (thank you Matt Godbolt).
- b20000 6y agoI was an intern in a startup years ago where they had a product that was a mix of java and C++. the company went bankrupt on that decision. there was only one engineer who understood the java/C/C++ interface at the time and that interface was responsible for all the bugs and performance problems.
- DrBazza 6y agoWell this was the reverse of a startup - an established company that had a working system, historically in Java, and then added a mixture of C++ processes, and Java-C++ interop libraries to improve performance. Picking two significant languages as a start up is a bold choice. Measurement and QA is everything in terms of performance.
- b20000 6y agoI don't think that matters. It all stands or falls on whether you have people that are capable of bridging both worlds correctly, and those people are rare, and I see no advantage to using java. So why bother? Just hire good C++ developers and you don't need to go find the ultra rare masterminds who can bridge both worlds. The time to market argument is debatable as there are an enormous number of libraries for C and C++ available and a lot of language features have been added to recent standards to address this issue. I also think that one of the key problems with java is that it forces the OOP paradigm on the user.