Is the programming language Rust just "new wine into old wineskins"? Discuss

Daniel Duffy

C++ author, trainer
1. What are the compelling reasons for using Rust?
2. Compare and contrast Rust's features with those of C++.
3. Is Rust trying to be a (C++)++, i.e. a better C++?
4. Which applications is Rust good at?
5. When will it take off into the mainstream?
6. Can I port C++ code to Rust?
 
@Daniel Duffy i don't know how familiar you are with rust but i think you are probably better suited than most on this forum to answer these questions (notwithstanding your vested interests in c++ doing well ;))

i would be interested in your answers to the above questions, thanks!
 

Daniel Duffy

C++ author, trainer
@Daniel Duffy i don't know how familiar you are with rust but i think you are probably better suited than most on this forum to answer these questions (notwithstanding your vested interests in c++ doing well ;))

i would be interested in your answers to the above questions, thanks!
I know 0.01 Rust but all languges are based on C and it compares itselt to C++ (they all do :).
Someone told me I should move to Rust but did not give any reasons...

Thus, until further proof I see it as just another language. It's a cotrarian viewpoint.
 
1. Rust is inherently meant to be memory safe. You can’t accidentally leave a dangling pointer because the way you write your code everything gets implicitly “moved” unless you explicitly state you’re using a reference. Potential memory bugs will not compile which is a pretty strong advantage over c or c++, but requires you to “rethink” the way you write code. For trading, getting that benefit + the speed of c++ makes it a contender if you’re starting to build infra from the ground up

Main benefits are memory safety, speed, ease of package adding / formatting via cargo, built in support for result types / failure handling, substantially better async libraries / web socket support

Main downsides of rust are it’s poor OOP support (ie polymorphism and inheritance is doable in rust, but harder), poorer generics/ templating support (this is actively improving), sparser math libraries (ie I don’t know if there’s a good Eigen substitute, over time this has been improving), and in general the lack of industry experience around it. Hiring someone who knows c++ is infinitely easier than hiring a rust programmer


Can’t speak to the other questions really, but overall if you’re writing infrastructure for trade execution, exchange connectivity it’s for sure got upside relative to c++, for signal generation you can make it work but it’ll probably require a bit more tuning, and working with the compiler is significantly slower.

Is it worth learning? If it’s learning for the sake of learning , imo no- it’s not going to add much value to your life over c++; if you’re exploring options for a new project where speed and stability are important, potentially concurrency related? Yes
 
Last edited:

Daniel Duffy

C++ author, trainer
Main downsides of rust are it’s poor OOP support (ie polymorphism and inheritance is doable in rust, but harder), poorer generics/ templating support (this is actively improving), sparser math libraries (ie I don’t know if there’s a good Eigen substitute, over time this has been improving), and in general the lack of industry experience around it.

==> non-starter/show-stopper in general. It means Rust is immature (for many reasons).
No OOP, no generics ==> null points.
This means stone-age applications.

And lots of promises ..


Hiring someone who knows c++ is infinitely easier than hiring a rust programmer
Whatever makes you that?


Rust is inherently meant to be memory safe.
Rust == C for the memory-challenged?
Ever heard of smart pointers?

Rust = C+?
 
Main downsides of rust are it’s poor OOP support (ie polymorphism and inheritance is doable in rust, but harder), poorer generics/ templating support (this is actively improving), sparser math libraries (ie I don’t know if there’s a good Eigen substitute, over time this has been improving), and in general the lack of industry experience around it.

==> non-starter/show-stopper in general. It means Rust is immature (for many reasons).
No OOP, no generics ==> null points.
This means stone-age applications.

And lots of promises ..


Hiring someone who knows c++ is infinitely easier than hiring a rust programmer
Whatever makes you that?


Rust is inherently meant to be memory safe.
Rust == C for the memory-challenged?
Ever heard of smart pointers?

Rust = C+?
1) It doesn't not have OOP or generics, its just different from C++ / the entire feature set isn't there yet. You can do 80-90% of everything you would need as far as generics / OOP, it just won't be the same and might require extra effort. Rust was originally compiled off OCAML and it's functional background shows up a lot in the language. I definitely wouldn't say the lack of OOP is necessarily a problem to begin with, especially for trading when you've got firms like Jane Street. I would also say its a gross simplification to say "stone-age applications" are the best you can get out of rust

2) hiring c++ programmers is easier because there are more c++ programmers in the market than rust programmers, it's pretty straight forward. One language has been around for decades, and taught at hundreds of universities globally, (+ the abundance of online programs like the quantnet c++ program has helped) the other's been around for about a decade and has a niche userbase at the moment. Finding someone who out the gate knows Rust proficiently and is interested in quantitative finance isn't easy

3) yeah, smart pointers exist in c++. tbh I'm sure you can find libraries or boost projects that have a lot of the feature set of rust, the difference is one language was designed around certain principles and the other wasn't


Realistically I don't think any particular language (Go, Rust, Python, Cython) is going to 100% replace C++ as the "dominant" language in quantitative finance, but they've all got their own trade offs and all come with valid use cases in the industry
 
Last edited:

Daniel Duffy

C++ author, trainer
I would also say its a gross simplification to say "stone-age applications" are the best you can get out of rust

In my experience of 45 years in very many areas (e.g. 1st C++ programmer in NL in 1989, before that Fortran, Cobol, SQL) , it is NOT a gross simplication.

