Why Discord is switching from Go to Rust

Posted on

level 1

Isnt this article quite old? I remember seeing that async rust is already on stable Rust

level 2

Probably a bot that automatically repost top links from a year ago

level 2

I remember seeing this article a WHILE back, which convinced me in the first place to leave Go, so I guess they reposted because of the widespread adoption of Rust thanks to The Rust Foundation, but idk. Here’s a blog post from around that time explaining how they’re using it to expand Elixir.

level 2

It was published Feb 4, so two-ish weeks ago. Still a great write up worth reading though.

Edit: Feb 4 2020, lmao. My bad.

level 2

OP, Is there a reason why this is coming up now (ie a year later)?

Maybe there is…

level 1

TL;DR Garbage collection was slow in GO. Rust has no garbage collection to slow them down, and async dev experience has been improved in the nightly branch, so they’ll switch.

Makes perfect sense.

level 2

Kinda ironic considering their client is a ram chewing browser that runs javascript.

Doesn’t help that they prohibit custom clients either.

level 2

The Go GC is not slow, it’s actually pretty well tuned for low latency. The issue is that a LRU cache is the worst use case for a garbage collector.

level 2

TL;DR Garbage collection was slow in GO.

And Go forced it to run every 2 minutes, didn’t matter if it was needed.

level 2

I gotta tell you that ARC, Automated Reference Counting in Objective-C and Swift is really really nice. It offers smooth reliable performance when reclaiming memory.

level 2

I wanted to try Rust’s async stuff out, but when I saw it was function call-like I noped out. Is that still the case?

level 2

Then what happens to the garbage if it’s not being collected?