TRANSCRIPTEnglish

I Can't Believe Rust is Replacing Java

7m 46s1,376 words210 segmentsEnglish

FULL TRANSCRIPT

0:00

So XAI just open sourced the X

0:01

recommendation algorithm and they

0:03

massacred my boy. Scrolling down, I

0:06

expected to see language stats like that

0:07

of the 2023 repo. But no, they were

0:10

gone. The only languages listed, Rust

0:14

and Python. So this wasn't just a simple

0:16

refactor of the algorithm. It was a

0:18

complete rewrite. One that had me

0:20

thinking, wait a second, I thought Rust

0:23

was supposed to replace C and C++, not

0:27

Java and Scala. So I wanted to take a

0:29

closer look and figure out why replace

0:31

Java with Rust. And luckily for me, we

0:34

have access to both code bases. So we

0:36

can take a look at exactly what they

0:38

replaced like Twitter's custom scholar

0:40

framework product mixer which they use

0:42

to build services like homemixer what

0:45

serves the for you recommendation feed

0:47

and systems that produced handgineered

0:49

systems like sim clusters tweep cred

0:52

real graph early bird and dozens more

0:55

interconnected microservices that made

0:57

up this algorithm. So the engineers

0:59

would literally sit down and say, "hm,

1:01

let's add a feature for whether the

1:02

author of a post replied to the comments

1:05

and weight it at 75." That's

1:07

handineering.

1:09

Yeah, that all got completely ripped out

1:12

of the codebase. No more handgineered

1:14

features or in other words, no more Java

1:17

and Scala because these are the

1:19

languages that were used to build those.

1:20

So those dozens of interconnected

1:22

microservices went away and after it was

1:24

all rewritten which we'll dive into we

1:27

were left with this four directories

1:30

four components that is the entire

1:33

algorithm kind of we'll get into that

1:35

rewrite here in just a second but we

1:37

need some context first you see

1:38

homemixer which was our last little bit

1:40

of scaline java left was entirely

1:43

rewritten in rust it still serves the

1:46

for you feed but with a completely

1:48

different approach that I'll explain.

1:49

Thunder, also written in Rust, is an

1:52

in-memory post store. Candidate

1:54

pipeline, Rust again, is just a generic

1:56

framework for building recommendation

1:58

pipelines. Here's what those pipeline

1:59

traits look like. And Phoenix written in

2:02

Python, which is the heart of it all. It

2:04

has retrieval for out of network, but

2:06

also a Grockbased transformer, which

2:09

does the actual ranking of your post and

2:11

what you should and shouldn't see based

2:13

on your interactions and your behavior.

2:15

That's the new system. But in the old

2:17

system, pipeline components were in

2:18

Scala classes, extending product mixer

2:21

traits. Here's one of their scores. It's

2:23

Scala's scorer trait. Now, here's the

2:26

Rust equivalent. It's the same pattern,

2:28

traitbased pipeline composition, but

2:30

Rust gives you, as much as I hate to

2:32

admit it, uh quite a few perks like

2:35

async native code, explicit thread

2:37

safety with send and sync bounds, and

2:39

zero garbage collection overhead. Not

2:41

only that, but with Rust, as we know,

2:43

the compiler enforces correctness.

2:45

Whereas with Scala, a lot of it is left

2:48

to runtime. The old algorithm also had

2:50

explicit hand-tuned weights. So like how

2:52

I said you reply to comments plus 75 or

2:55

if you report a post minus 369. All of

2:59

these numbers were handpicked by humans

3:02

presumably throughout numerous meetings

3:05

with lively debates and fine-tuned over

3:07

the years. And most of these

3:09

heruristics, just like the handgineered

3:11

features, ripped right out of the

3:13

codebase, because Phoenix, the Gro's

3:15

transformer, doesn't need them, at least

3:18

how they were. It learns engagement

3:20

patterns directly from your behavior.

3:23

Which is why when you click on a single

3:24

political post, your entire feed is just

3:26

filled with politics, hoping you get

3:28

caught up in it and stay on the platform

3:29

forever, arguing with what are probably

3:32

foreignrun bots. Now, back to HomeMixer

3:34

real quick. And the old algorithm

3:35

homemixer orchestrated the dozens of

3:37

services calling sim clusters for

3:39

community data, tweet cred for

3:41

reputation scores, real graph for

3:43

relationship strength, then combining

3:45

all of those signals with the hand-tuned

3:47

weights. That was the algorithm. Now

3:50

