Article from eFinancial News 16/12/2020 by Sarah Butcher
If you want to write the kind of code that’s used in the kinds of trading algorithms that are integral to market-making in today’s financial system, it’s quite possible that you’re going about it all wrong. Especially if you’re starting out by learning how to code in Java.
Peter Lawrey, CEO of Chronicle Software, which provides low latency trading systems to banks and hedge funds, says Java expertise can be a hindrance rather than a help if you want to write low latency code.
“You can have 10 years of Java coding experience and not really understand what you’re doing,” says Lawrey. “There are Java developers who’ve been coding for 10-15 years and who have no idea how big an integer is, who don’t really understand how data is laid out, or how to turn an object into raw data so that it can be turned back into an object. People have only ever used libraries.”
Programmers who spend their entire careers in Java often develop a false sense of their own ability, suggests Lawrey. – They know how to do everything in Java, but this is simply because there aren’t many things to know in Java. “There’s a philosophical difference between the two languages,” says Lawrey. “C++ is kitchen sink approach – it has loads and loads of features and options for doing the same thing and if you know what you’re doing, you pick the right one. Java only has one or two, or maybe three ways of doing the same thing. It’s feature poor, but because it’s feature poor then developers feel they have mastered all the features of Java fairly quickly. With C++ it can be really difficult to feel you have mastered all the alternatives.”
At Chronicle, Lawrey codes ‘low latency Java’ which he describes as Java with only fast and efficient constructs and all the “garbage” stripped out. Instead of learning to code in Java, Lawrey says he spent his first two years learning how to code in an assembly language which translated directly into the machine code that creates the binary instructions moving values in and out of the registers in a CPU.
“It’s learning the hard way,” says Lawrey. Even if you start learning how to code in C++, he says you’ll be forced to learn how everything works down to a very low level of detail. – But if you start in Java, you’ll usually simply learn a few abstractions that will deliver quick results.
This is fine if you want to use Java to code websites, but if you want to code low latency Java for trading algorithms, Lawrey says it helps to know C++ inside out first.
This begs the question of why you’d bother switching to Java in the first place. Lawrey says the best low latency Java programmers are those who are glad they’re not still coding in C++. “They need to have a background where they’ve been forced to understand everything, but to be thankful that Java is there instead.”