I was reading Why I think C++ is still a desirable coding platform compared to Rust on Low Latency Trading Insights, and wanted to share my thoughts. Overall, I really appreciate this article: it raises a very important subject and makes lots of good points. I do disagree with some of it, though I wouldn’t go as far as to say that I disagree with the conclusions drawn.
Safety: I can empathize with the author where he says that segfaults and other issues coming from the lack of safety in C++ are very rare for him: I expect most experienced C++ developers will feel the same way; I certainly do. But in a company you also have to consider how productive junior members can be. I’ve mentored and managed my share of juniors, and C++ being essentially a language assembled from landmines definitely adds a drag to the stability of the overall system and the general productivity of developers, in part because less experienced or knowledgeable developers will run into said landmines.
Performance: even in a trading system, not all code – in fact, not even most code – needs to be ultra low-latency. (That’s why lots of trading companies use languages like C#, Java, and OCaml in addition to C++.) Using unsafe
on the most latency-sensitive code sounds like a fair enough choice to me, or at least I’d not completely ignore unsafe
in this way. It is completely true though that optimizations currently work better for C++ (due to its long history and untold effort expended in that area) and that GCC most often optimizes better than Clang at the moment: this situation may change over time however. Undefined behaviour in C and C++ does unlock a lot of optimization opportunities, a fact which is often lost on critics.
Ecosystem: C++ is definitely the established and dominant choice, so companies will have huge existing C++ codebases, and there are plenty of C++ developers to go around. These are difficult for Rust to combat, though over time I expect the share of Rust developers will go up. Rust does have a massive advantage over C++ though in the ecosystem via it’s easy accessibility of third-party libraries (similarly to what is enabled by Python’s pip
and JavaScript’s npm
). In C++ it can be a huge pain to use third-party libraries, partly because many of them will end up doing things completely differently (see e.g. Qt’s QString
instead of std::string
), and partly because integrating them into the build system can be very problematic. (CMake’s popularity alleviates this somewhat, but having to use CMake is its own special kind of hell, so I’m not sure whether this actually counts as a win.)
I consider myself a very solid C++ developer, but admittedly I am not a Rust developer as of yet, so my opinions may be based on incomplete or erroneous information. I have been digging into Rust a bit though, because I believe it has merits: I’ll be curious to see if my opinion changes on the longer run.