Okay. This might be a pretty dumb question, but I really want to know what is it that the high frequency trading firms write in terms of services that requires C++.


I am a Rust and TypeScript developer and I was having a conversation with a guy I met at a function. He was a C++ developer at a high frequency trading boutique. As we were discussing the merits and demerits of the languages he brought up that Rust will never replace C++ just because of the sheer speed.


I am a strong believer in Rust. And I do believe that it can tackle a lot of problems that other languages pose without compromising a lot on speed: benchmarks

Granted, C++ is still faster, and I am no one to argue its dominance in a sector I know jack all about.

But I really want to know how C++ is used that proves it to be faster for high frequency trading firms.

Bigger Problem

I know jack all about high frequency trading. But I really want to know.

So my question is, what kind of services or cronjobs or APIs do people write using C++ for high frequency trading firms. Forgive me for my ignorance, but I come from a more API centric background, so we generally use services/contracts and APIs like, get_balance. What is it? I can't seem to find anything on the open web. Or maybe I am not looking in the right place?

  • 3
    $\begingroup$ This Reddit thread is a bit old but the discussions in it can maybe answer some of your questions: Production deployment of Rust in HFT system at Korean financial company $\endgroup$
    – Alper
    Nov 14, 2021 at 18:48
  • 2
    $\begingroup$ I think you question is a "emacs vs vi" one. Of course other languages can be faster than C++... personally my preference would go to ocaml ;{)} stackoverflow.com/questions/1924367/… $\endgroup$
    – lehalle
    Nov 14, 2021 at 19:57
  • 1
    $\begingroup$ Stating that c++ is (generally) faster than rust is a bit naive I would claim. However, why does everyone write in English here? It's the same with coding, people use what most people understand (and what works well). $\endgroup$
    – AKdemy
    Nov 15, 2021 at 7:26

1 Answer 1


I read your question here on stackexchange and was curious myself, so I did a little digging and came across this:

A thread on Quora

Where can I learn C++ for HFT?

Theodore Weld Smith (programming primarily in C++ and OCaml) answered:

One of the biggest distinctions from what C++ looks like for HFT versus in other applications is the latency aspect.

Writing good low latency code means

  • knowing how concurrency and parallelism works and how to use it
  • knowing what exactly the compiler is doing
  • knowing how memory is being dealt with
  • knowing how to write code for the specific hardware in use
  • knowing how the OS kernel the algorithm operates on works, and how to deal with it (e.g., kernel bypassing)

There are a bunch of things you can do in C++ that will “simulate” what HFT work is like; thus preparing you for it.

  • Writing device drivers (C or C++)
  • Using and learning about how frameworks such as CUDA work.
  • Learn about how the FIX protocol works"

And Daniel Wisehart (Longtime C/C++ Developer) answered:

Start by learning to write simple, clean C++ that is easy to understand by any competent developer with as little magic or reliance on the compiler to do the right thing as possible. Your intentions should be as clear to the compiler as they are to another developer. Some shops use libraries where they have no idea what is happening under the hood, but most prefer to roll their own for low-latency pathways. This means it is good for you to understand some of the issues confronted when writing those magic libraries, especially within the narrow set of problems you will deal with.

For example, a sorting library may have all sorts of optimizations for all sorts of initial conditions qsort will encounter, but if you only do insertion sorts—which is a common implementation in HFT—you really neither need nor desire a sorting library that handles the generic solution.

You will use a lot of hash map’s, but there are a lot of things hash maps can be optimized to do—such as merge or an apply—that you will likely never use. So you need to understand how to create a hash that is optimally sized for the number of entries you will deal with, statically allocate what you can and pool memory that will take care of hash collisions. Even if the firm already has an optimal hash for their use, you need to understand how it works, what choices were made and why other options were not pursued.

The more you can understand about the hardware you are running on, the better. With modern processors there are various rings of memory around the ALUs, and as you get further away from the ALU, the number of cycles to access something increases. We have a saying on this: in the old days, memory was fast, but if you had to go to disk you missed the trade because it was just too slow. Today, cache memory is fast, but if you have to go to main memory, you missed the trade.

We ran the entire Linux O/S in main memory on diskless machines—OK, there was a little bit of disk for local logging in case of a network failure, but no code was stored there—and we tried to keep everything in the trading code path in layer two cache or better. NICs with DCA (direct cache access) and user space data—aka kernel bypass—helped a lot.

If you have a good understanding of all the code—yours, the libraries and the O/S—that runs from network to application back to network, you will be a real asset as a C++ developer for an HFT firm.

Source: https://www.quora.com/Do-HFT-programmers-write-in-Assembly-and-Binary-code-to-further-optimise-their-systems

I know that might not be directly what you were looking for, but I hope it answers some of your questions.

Also, if you are interested to learn more about how to use Rust instead of C++ for quant trading, especially when trading on the blockchain, feel free to contact me on Discord. We are currently building a quant trading system in Rust. My discord is "Pierre#7374"


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.