It might be good in trading (I'll take your word for it), but in other areas, C++, C# and Java are dominant.

It will probably remain a niche/quiche product.

Just to be clear, C++11 etc. supports smart pointers. Many Boost libs are now in C++.

I would be concerned about the business model around Rust.

Is there Rust <-> C++ interop?
 
Last edited:

Daniel Duffy

C++ author, trainer
It does not have OOP or generics, its just different from C++

I agree. It feels like a step backwards to the 1980s.
 
Last edited:
That’s kind of a misleading way of putting the stats- you’re comparing something that’s been around (in a stable way) for only a couple years vs something that’s been around for a few decades

For example, rust has been having pretty rapid growth in its user base.

In any case I don’t really have a bias towards one language or the other, use whatever you want to use. Every language, including c++, has its own pros/cons, so go for whatever suits you the most.

Yes there is interop, and I think you misread or misquoted my post

1) It doesn't not have OOP or generics, its just different from C++ / the entire feature set isn't there yet

The double negative may be confusing- so to be very explicit: there is oop support and generic support, it’s just not as fleshed out as c++
 
Taken from Rust programming language - what is rust used for and why is so popular? - CodiLime

According to the Stack Overflow Developer Survey 2021 conducted among over 80,000 developers, Rust is the most beloved programming language. And it won the title for the sixth year running.

In 2020, Linux kernel developers proposed writing new Linux kernel code in Rust. To be clear, they did not want to rewrite the entire Kernel, which was originally written in C, but to add new code in Rust that would work with the existing infrastructure. No less a figure than Linus Thorvalds, the father of the open-source operating system Linux, welcomed the idea and is keen to see the project results. This idea is in continuous development — at this moment, it is still described as experimental, but “good enough that kernel developers can start working on Rust abstractions for subsystems and write drivers and other modules.”

Moreover, Google is also planning to use Rust in the Linux kernel after bringing support for the systems programming language Rust to Android. The entire operation is aimed at reducing security flaws. Microsoft, meanwhile, has turned to Rust to reduce memory-related bugs in Windows components.

Facebook has also forged closer ties with Rust, joining the Rust Foundation, an organization created in 2021 to drive the development of Rust and make it “a mainstream language of choice for systems programming and beyond.” Facebook joins Amazon Web Services, Google, Huawei, Microsoft, and Mozilla in using Rust in some capacity.
 
Is Rust being used in Quantitative Finance/Fintech? For example: Derivatives pricing libraries, or High Frequency Trading or Crypto/Blockchain (it was mentioned above that one of the pros of Rust is speed)?
 
Not super widely yet; at least a few “new” hft firms (mostly within crypto or digital assets from what I can tell) that are writing their infrastructure are using rust based on recruiter LinkedIn postings, but most of the “well known” names already have existing infrastructure in c++ that doesn’t make sense to port to rust.

If you’ve got existing C++ infrastructure that’s been battle hardened over the years, rust isn’t worth it
 
If you already know C++ and want to work in HFT, it is good to learn Rust and to make yourself stand out, I guess, atleast to those firms that are building their infrastructure in Rust.
I think our QuantNet TA @APalley is working in Crypto space, maybe he can throw some light on the topic and improve our understanding about the current relevance of the language in crypto trading.
 
@tips not able to do self referencing structs and lazy evaluation is a big turn off for me.

Life time annotation sux as of making your code unable to be extended (or maybe a huge rewrite) when you have an “evil” boss or “unreasonable” user.
 

Daniel Duffy

C++ author, trainer
The Rust mindset of trying to outdo C++ is stoopid. The Java/C#/C++ languaage wars ended a long time ago. Now it should be Rust's turn to accept the status quo.
All I hear at this stage is that Rust is for HFT, a very specific area. It's a low-level language.

Rust is not for all things; be honest and stop always proselytizing Rust. Java had the same mantra 25 years ago.

In real life organisations use a mix of languages; Interop is the norm.

In 2020, CXX appeared, and it was a real revolution. Thanks to the CXX library, calling C++ code from Rust and Rust code from C++ is safe and effective now. It does not mean that it was impossible before. It was, but before CXX, Rust-C++ integration was more inconvenient—it required manually crafting Rust-C and C-C++ interfaces.

Call it a draw?
 
Last edited:

Daniel Duffy

C++ author, trainer
sparser math libraries (ie I don’t know if there’s a good Eigen substitute, over time this has been improving), and in general the lack of industry experience around it.

On a follow on question. does Rust have support for mathsy stuff like Python numpy/scipy or Julia?

 
Anecdotally, I know you can do most of the common needs a data scientist might have in Rust, and what isn't readily available you can build out - part of the downside of it being a fairly new language w/ broad use cases

You can check the crates for ML related libs below

i.e. TensorFlow has a rust port

There are some interesting DataFrame libraries (i.e. like Pandas) GitHub - pola-rs/polars: Fast multi-threaded DataFrame library in Rust | Python | Node.js
and it's possible to access / use the C bindings for numpy via stuff like GitHub - PyO3/rust-numpy: PyO3-based Rust bindings of the NumPy C-API
 
- Rust is also definitely NOT just for HFT - I work in HFT so I'm more familiar with that use case. Any situation in which you can use a low level language, it makes sense to consider Rust as an option (i.e. like literally writing the linux kernel in it; it's now one of the official languages for adding to the linux platform)

- No one is claiming you can't do interop with other languages, nor is anyone saying you shouldn't; choosing to do interop varies project to project and organization to organization

I don't think anyone reasonable is actually claiming that Rust is here to "replace C++", nor is it really a competition (which is why I'm kinda confused why you keep framing it like that). Languages are just tools so use whatever makes the most sense; Rust is likely here to stay, but I really don't see it replacing or causing C++/Java/Python to disappear or become less popular
 
Top