News for hackers. Stuff that matters.
Re:Why Discord is switching from Go to Rust (2020) by reikonomusha on Monday February 22, 2021 @01:50PM (#26228636)
Meta-comment, and I’m not claiming this is what’s true about Discord.

Every time I see a company post about how they’re changing programming languages, I tend to believe it actually happened because engineers with enough political clout decided they wanted everybody to change to their preferred language, not truly because of technical reasons, but because they just wanted to be paid to write in a cool language. But, of course, you’d be lambasted by your colleagues if you didn’t provide technical reasons, so you go and hunt for technical reasons that seem insurmountable and build a case for it, turning a blind eye to perhaps less exciting solutions that don’t require a programming language change.

(It’s sort of like how a cop in America can find you doing something illegal in any circumstance if they look hard enough. Except in this case, it’s a matter of finding technical deficiencies.)

This strategy highly depends on clout though, which is why I think technical arguments are frequently really a façade. If, say, a junior programmer doesn’t have clout, even presenting an equivalent technical argument won’t lead to a change in programming language, especially if it’s the senior’s favorite. I’m sorry to say, but most tech organizations aren’t meritocratic or egalitarian in this way (and perhaps they shouldn’t be).

As it pertains to the article—which again I don’t claim is all “fake” politicking (I don’t know anything about or anyone at Discord)—they mostly ripped on garbage collection. They specifically talked about how GC was bad because their LRU cache had to be scanned, which was part of why they observed spikes in their metrics. I wonder why they didn’t try doing things like putting the LRU cache into foreign, unmanaged memory to avoid garbage collecting it. Easier said than done, but why not?

I think using any language with any serious and large project will find deficiencies in the language. At some point in a product lifecycle it’s more profitable to just work with and ameliorate those deficiencies than do rewrites where the new deficiencies will be completely unknown.

Re:Why Discord is switching from Go to Rust (2020) by silentsea90 on Monday February 22, 2021 @01:55PM (#26228741)
+1 going from meme language to meme language seems highly suspicious. Go and Rust are fine languages, but given these are relatively new and immature, I find it startling that Discord had to do writes/rewrites so often. I'd wager that if Discord had started sooner than 2015 (say, 2013ish) - we'd have seen Scala thrown into the fray as well.
Re:Why Discord is switching from Go to Rust (2020) by ericbarrett on Monday February 22, 2021 @02:06PM (#26228921)
In Discord’s defense, their product’s scope and userbase has increased orders of magnitude over just a few years. Setting language choice aside, one would expect several rewrites of core code and infra over this time.
Re:Why Discord is switching from Go to Rust (2020) by silentsea90 on Monday February 22, 2021 @02:24PM (#26229198)
My intention was to not set the language choice aside, especially where rewrites are squarely targeted at migrating to a different language.

Rewrites of services to decomp into different services, migrate to different datastores to scale up etc. is completely justified and is a good problem to have.

Re:Why Discord is switching from Go to Rust (2020) by sacado2 on Monday February 22, 2021 @04:05PM (#26230607)
Go is starting to get a bit old though. Version 1.0 dates back from 2012, 9 years ago. It's as old and mature as Java was in 2005.
Re:Why Discord is switching from Go to Rust (2020) by Seb-C on Tuesday February 23, 2021 @01:41AM (#26234460)
Not having a v2.0 does not mean it's old, it just means that they did not break backward-compatibility since then.
Re:Why Discord is switching from Go to Rust (2020) by mraza007 on Monday February 22, 2021 @02:00PM (#26228836)
Yup this makes me wonder why do companies go for relatively newer languages compared to old ones such as Java,C++ or C as they have been matured and has been widely used
Re:Why Discord is switching from Go to Rust (2020) by Laremere on Monday February 22, 2021 @02:28PM (#26229275)
Go was announced in 2009, and went 1.0 in 2012. Sure, it's "newer" than languages from the 90s, but calling it "new" when it's nearly a decade old doesn't pass the smell test. Serious software has been written in both Go and Rust, and real issues with Java, C++, and C that these newer languages address are well known.

Compare Go and C++, and I bet C++ has had more language changes since Go's 1.0 than Go has. That makes large portions of C++ "relatively new and immature" compared to Go.

Re:Why Discord is switching from Go to Rust (2020) by mraza007 on Monday February 22, 2021 @02:36PM (#26229404)
I agree with you on that but this still makes me question the problem they are trying to solve can't they solve in Go instead of switching to Rust.

Furthermore, A lot of companies to this date have there performance critical code written in C++ , C or Java

Such as you can take HFT for example they use C++ for most of their trading applications instead of newer languages

I'm definitely not saying C++,C or Java is better than Rust or Golang each language has its own pros and cons

Re:Why Discord is switching from Go to Rust (2020) by tjalfi on Monday February 22, 2021 @03:39PM (#26230261)
> I agree with you on that but this still makes me question the problem they are trying to solve can't they solve in Go instead of switching to Rust.

High performance systems in GC languages often preallocate or use object pools to reduce time spent in the garbage collector. LMAX's Disruptor, for example, allocates all memory at startup; no additional memory is allocated so the garbage collector never runs. Generational GCs make this strategy more effective because long-lived or large objects are traced rarely or not at all. Another option for trading systems is to run garbage collection after hours when the market has closed.

Go's GC is conservative, not generational, and has a hard coded collection interval of 2 minutes; you pay for a GC even if no memory has been allocated. There are only a few configuration options for Go's GC; if it doesn't work for your use case then you can either fork or use a different language.

Re:Why Discord is switching from Go to Rust (2020) by jimbokun on Monday February 22, 2021 @03:19PM (#26230015)
They did solve it in Go, then got performance improvements re-implementing a small piece in Rust.

This is more about scale and saving computing costs, than proving out a business idea or implementing new features.

Re:Why Discord is switching from Go to Rust (2020) by devmor on Monday February 22, 2021 @02:43PM (#26229515)
Not all problems are specifically technical in nature.

One of the big issues with Go is that it's got a steep learning curve. (There was an article about this posted on HN yesterday, in fact)

Rust, by contrast, is an extremely easy language to learn. Of all the languages I've picked up at least partially in my ~12 years of professional programming, Rust was probably second only to to PHP in "get up and start running with it".

If Discord is trying to pick up new developers, or cross discipline seniors to improve their talent pool, Rust is definitely a better choice than Go.

Re:Why Discord is switching from Go to Rust (2020) by steveklabnik on Monday February 22, 2021 @02:56PM (#26229699)
Not to discount your experience, because I think that this topic has a lot of nuance and is very different on an individual level, but most people regard Go as easy to learn, and Rust as difficult to learn.

I wish we had a good way to evaluate this question in a quantitative way, but I haven't seen one yet. So reasonable people are going to disagree on the answers here.

Re:Why Discord is switching from Go to Rust (2020) by snth on Monday February 22, 2021 @02:53PM (#26229665)
This is the reverse of the characterization of the two languages I usually see. I usually see "Go is easy to learn and use" and "Rust is hard to learn but has performance advantages". I often see comments about how you "really need to go read the Rust book" and not just try to pick up Rust on the fly.
Re:Why Discord is switching from Go to Rust (2020) by domano on Monday February 22, 2021 @02:57PM (#26229730)
This is the first time i have seen this argument. Just understanding ownership seems more complex to me than writing a simple web app in go or PHP for that matter.

I am sure rust is great but it is at the very least more difficult to learn then go.

Re:Why Discord is switching from Go to Rust (2020) by icod on Monday February 22, 2021 @06:38PM (#26232123)
to this day I can't wrap my head around the need to unwrap almost every single variable/function/whatever.

I don't get Rust. I got Go very easily. Rust just doesn't make sense for me.

In Go I can just write down my thoughts and they translate to code easy. I don't even know which mental game I have to play in Rust. And all the conventions in Rust are another step. The final nail is the un-community of Rust. I still have no idea how to write a simple RESTful http server with a mongodb backend. I've asked only to have been met with downvotes on Reddit. The official MongoDB discourse didn't answer either.

Time and again I want to do something with it but every time I just quit frustrated and irritated of the complexity of everything in Rust land.

Re:Why Discord is switching from Go to Rust (2020) by cyphar on Monday February 22, 2021 @08:06PM (#26232721)
> to this day I can't wrap my head around the need to unwrap almost every single variable/function/whatever.

Think of Result as (foo, err) bundled into one thing. result.unwrap() is then equivalent to:

    if err != nil {
        panic(err)
    }
And the ? operator is:

    if err != nil {
        return ..., err
    }
You don't need to unwrap (or ?) everything, just things that return a Result -- which is the same as functions which return an error in Go. The advantage of Result is that you can never forget to handle the error because the compiler requires you to get the value out of the Result in such a way that you have to handle errors.

Don't get me wrong, there are complicated things in Rust, I just don't see how Result-based error handling is one of them. This is also not a new idea, many languages have something similar.

Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @02:04PM (#26228889)
Because excited developers generally means more satisfaction from work. And one way to keep developers excited is to give them new toys to play with.

Also mature languages, even though they're more stable, are just more of a pain to work with since they don't have a lot of the new shortcuts.

For something like Discord, Rust is perfect.

Re:Why Discord is switching from Go to Rust (2020) by collyw on Monday February 22, 2021 @02:56PM (#26229705)
Crap developers get excited by new tech. Good devs want to get problems solved. If a new tech is the best solution then use shiny new tech. Usually it´s not the best choice.
Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @03:25PM (#26230069)
What a ridiculous statement. You can be excited by new tech and realize how it can solve your problems.
Re:Why Discord is switching from Go to Rust (2020) by jjav on Tuesday February 23, 2021 @03:21AM (#26234978)
New languages lack most of what is needed to be highly productive. Tooling is minimal to none. Libraries are sparse and still catching up, this takes many years. Many gotchas remain undiscovered and will bite you in production.

To get actual product work done with optimal efficiency, a mature ecosystem will always win.

Re:Why Discord is switching from Go to Rust (2020) by collyw on Monday February 22, 2021 @03:53PM (#26230445)
And you can be maintaining a system built by developers who got excited by shiny new tech and made a load of inappropriate technology choices because they were flavor of the month and looked good on their resumes.
Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @04:30PM (#26230911)
It sounds like you've had bad experiences with some devs and you're applying that to everyone.

Maintaining a codebase written in C is far far harder than one written in Java and that's far harder than one written in Go.

Re:Why Discord is switching from Go to Rust (2020) by collyw on Thursday February 25, 2021 @11:47AM (#26264841)
I have worked in tech long enough to see some common patterns. It's usually intermediate devs (though not always) who get excited by new tech. The same people are usually pushing to use shiny new tech in places where it isn't needed. You don't get cynical old school devs trying to replace working parts of the tech stack with tech less than 5 years old.

Personally i think developer skill has far more to do with maintainability than language choice. And I have worked with a lot of shit code.

Re:Why Discord is switching from Go to Rust (2020) by mraza007 on Monday February 22, 2021 @02:28PM (#26229282)
I agree with you, developers do get excited when are using newer technologies but the question is what if a new problem arises and they might not be able to find a to it solution.

Just like how they did in this case completely switching from Go to Rust

Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @02:33PM (#26229342)
Then they'll have to cross that bridge when they come to it. Nothing of this article gave me the impression that the second they saw this bug they're like WELL TIME TO SWITCH.

I'm sure we're glossing over probably hundreds of hours of investigations by dozens of people.

Re:Why Discord is switching from Go to Rust (2020) by jhgg on Monday February 22, 2021 @02:43PM (#26229499)
We kept dealing with GC pauses in go, and eventually after investing a bunch of time trying to fix this - we decided to research what it'd be like to rewrite it in another language.

The service itself is pretty simple, so it wasn't a gargantuan task. So it was either, rewrite this again in Go (using off-heap data structures to avoid GC pauses, which makes the software both harder to maintain, and also less idiomatic) or try a new language where we won't have these issues - where we don't have to resort to clever hacks to work around the runtime system.

Since then we've continued our investment in Rust, after success of this project (and many others we've yet to blog about as well.)

Re:Why Discord is switching from Go to Rust (2020) by flippinburgers on Monday February 22, 2021 @05:56PM (#26231806)
Excitement < the countless hours required to rewrite a complex system in a non-trivial language.
Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @06:29PM (#26232057)
And do you have numbers to back up excitement of devs vs their productivity?

It seems like everyone is just applying their subjective view. Which is fine. Just don't assume your equation works for everyone and every business.

Re:Why Discord is switching from Go to Rust (2020) by doodpants on Monday February 22, 2021 @02:16PM (#26229067)
The simplest answer is that these newer languages were created specifically to address problems with existing languages. If a new language has no compelling reason for anyone to switch to it, why bother to create it in the first place?
Re:Why Discord is switching from Go to Rust (2020) by johannes1234321 on Monday February 22, 2021 @02:20PM (#26229148)
It's not that easy. A new language starts because a set of developers has a problem, however that doesn't mean that others share that problem or agree to the choices and solutions made. Rust seems to be in a good situation where this worked for large parts, but many languages came and got no or only short attention.
Re:Why Discord is switching from Go to Rust (2020) by chc on Monday February 22, 2021 @02:32PM (#26229329)
There are actually very good reasons to go with Rust over those languages, which were the motivating reasons Rust was developed in the first place. Rust supports lower-level development than Java, offers much stronger safety and correctness guarantees than C or C++. This is why Google's security team also supports reimplementing C libraries in Rust (https://security.googleblog.com/2021/02/mitigating-memory-sa...).
Re:Why Discord is switching from Go to Rust (2020) by bgorman on Monday February 22, 2021 @02:16PM (#26229066)
Have you ever considered that programming language design is an evolving field, and programming languages directly influence programmer productivity?

C++, C and Java are old, so some mistakes can be forgiven. However there are problems with these languages that new languages have addressed.

Do you think a car from 1985 is better than one from 2015? The same applies to programming languages. Given the explosion of programming, it is absurd that the best ideas from PLT are not in mainstream languages.

Re:Why Discord is switching from Go to Rust (2020) by scoutt on Tuesday February 23, 2021 @03:16AM (#26234950)
> programming languages directly influence programmer productivity

A complete re-write (preceded by a very deep analysis) is exactly the opposite of productivity.

> problems with these languages that new languages have addressed.

And new problems were introduced... case in point: this very article.

> Do you think a car from 1985 is better than one from 2015?

Depends on the car...

I think this analogy would be better: "Do you think a hammer and screwdriver from 1985 are better than the ones from 2015?"

Re:Why Discord is switching from Go to Rust (2020) by franga2000 on Tuesday February 23, 2021 @05:30AM (#26235693)
I definitely see the appeal of Java (used to be my main lang), but I would never in a million years base a company's flagship product on C or C++ unless it was a domain requirement (embedded, kernel, etc.). It's just not safe.
Re:Why Discord is switching from Go to Rust (2020) by dkarl on Monday February 22, 2021 @06:01PM (#26231853)
There's a difference between starting new projects and rewriting old ones. I have 7+ years of professional C++ under my belt and probably wouldn't start a new project in it. Same with Java. Sometimes new things are better.
Re:Why Discord is switching from Go to Rust (2020) by wrenky on Monday February 22, 2021 @02:04PM (#26228888)
Easier to hire people working in the new hot languages, and get younger programmers out of college.
Re:Why Discord is switching from Go to Rust (2020) by ModernMech on Monday February 22, 2021 @02:22PM (#26229169)
At the same time, in college we are teaching our students Java and C++ because that's what companies expect our students to know. Half our CS curriculum is in Java. The students I teach loathe C and C++ and want to learn Rust, but we won't teach it to them except in an experimental elective that won't count toward their graduation. So it's hard to say how many young programmers out of college actually know these "new hot languages".
Re:Why Discord is switching from Go to Rust (2020) by mraza007 on Monday February 22, 2021 @02:25PM (#26229221)
I totally agree with you on this comment since as I college graduate I learned Java , C++ ,C and python but I was exposed to Golang and Rust through online discussion forums.

Plus most of the organizations still write code in matured languages such as C,C++ and Java.

Re:Why Discord is switching from Go to Rust (2020) by johannes1234321 on Monday February 22, 2021 @02:18PM (#26229100)
I don't think so. There is a full load of people with experience in C++ or Java, but people with experience in performance critical (whatever that means) Rust code is more limited for being a newer language. You however win on the hipness scale and attention in places like hacker news.

As others have said, however, a big factor certainly is that an internal lead developer lobbied for Rust, which they experimented with.

Re:Why Discord is switching from Go to Rust (2020) by johnnycerberus on Monday February 22, 2021 @02:49PM (#26229601)
> we'd have seen Scala thrown into the fray as well.

Scala has already found its niche in Big Data, streaming and distributed systems. Usually, the stack that you can find in my area, consist mostly of Java codebases, sprinkled with some Scala services that are purely data-oriented. There's a high probability that Discord is already using Scala.

Re:Why Discord is switching from Go to Rust (2020) by spoiler on Monday February 22, 2021 @03:36PM (#26230229)
> I tend to believe it actually happened because engineers with enough political clout decided they wanted everybody to change to their preferred language, not truly because of technical reasons, but because they just wanted to be paid to write in a cool language.

I would say it's cool _because_ of the technical reasons, though! You make it seem like people are inventing technical reasons to make rust seem cool. I could make a long "technical reasons" list why I would personally prefer to work in Rust, but it boils down that it makes me more productive, and the code more performant with fewer gotchas and less sacrifices/compromises (compared to say C++ or C). Do I think Rust is cool? I guess... But that which attracted me to Rust was there already; I didn't have to make it up[1].

I understand not every language is for everyone. I've had colleagues dismiss rust simply because they prefer C++ (and we work with C++). Some will even agree Rust is better when presented with technical reasons, but still not like Rust "just because."

> I wonder why they didn’t try doing things like putting the LRU cache into foreign, unmanaged memory to avoid garbage collecting it. Easier said than done, but why not?

I write Go intermittently since I participate a little in the Kubernetes ecosystem, and haven't dwelled that deeply into it. How would this be done without reaching for C, though? Or would it be fitting to swap languages in this "subset" of the implementation?

[1]: I feel like "make up" is the wrong phrase here, but I can't think of a better one right now. I guess what I want to say that Rust's "cool" reputation is well deserved. I don't think the technical reasons are made-up to serve as office-politics cannon fodder.

Re:Why Discord is switching from Go to Rust (2020) by hedgehog on Monday February 22, 2021 @03:09PM (#26229867)
Agree, Rust seems like a good choice but I'm curious why they needed to replace Go. GC pause time is mostly due to the amount of pointer-containing heap memory. Moving the the cache storage to slabs of pointer-free "dumb" slices should pretty much avoid the problem so long as you force GC frequently (large heap will confuse the heuristic). Shard the slabs across a handful of goroutines, one channel each to handle locking, and that should perform fine compared to an equivalently complex Rust implementation.
Re:Why Discord is switching from Go to Rust (2020) by ctvo on Monday February 22, 2021 @05:53PM (#26231771)
The article lays out the points as if they exhausted all their Go options and ran into some deep language problem. I agree with you that this isn't a huge deal in Go, and could have been solved without a language, tooling, etc. change.

It reads like a tool (Rust) looking for a problem.

Re:Why Discord is switching from Go to Rust (2020) by agumonkey on Monday February 22, 2021 @05:42PM (#26231671)
I skimmed through this https://blog.kraken.com/post/7964/oxidizing-kraken/ yesterday

now its php->rust so a widely different migration but rust was measured for its latency cutting value, not just fad factor

I'd believe discord and others are on rust for this and not just the new shiney (that would be to their loss)

Re:Why Discord is switching from Go to Rust (2020) by alephu5 on Monday February 22, 2021 @03:54PM (#26230469)
This is my experience too. I've seen a lot of decisions made due to personal preference, at considerable technical and financial expense.

The most recent example was a replacement for a complex YAML DSL, served by spring config sever and interpreted by a python program on every instantiation. This thing was literally using 20% of our CPU cycles over the whole compute cluster and estimated to cost around €6k per month. Long story short I provided a fully working pre-processing solution with effectively no runtime cost, no dependency on the spring config server and a more powerful & type-safe DSL. It was dhall with a bit of bash and python, although you could also have used jsonnet or any configuration language. Another developer with more clout pushed me out in favour of their own solution, which I believe was to keep me away from his political pedestal. A few months later I left and from what I've heard the company is still burning 20% of it's compute budget on this...

Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @01:51PM (#26228660)
Well, on the positive side a company like Discord moving to Rust means better tooling than what is currently available. So that's exciting.
Re:Why Discord is switching from Go to Rust (2020) by reikonomusha on Monday February 22, 2021 @01:55PM (#26228752)
Better tooling for the programmers you mean? I don’t regularly program in either language (Go or Rust), but I thought Google ran a pretty tight ship on good Go tooling, except with a bit of module SNAFU in its past.
Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @01:58PM (#26228803)
Go's tooling is pretty nice. I was talking about better tooling for Rust. Maybe JetBrains will make a Rust-specific IDE.

So far though rust-analyzer >>>>> JetBrains' plugin

Re:Why Discord is switching from Go to Rust (2020) by zn44 on Monday February 22, 2021 @02:04PM (#26228897)
i believe this also often happens when original designers of the systems are out and not involved anymore, the new team wants to rewrite everything from scratch but that's hard to sell. So they find few technical reasons and pick some latest fun tech to play with.
Re:Why Discord is switching from Go to Rust (2020) by FalconSensei on Monday February 22, 2021 @03:26PM (#26230087)
Yeah, unfortunately in some cases is easier to sell rewriting to a new language, than just refactoring/rewriting in the current stack.
Re:Why Discord is switching from Go to Rust (2020) by xtracto on Monday February 22, 2021 @02:36PM (#26229396)
Right, specially because last thing I read Discord was using Elixir: https://blog.discord.com/scaling-elixir-f9b8e1e7c29b
Re:Why Discord is switching from Go to Rust (2020) by adamnemecek on Monday February 22, 2021 @02:51PM (#26229631)
Re:Why Discord is switching from Go to Rust (2020) by MengerSponge on Monday February 22, 2021 @02:10PM (#26228986)
Ham Sandwich Development
Re:Why Discord is switching from Go to Rust (2020) by unanswered on Monday February 22, 2021 @01:54PM (#26228722)
> I wonder why they didn’t try doing things like putting the LRU cache into foreign, unmanaged memory to avoid garbage collecting it

Ah yes, because what I really want out of an ostensibly memory-safe language like go is to have to resort to C, or what amounts to C, to get anything done. Or I could use a language which doesn't have this garbage issue. But that would just be political nonsense apparently.

Re:Why Discord is switching from Go to Rust (2020) by reikonomusha on Monday February 22, 2021 @01:57PM (#26228784)
I’m not saying that it’s a perfect solution, and yes, using C memory defeats the purpose of memory safety. But it’s a trade-off, as most engineering things are. Rewriting in Rust is also a gigantic trade-off along many many more axes, and Rust isn’t immune to people using `unsafe` in practice either. In both Go and Rust, it’s possible to carefully engineer so as to isolate where sources of memory unsafety are, either through the language or through principled policy and software design.
Re:Why Discord is switching from Go to Rust (2020) by jzoch on Monday February 22, 2021 @02:28PM (#26229277)
You make an excellent point i just wanted to correct your usage of "unsafe" in rust: It does not signify "im writing c" now as many invariants are still upheld in Rust even with the usage of unsafe. Id say its still much "safer" than using unmanaged memory in go as you have far more facilities you may use and more invariants are upheld.
Re:Why Discord is switching from Go to Rust (2020) by hiptobecubic on Monday February 22, 2021 @10:35PM (#26233565)
Also, they didn't have to do this.
Re:Why Discord is switching from Go to Rust (2020) by aaomidi on Monday February 22, 2021 @02:06PM (#26228927)
I really am glad Discord did not go with this route. It's a chatting application, which means you're dealing with a TON of user generated content. Unmanaged memory and user generated content is an absolutely terrible idea.
Re:Why Discord is switching from Go to Rust (2020) by ctvo on Monday February 22, 2021 @05:50PM (#26231747)
...?

The article is about a very specific service handling state for if you've seen a message in a channel. It has nothing to do with processing user content.

Re:Why Discord is switching from Go to Rust (2020) by unanswered on Monday February 22, 2021 @02:21PM (#26229168)
The problem with go here is (a) garbage collection, such that rust likely wouldn't have needed any unsafe outside of well-known libraries; and worse (b) when you need to do stupid C shit in go, there's no `unsafe` to contain it; it just spews over the rest of your code.

"Principled policy and software design" is exactly what's needed to get rid of memory bugs in C too! So we can conclude that these things are impossible, or else we would not need memory safe languages in the first place. Since it's increasingly apparent that go requires these mythical safeguards after all, it's safe to say that it is not a memory safe language in the useful sense.

Re:Why Discord is switching from Go to Rust (2020) by reikonomusha on Monday February 22, 2021 @02:38PM (#26229433)
In general, I think this all-or-nothing attitude paired with FUD language is detrimental to good engineering. Memory unsafety is generally bad, I get it. But it’s exaggerating to say that these things “spew” all over codebases, or that you’re entering some inescapable memory hell that has no way to be treated properly. The original proposal was to manage some memory yourself within Go to solve one very specific problem with a very specific module of code. That’s not a lot of surface area and has a clear API. It doesn’t seem unfathomable that qualified, highly paid engineers can’t do a good job solving that problem comprehensively without rewriting everything else.
Re:Why Discord is switching from Go to Rust (2020) by ufo on Monday February 22, 2021 @02:06PM (#26228929)
I think the question is why not rewrite just the LRU cache in C/C++/Rust (whatever floats your boat), as opposed to rewriting everything in Rust.
Re:Why Discord is switching from Go to Rust (2020) by masklinn on Monday February 22, 2021 @02:09PM (#26228978)
One reason would be that doing that would require switching over to cgo, at which point you deal with the PITA that is an FFI, and the PITA that is cgo (it's easy to enable but it drastically alters your "game plan").

And here the cache is essentially the entirety of the micro-service:

> [The service's] sole purpose is to keep track of which channels and messages you have read.

so it's a giant map of (user, object) -> read flag or something along those lines. The DB commit and service input would be very light, and not really your main concern.

Re:Why Discord is switching from Go to Rust (2020) by fiddlerwoaroof on Monday February 22, 2021 @02:16PM (#26229077)
The question I’d have is “why use a custom cache at all”, this sounds like a problem that has a whole pile of battle-tested off-the-shelf solutions.
Re:Why Discord is switching from Go to Rust (2020) by jhgg on Monday February 22, 2021 @02:51PM (#26229629)
The original implementation of this "service" was in Redis using lua scripts.

We hit the performance ceiling of redis, and rather than deciding to go with redis-cluster, and dealing with the headache of managing persistent redis, we went this way, so we could consolidate data storage to scylladb/cassandra (it was cassandra at the time of rewrite, scylla now since we've migrated our data stores over).

Re:Why Discord is switching from Go to Rust (2020) by muzaffarpur on Monday February 22, 2021 @06:15PM (#26231962)
any reason to not consider Aerospike for Cache?
Re:Why Discord is switching from Go to Rust (2020) by jhgg on Monday February 22, 2021 @07:11PM (#26232361)
We don't have any operational experience with Aerospike.

We have a bunch of operational experience with C*/ScyllaDB.

Re:Why Discord is switching from Go to Rust (2020) by stryan on Monday February 22, 2021 @02:19PM (#26229127)
That sounds like basically what they did; they rewrote the ReadStates service in Rust and it sounds like that's basically a wrapper around an LRU cache. The rest of Discord is still Go/Elixer/whatever else they use.
Re:Why Discord is switching from Go to Rust (2020) by phabora on Monday February 22, 2021 @04:00PM (#26230537)
This is a fine suspicion to have. It’s a fine theory, even. But why raise this suspicion for this particular neo-language case? Why not raise it across the board?

Such a theory is more robust if it predicts how the organization will work in general. Thus one would also be partial to suspecting that neo-languages are declined for political reasons as well -- that a few powerful voices simply prefer to find other solutions, and then find post-hoc technical arguments.

Such a theory works less well if it is only used to explain some particular (ostensibly) technical decisions.