Live data from Hacker News

Why Discord is switching from Go to Rust

blog.discordapp.com

111–120 of 670 posts

Re: Why Discord is switching from Go to Rust

#112
Go is not a general-purpose language. It's a Google language designed to solve Google's problems. If you aren't Google, you probably have different problems, which Go isn't intended to solve.

EDIT: Currently at -4 downvotes. Would downvoters care to discuss their votes?

Re: Why Discord is switching from Go to Rust

#113

Earlier quoted context omitted.

Python chose spaces a la PEP8 by the way.

PEP8 isn't a language requirement, but a style guide. There are tools to enforce style on Python, but the language itself does not.

Same thing with Go... Tabs aren't enforced, but the out of the box formatter will use tabs. PyCharm will default to trying to follow PEP8, and GoLand will do the same, it will try to follow the gofmt standards.

See:

https://stackoverflow.com/questions/19094704/indentation-in-...

Re: Why Discord is switching from Go to Rust

#114
post #104
post #65

Earlier quoted context omitted.

Seems like Go is more suitable for the “spin up, spin down, never let the GC run” kind of scenario that is being pushed by products like AWS Lambda and other function as a service frameworks.

Why do you think it is? Go has a really great gc which mostly runs in parallel to your program with gc stops only in the doman of less than milliseconds. Discord ran into a corner case where they did not create enough garbage to trigger gc cycles, but had a performance impact due to scheduled gc cycles for returning memory to the OS (which they wouldn't need to do either).

[deleted]

Re: Why Discord is switching from Go to Rust

#115
post #91
post #85

Earlier quoted context omitted.

We originally cached this data with a Redis cluster but we hit scaling issues. The Read States service only exists because Redis had issues.

Hah, well now I feel like a dufus. Good info!

No worries, we could have mentioned that in the post as part of the service history :)

Re: Why Discord is switching from Go to Rust

#116
post #87

Earlier quoted context omitted.

With recent Go releases, GC pauses have become neglible for most applications. So this should not get into your way. However, it can easily tweaked, if needed. There is runtime.ForceGCPeriod, which is a pointer to the forcegcperiod variable. A Go program, which really needs to change this, can do it, but most programs shouldn't require this. Also, it is almost trivial to edit the Go sources (they are included in the…

runtime.ForceGCPeriod is only exported in testing, so you wouldn't be able to use it in production. But as you said, the distribution could easily be modified to fit their needs.

Thanks, didn't catch that this is for testing only.

Re: Why Discord is switching from Go to Rust

#117

Earlier quoted context omitted.

Python chose spaces a la PEP8 by the way.

You can use tabs to indent your python code. Ok, you might be lynched if you share your code but as long as you don't mix tabs and spaces, it is fine.

Same with Go, you can use spaces.

Re: Why Discord is switching from Go to Rust

#118
post #16

> After digging through the Go source code, we learned that Go will force a garbage collection run every 2 minutes at minimum. In other words, if garbage collection has not run for 2 minutes, regardless of heap growth, go will still force a garbage collection. > We figured we could tune the garbage collector to happen more often in order to prevent large spikes, so we implemented an endpoint on the service to change…

Typically a GC runtime will do a collection when you allocate memory, probably when the heap size is 2x the size after the last collection. But this doesn't free memory when the process doesn't allocate memory. The goal is to return unused memory back to the operating system so it's available for other purposes. (You allocate a ton of memory, calculate some result, write the result to a file, and drop references to the memory. When will it be freed?)

Re: Why Discord is switching from Go to Rust

#120

These kinds of posts would be much more interesting if they discussed alternatives considered and rejected. For example why did they choose Rust over C++?

The article mentioned that they have already used Rust successfully in house, so when you consider that Rust is inherently safer than C++, it seems like they picked the right language.
Post reply on HN