laitimes

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

author:Not bald programmer

In recent years, Stack Overflow's annual developer survey has been named the "most loved programming language" for many years in a row — and that's Rust.

With its unique security and performance on top of C++, Rust has become a language that many developers want to try, and the author of this article is one of them. And after rewriting the entire open-source algorithmic trading system in Rust, he came to a conclusion that was different from most people: Rust is a really bad language.

Once upon a time, I was a young and hopeful Rust fanatic. Because I've always heard that Rust is perfect as a programming language designed by God: not only is it fast, but it's also one of the most secure programming languages out there.

If you look up information about Rust online, you'll find that I'm far more than the only one who thinks Rust is perfect: every guide on Medium, every post on Reddit, every answer on Stack Overflow...... It's all overwhelmingly positive about Rust.

With this in mind, I decided to ditch TypeScript and use Rust to rewrite my open-source algorithmic trading system, NextTrade.

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

There are benefits to rewriting in Rust, but it comes at a significant cost

Initially, NextTrade was built with TypeScript with a focus on maintainability, readability, and reusability. However, when the core trading logic started to suffer from serious performance issues, a complete rewrite was necessary in order to build a paper trading and backtesting platform that could scale to tens of thousands of users. As a result, Rust emerged as the top candidate, and after a lot of research by me, it came out as the programming language for a complete rewrite of NextTrade.

It took 18 months before and after, and the final rewrite turned out to be good. NextTrade, which was rewritten from Rust, became NexusTrade, and NexusTrade was significantly better than before the rewrite in terms of speed and configurability: for example, backtesting that took seconds to complete on NextTrade can be completed in a few hundred milliseconds on NexusTrade – which means a 1,000x increase in performance and the ability for the platform to support more complex features.

It's great to have these benefits, but the huge price I paid can't be ignored.

The biggest advantage of Rust is that it completely eliminates the whole class of errors, and that's also its biggest weakness - borrowing inspectors makes the language incredibly difficult, especially when compared to languages like TypeScript and Go. I couldn't learn a new language at the same time as I used to, especially with a full-time job: Rust was so hard!

Truth be told, if OpenAI hadn't launched ChatGPT, I would really have switched to Go.

Thankfully, with ChatGPT's guidance, I overcame every obstacle and gained insight into Rust's nuanced syntax and its powerful and complex type system. ChatGPT is like an experienced Rust developer by my side, always on hand to explain the complexity of the lifecycle or the elegance of matching expressions.

All in all, I had a moderate rating of Rust at the time, and I didn't really love the language, so I wrote a blog post based on that. Unexpectedly, the article received a lot of criticism on Reddit, including a high-praise comment scolding me for using ChatGPT to write articles.

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

When I saw these comments, I thought: maybe I don't know enough about Rust to be biased.

So, I didn't like Rust much after that, but I stuck with it for a while. Now, four months later, I can confidently conclude that Rust is a terrible language.

Terrible, verbose, unintuitive syntax and semantics

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

It seems to me that everyone who says that Rust doesn't have brutal semantics is lying. In some cases, writing functions is simply impossible if you don't have access to extremely powerful large language models. But I really don't want to spend 90 minutes figuring out the clauses in a function, I just want to write a function that I want to write!

In the end, I also had to abandon the idea of helper functions altogether, because I really couldn't get the code to compile successfully. One of the biggest drawbacks of Rust is that people say that the strict compiler eliminates errors. Just give me a garbage collector and let me do what I want!

In contrast, if I were to write this exact same function in Go, it would look something like this:

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

While the core of the functionality is relatively the same, this way you don't have to go back and forth to figure out how to get your code to work – it works on its own!

Terrible error handling

Rust does handle errors very well. As long as you avoid unsafe errors, you can ensure that your code is working properly. NilPointerException exceptions and unhandled errors never happen again, right?

Wrong! Because when something goes wrong with your data or something unexpected happens, you're desperate to figure out what's going on. Maybe I'm an idiot and don't know how to enable stack traces. But when I got an error in my app, I didn't know why!

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

(Where exactly is my stack trace?) )

In contrast, in a language like Python, you'll get some nice, artistic stack traces that tell you what's going on, down to line numbers! Even in Go, you have errors. Wrap(...) allows you to see the error stack of your entire application. Maybe I'm such a fool that whenever I get an error in Rust, I'm at a loss and have absolutely no idea what's going on. I need to add eprintln everywhere in the app! (...)。

In fact? No, I'm not an idiot. This is a flawed language design.

Rust Community

One of the hot reviews is that the Rust community isn't as friendly and calm as they pretend to be. More specifically, I think they're a bunch of narcissistic guys who especially hate people saying that Rust is flawed.

Developers abandoned TypeScript for Rust and rewrote the system and criticized: this language sucks!

(A member of the Rust community gave me a "helpful" suggestion for my problem.)

For example, I asked a question on the Rust subreddit about how to improve MongoDB Rust crate error handling, and the answers included:

  • Use Postgres instead. (Laugh to death, am I going to redesign the entire database because of some bad misinformation?) )
  • Why should you use MongoDB? (I like, next question?) )
  • MongoDB is also terrible in Go and Python. (I don't know, but it's fine in TypeScript.) You changed the subject and didn't answer my question)
  • A really useful suggestion to improve the error message appears. (Very rare)

Of all the programming communities I've been in contact with so far, none are as cult-like as Rust. They ignore all of Rust's glaring flaws, such as the steep learning curve, lengthy code, terrible error messages, complex syntax, and controversial language design choices — all of which they attribute to the developer's own skills. In my opinion, this is simply insane!

summary

Still, there are some advantages to Rust. It works fast...... Well, that's basically its main advantage.

Plus, it should be safe too. If we compare it to C++, Rust is clearly the better language. But Rust's "security" is more of a drag to me than other languages like Go. If I could cut the development time in half, I'd rather add a few tens of milliseconds to the running time of the application.

On the bright side, if I choose to write an app in Go, I might regret it a little bit as well. I'd think, "What if Rust could be faster?" "Another article says Rust is the best language. Oh my God, did I make the wrong choice! ”

At least, now that I've learned Rust, I feel like I can learn anything. Maybe I'll try OCaml for fun later, it's no more difficult to learn than Rust, right?

Reference Links:

https://medium.com/@austin-starks/i-spent-18-months-rebuilding-my-algorithmic-trading-in-rust-im-filled-with-regret-d300dcc147e0

https://medium.com/@austin-starks/i-built-an-algorithmic-trading-system-in-rust-heres-what-i-regret-a89f378b22c9

Read on