homemixer just fetches candidates from

3:52

thunder in network and Phoenix retrieval

3:54

out of network, then feeds it to the gro

3:56

transformer in Phoenix to score. It all

3:59

got simpler. The codebase shrank because

4:02

the intelligence moved into the model.

4:04

But there is an issue with this codebase

4:06

and that is well it's not reproducible

4:08

for us. We have no model weights. There

4:10

are no cargo.l files. So we can't even

4:13

compile it if we wanted to. The proto

4:15

definitions are external and all of that

4:17

logic from the old algorithm is now

4:19

inside the model which we can't see. We

4:22

went from a 48 million parameter mask

4:24

net running inference to a gra

4:26

transformer that absorbed what all of

4:28

those microservices used to do which I

4:31

think is a clear reason why XAI replaced

4:34

Java and Scala with Rust in Python. Now

4:37

there's no official engineering blog yet

4:39

but we can connect the dots. It's not

4:41

that all of these microservices and the

4:44

codebase was rewritten in Rust and

4:47

Python, but that it was all absorbed by

4:49

the model and they wrote the Rust and

4:51

Python code to really just connect and

4:53

orchestrate everything. And for good

4:54

reason, I think. Thunder, the in-memory

4:57

post store, well, it needs

4:58

submillisecond latency for real-time

5:01

serving. And on the JVM,

5:03

garbage collection pauses are

5:05

unpredictable. This is JVM's kryptonite.

5:07

At least in my experience, it's always

5:09

been my biggest complaint about it. And

5:11

while you'd be fine 99% of the time,

5:12

you'll randomly get a 200 millisecond

5:14

pause right when you're serving a feed

5:16

request, which I would say is

5:18

unacceptable. And that's why X decided

5:20

to use Rust. But this seems to happen

5:23

more on X than ever before. So, I don't

5:26

know if they're just vibe coding their

5:27

Rust code or or what they're doing over

5:29

there because it ain't working right.

5:31

And also, all of Elon's companies use

5:33

Rust in one way or another from Tesla

5:35

and SpaceX. It seems that XAI was built

5:38

from day one with this exact stack in

5:41

mind. We are looking at a genuine

5:43

architectural shift in the industry.

5:46

Discord rewriting a lot of Go in Rust.

5:48

Cloudflare building a whole EngineX

5:51

replacement in Rust Linux accepting Rust

5:53

into the kernel. And now this a decade

5:56

of Scola microservices being replaced by

5:59

four Rust components. one is technically

6:02

Python and a transformer that learned to

6:05

do what a thousand lines of hand-tuned

6:08

code used to do. The question isn't even

6:11

whether Rust is replacing Java or Scala.

6:14

It's whether AI is AI is replacing

6:16

algorithms that used to be this vast

6:19

codebase. And Rust, well, it just

6:21

happens to be the language that people

6:23

reach for to glue all of the pieces

6:25

together. And if you want to do that,

6:26

you need to understand how these systems

6:28

actually work. That's why I've been

6:30

using Brilliant because their how AI

6:32

works course actually walks you through

6:34

transformer architecture and attention

6:36

mechanisms, the stuff powering the

6:38

systems like Phoenix and Grock. But

6:40

what's nice about it is that you're not

6:42

watching lectures. You're solving

6:43

problems until the concepts actually

6:45

click. Because if you've ever thought,

6:47

I'm not a math person, it it is likely

6:50

due to how you were taught, not because

6:53

you're not a math person. And Brilliant

6:55

accounts for this in all of their

6:56

programs from math and physics to

6:59

computer science and programming by

7:01

personalizing everything. They start you

7:03

at the right level and they keep pushing

7:05

you forward as you get better. It's also

7:07

a very good way to just kill some

7:09

downtime because you're able to do a lot

7:11

of these problems on your phone. So if

7:13

you're sitting there waiting for your

7:14

doctor or waiting for whatever, you can

7:16

just knock out a couple of these instead

7:18

of scrolling. Do something that actually

7:19

helps you. So, if you want to actually

7:21

understand what's happening when a model

7:22

learns engagement patterns instead of

7:24

relying on handtune weights, go to

7:26

brilliant.org/forest

7:29

night free for 30 days and my viewers

7:31

get 20% off annual. Just click the link

7:34

in the description. If you want me to go

7:36

deeper on any of this, the Grock

7:37

architecture, the pipeline patterns, or

7:39

how this compares to Meta or Tik Tok,

7:42

just let me know in the comments.

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.