HomeVideos

We’ve lost the Tech

Now Playing

We’ve lost the Tech

Transcript

478 segments

0:00

There are some engineering marvels out

0:01

there that end up living rentree in my

0:03

head for just years on end. And I I go

0:06

back and I think about how cool they

0:07

are, but there's a new one that's living

0:09

in my head. Uh not because of how cool

0:12

it is, but because of how ridiculous it

0:14

is. I am talking about Claude Code and

0:17

their Tui. Now, this tweet caught my

0:18

attention and has been just eating me

0:20

alive and now I have to make a video

0:22

about it. Okay, so let me just read it

0:24

to you. Most people's mental model of

0:26

Claude Code is that it's just a TUI.

0:27

That's what I thought it was at least.

0:29

But it's actually really closer to a

0:31

small game engine. Okay. Okay. Whoa. I

0:33

didn't realize rendering. I mean, I

0:35

guess if you if you really think about

0:36

it, you know, like if you really dig

0:38

down into the nuts and bolts, you can

0:40

kind of imagine that a screen every

0:42

single one of the characters is kind of

0:44

like a pixel, right? Which means it's a

0:47

game, right? Except for your bounds are

0:50

like 30 by 120 pixels. So, you know,

0:54

2400 pixels. We're talking about pretty

0:57

easy rendering going on here, right?

0:59

Like you could make a decision about

1:01

every single pixel many, many times,

1:03

right? Wo there, tough guy. For each

1:05

frame, our pipeline constructs a graph

1:07

from React, then lays elements out,

1:09

rasterizes them in 2D, diffs them

1:11

against the previous screen, and finally

1:12

uses the diff to generate an ANIE

1:14

string. If you're not familiar with

1:15

ANIE, ANIE effectively is the thing that

1:17

allows you a either to color text that's

1:19

on the terminal or b you can put your

1:21

cursor in places. Uh you can also clear

1:23

the screen with an escape sequence. Open

1:26

bracket 2J would effectively clear the

1:29

entire screen inside your terminal.

1:30

There's all these little things. That's

1:31

how ANI works, right? It's an escape

1:33

character plus an open bracket plus some

1:34

sort of code. Don't worry about ANIs.

1:36

It's really irrelevant in this situation

1:38

other than it just requires a bit more

1:39

memory to generate and that's it. And so

1:41

they have roughly 16 milliseconds frame

1:43

budget. And so we roughly have five

1:45

milliseconds to go from React to Ansie.

1:47

That means React takes 11 seconds to lay

1:50

out something on approximately 2400

1:52

pixels. We're going to talk about this.

1:54

Okay, I'm going to I'm going to first

1:55

off, I'm going to tell you some

1:56

engineering management takes that I

1:57

have. Okay, and I think they're very

1:59

very important. More so, I'm going to

2:00

give you some, hey, this is how I think

2:02

you should engineer things. And then

2:04

lastly, I'm going to show you that I

2:05

think whatever they're running up

2:06

against is a design of their own making

2:09

and a downfall of engineering in the

2:11

most truest sense. So, first off, as an

2:14

engineering manager, if I had someone

2:15

come up to me and say, "Hey, I'm going

2:17

to make a TUI and we have all these

2:20

constraints and it involves like say

2:22

frames per second." My very first

2:24

question would be like, "Oh, wow. Okay,

2:25

so you must have a bunch of stuff

2:27

changing on your scene to require uh

2:30

stuff to be rendering at that kind of

2:32

rate, right? Like what what's changing?

2:33

What's going on? Why do we have to have

2:35

a frames per second to ever even begin

2:37

with? I want to know. I want to

2:38

understand more." And if the answer

2:40

isn't we're writing a full a full-blown

2:42

game and every single key press and

2:45

everything needs to pass through a tick

2:46

and we need to have this really verbose

2:48

a beautiful way to handle everything. I

2:50

would go you got to stop. Something has

2:52

gone terribly wrong here. What are you

2:54

doing? When I hear this that claude

2:57

code, which if you're not familiar with

2:59

is just interacting with a model that

3:01

lives on the internet that takes seconds

3:03

to minutes to respond and leaves little

3:05

breadcrumbs along the way, requires 60

3:07

fps. This to me feels like a failure in

3:11

engineering management and also a

3:12

failure in engineering. Now granted I

3:15

don't work there. I don't know the

3:16

constraints they're working against.

3:17

Maybe just maybe there are things that I

3:20

don't understand that could make this

3:21

very very hard and maybe it's supposed

3:23

to make sense if one you know if I were

3:25

to understand the difficulty. So I'm

3:27

willing to concede that I don't

3:28

understand everything. If I were a

3:30

manager and I heard this I would say no

3:32

way. Back to the drawing board. Now as

3:33

far as engineering goes if I was an

3:35

engineer attempting to solve this

3:36

problem. First off, if I had to generate

3:39

text into a fixed box along with the

3:41

scroll history background, which is

3:43

apparently what they want, you you

3:44

should be able to scroll up and see all

3:45

your previous stuff. And you want to be

3:47

able to have some dynamic elements on

3:48

here along with some other stuff.

3:50

Obviously, I would have to set up a

3:52

situation in which I have some layers,

3:53

right? I have my dynamic side of things

3:55

right here, and then I have my actual

3:57

scroll back going on right here. And

3:59

then I have to construct these things to

4:01

be able to actually draw what's

4:03

happening on screen. Correct? But here's

4:05

the deal. I would never set up an FPS

4:08

for this. It makes no sense. And here's

4:11

why. You only have a few things that

4:13

cause a render. One, you have input. So,

4:16

when I start typing, I need to see my

4:18

characters going on to the prompt,

4:21

right? Okay. So, there we go. We have

4:23

our characters. For whatever reason,

4:24

Claude Code also wants a throbb, right?

4:27

That's what they call it. A big old

4:28

throber. Something that's like letting

4:30

you know like, "Hey, I'm rendering."

4:31

Like right here. See, if I say, "Tell me

4:33

how to talk to a woman." You can see the

4:34

throber right here. It's throberating.

4:36

Hey, Blood Code teaching you how to RZ,

4:39

just in case you're wondering. Okay,

4:41

treat her as an individual person, not a

4:43

category. Boom. Nothing says autism like

4:46

that answer. [laughter]

4:50

Hey there, fellow woman. I hear you like

4:53

flower. So, you have the throbb, which

4:55

needs a you know that that thing was

4:56

rendering like what three, four times a

4:58

second. And then lastly, you have output

5:00

coming in from Claude. That's really, as

5:02

far as I can tell, just looking at the

5:04

UI, things that require a change in the

5:07

scene to render. So, I'm not even

5:09

dogging on React, despite my feelings

5:11

about React. I'm just saying this is

5:13

what you see. Now, none of these happen

5:16

at effectively 60 frames per second.

5:18

People aren't typing 60 characters a

5:21

second. It's not throbbing plus typing

5:24

plus receiving clawed code back at 60

5:26

frames per second. So that means you

5:28

could make the little diff adjustments

5:31

to your screen as each one of these

5:33

things come in. There's no running game

5:35

loop. It should be completely empty if

5:38

nothing is happening. If you're waiting

5:39

for Claude, there's no throbbing going

5:41

on, no characters being typed. There is

5:44

no work to be done. There's no diffing.

5:46

There's no reacting. There's no there's

5:47

no rasterizing. There's no generating of

5:49

antsy. You can say no change, no work.

5:52

It's one of these really beautiful

5:53

things about writing 2ies is that you

5:56

can tell when something has changed.

5:58

Therefore, you know when work needs to

6:00

be calculated. And so in my head, this

6:02

is like what should happen. But

6:04

obviously, again, I still may not

6:06

understand things and I don't want to

6:07

dog on somebody for some engineering

6:09

stuff. Uh I I don't understand the

6:11

trade-offs they originally used. I don't

6:13

understand the React thing. But again,

6:15

I'm sure you can explain to me why React

6:18

was a good decision. To me, this just

6:19

obviously looks like, hey, I want to

6:21

write TypeScript. What do you write with

6:23

TypeScript? You write React. Okay,

6:25

that's what the LLM told me. Hey, I'm an

6:26

engineer. I use an LLM. Bada bing, bada

6:28

boom. We use React. Or this comes from

6:30

some sort of legacy decision that

6:32

somebody who thinks that they really

6:33

love Tuies, but they also only just want

6:35

to write TypeScript was like, yo,

6:37

there's this library called Inc. that

6:38

uses React, bro. Which is I think what

6:40

ended up happening. It doesn't really

6:41

matter how you got here. that decision

6:44

was made, but the 60 fps is really still

6:46

just living rentree because then I

6:48

thought, okay, how fast can I render

6:50

stuff to the screen? So, I wrote a

6:52

little tiny little test right here where

6:54

I can say I want to draw a box of one by

6:56

one characters and I want to draw it as

6:58

fast as possible. So, I'm drawing this

7:00

as fast as possible randomly on my

7:01

screen. This number right here is me

7:04

drawing a thousand of those boxes. How

7:06

many milliseconds did it take? So, I

7:08

drew a,000 one by one boxes in

7:10

effectively 1,000 milliseconds. Okay,

7:12

that's pretty cool. I do it again. Let's

7:14

do a 2x2. As you can see, I'm writing a

7:16

lot more characters. Effectively, no

7:18

time has changed. I can do that at

7:20

32x32. You can see the screen's going

7:22

nut. I bet you YouTube encoding is just

7:25

utterly failing at this point because I

7:27

have simulated white like white noise

7:29

from first principles. Again, I'm also

7:31

using Ghosty. This is a modern terminal

7:33

with GPU acceleration. So, some of the

7:35

older terminals probably couldn't render

7:36

as fast as this. I don't actually know

7:38

what the real frame rate is because I

7:41

don't know if we're actually rendering

7:42

at effectively one frame every 1.3

7:46

milliseconds, right? We're rendering

7:48

some amount at some rate that's very

7:51

very astronomically high to the point

7:53

that I can't even see what's really

7:54

happening on the screen. Just as far as

7:56

rendering goes, you can go really really

7:58

fast. There clearly is nothing holding

8:01

back from just going uh absolutely much

8:04

much faster than 60 frames a second even

8:06

in a just in a modern terminal. Now

8:08

granted again uh legacy terminals I

8:10

can't speak for them. I used to use uh

8:12

some terminal from 1984. It took a you

8:14

know everything was much much slower

8:16

when I tried to play Asky Doom. But then

8:17

I got curious. So this right here is me

8:20

seeing how fast can I render scroll back

8:23

history. Okay. So now if I close this, I

8:25

can actually take T-Mox and I'm look

8:27

like that's the scroll back history

8:28

right there. So this is much closer to

8:30

what Claude code does is it has an input

8:32

area where I can put in some nice input

8:34

going on down here and at the same time

8:36

you can imagine I'm getting so much

8:38

stuff coming back in. Now granted I

8:40

didn't use React. This is not nearly as

8:42

complicated. I I also included a throbb

8:45

that looks pretty similar and along with

8:47

like a little Braille little swirly

8:48

thing. This is how many new lines I have

8:50

created. This is how much of the time

8:53

I'm calculating I'm using the CPU in

8:56

JavaScript land approximately for every

8:58

every frame I'm using a 100 microsconds

9:01

and I'm almost idle the entire time. So

9:04

again even with this really ridiculous

9:06

example which is just you know rendering

9:08

at an absurd rate and doing a ridiculous

9:11

amount of stuff. I don't know where the

9:14

16 milliseconds is going wrong. It

9:16

purely seems like a React problem. And

9:19

don't just take my word for it. Will

9:21

McGugan, uh, if I'm saying that name

9:22

correctly, is kind of a longtime

9:25

engineer out here that has done a lot of

9:27

stuff and I think he has a really

9:29

amazing take on this. Sometimes

9:30

developers get hyperfocused on tackling

9:32

the immediate technical challenges in

9:34

front of them that prevents them from

9:35

reflecting on past decisions. By the

9:36

way, this is one of my greatest

9:37

weaknesses. And even after 20 years of

9:39

engineering, this right here, it still

9:41

rings true today. So much of engineering

9:44

is taking a step back and going, why did

9:46

I make this decision? Let's let's

9:48

actually understand the problem and not

9:51

just simply the solution. It's like you

9:52

take a fork in a road and find out you

9:54

need to climb a mountain. The faster

9:56

route to your destination may be to

9:58

backtrack and take a more direct route

9:59

without the mountain in the way. Tuies

10:01

are much more complex than most people

10:03

know. Very true. I've written a couple

10:04

tuities in my day. You know, I have some

10:06

amount of experience in it, but I've

10:08

never written a tuy to say to the level

10:09

of complexity of claude code. It is a

10:11

very impressive tuy. Trust me on this.

10:13

But I see nothing nothing in Claude's

10:16

output that needs a scene graph. Their

10:18

scene is a list of non-interactive

10:20

output. It's literally literally a list

10:22

of things. Granted, there's a little bit

10:24

of like highlighting, a bit of

10:25

throbbing, there's some input at the

10:26

bottom. They want to preserve scroll

10:28

history. Like I mean there's a couple

10:29

things. And apparently you can press

10:31

like controlB to like expand some stuff.

10:32

So there's some like accordion

10:34

interactive stuff, though I've never

10:36

gotten that to work. Cloud code does not

10:38

need to be a small game engine. No game

10:39

engine would construct a scene graph and

10:41

diff every frame. That would be too

10:43

expensive and wouldn't scale. I'm an ex

10:44

games developer. Yeah, typically you

10:45

just do immediate mode, right? You just

10:47

draw the scene, right? Big. You could

10:48

draw the entire terminal every single

10:51

time. How do I know? I'M DOING IT RIGHT

10:53

NOW WITH THE SCENE STORED as a list

10:54

tracking what changes rather than

10:56

diffing. The caching and see generation

10:58

16 milliseconds for a frame wouldn't be

10:59

challenging to hit. I don't even think

11:01

again I would argue from the beginning

11:03

there is no frame rate you need. You

11:06

react to changes coming in cuz they're

11:08

not going to be that fast. So, by the

11:09

way, just in case you're wondering with

11:11

input, if you did 60 characters per

11:13

second typing, that's 720 words per

11:16

minute. Okay? Ain't nobody typing that

11:18

fast. Even if I mash my little fingies

11:20

as fast as possible, I can't achieve

11:22

such speed. I think the mountain is the

11:23

React model, a holdover from their ink

11:26

days. It allowed TS developers to use a

11:28

comfortable pattern for building UIs.

11:30

But React was designed to manage the

11:31

complexity of a browser UIs, which are

11:33

way more complex than Claude's

11:35

requirements for a terminal UI.

11:37

Absolutely true. And now Anthropic are

11:39

expending a lot of engineering effort to

11:42

tunnel through this mountain. On top of

11:43

it, this also just goes to show,

11:45

remember this phrase that people always

11:47

say, use the best tool for the job. It

11:49

really just goes to show what people

11:51

mean when they say that is, I'm going to

11:53

use the most comfortable tool for the

11:56

job, which is the anti pattern. By the

11:59

way, I'm not even upset at JavaScript. I

12:00

think JavaScript's perfectly fine here.

12:02

I don't even care about that aspect.

12:04

Yeah, sure, it's a little bit memory

12:06

hoggy. Uh now with RAM becoming the most

12:08

expensive thing in the universe, I can

12:09

see why that's negative. But

12:10

nonetheless, your problem is not

12:12

performance. This is not a performance

12:13

problem going on here. If there is a

12:15

performance problem, it's a U problem.

12:17

Perhaps the renderer is too coupled to

12:19

the data model and hard to replace. Now,

12:21

I wouldn't be surprised if that were

12:22

true. But if I were anthropic, I would

12:24

have a small team work in parallel to

12:26

build a kind of decoupled model and

12:27

renderer that you would make if you

12:29

didn't have any legacy issues. I would

12:30

hire at least one games developer for

12:32

this. Honestly, you could hire a games

12:33

developer. Just hire a tools developer

12:36

in general, not even a games developer.

12:38

Hire somebody that doesn't just build

12:40

for the web. Really, just anybody else.

12:42

You could probably hire half the web

12:44

devs and they could just figure it out.

12:45

I really think this team would get to

12:46

their destination before the team that

12:48

is tunneling through the mountain.

12:49

Honestly, this is just so true and I

12:50

think it's such an interesting point in

12:51

engineering, right? Because Anthropic

12:53

has been the leading scaremonger about

12:55

like the world's going to end, all the

12:57

jobs are going to leave. You look at

12:59

this and I see a failure of both

13:01

engineering management and engineering.

13:03

They've got they've dug themselves into

13:05

the weirdest place. And it just goes to

13:07

show even if they generated all the code

13:10

with LLMs and they're saying this is the

13:11

best ever, fundamentally the decisions

13:14

they have made aren't good. And so

13:16

whether the code was generated by hand

13:18

or by LLM, it doesn't matter. The

13:20

failure already happened. Some more

13:22

highlights from Twitter. We apparently

13:24

live in a clown universe where a simple

13:25

TUI is driven by React and takes 11

13:27

milliseconds to lay out a few boxes in

13:29

monospace text. By the way, uh, business

13:30

right here, excellent blog, excellent

13:32

engineer. Layout 0.9 milliseconds.

13:34

Rasterization. Still, I still actually

13:36

just I've never read what rasterization

13:37

means. I'm sure it's really simple. It's

13:39

just in my head. I'm like, that's a word

13:40

I never know. 2.1 millconds. Diffing 1.2

13:43

millconds. Building the React scene

13:44

graph 11 milliseconds. I think this one

13:46

really is just like this encompasses how

13:48

I feel. This company is having a hard

13:50

time making a 2D ANC terminal to run at

13:52

60 fps and they demand you to take them

13:54

seriously when they talk about

13:55

revolutionizing programming. I keep

13:57

saying this and I feel like this is just

13:58

so important. hard skills are still in

14:01

demand. The LLM's aren't going to make

14:04

the best decisions. They're going to

14:05

make the decisions that you tell them to

14:07

make crappily. It's not only up to you

14:09

to make the decisions, it's up to you to

14:11

double check that the decisions you made

14:13

were even implemented properly and with

14:15

care. So, if you don't have that

14:17

foundation, you just might find yourself

14:19

in 60 frames per second react diffing

14:22

helland hellscape 2i. Lastly, I know

14:24

this tweet was made by Tyreek right here

14:26

and a bunch of people kind of been

14:27

dogpiling him. Hey, my goal wasn't here

14:29

to like call him out or single him out

14:30

or try to be mean to him. Hey, I've been

14:32

in positions in which I've had to make

14:33

decisions or follow up with past

14:35

decisions that weren't ideal. That did

14:37

cause a whole bunch of difficulty. I

14:39

just was lucky enough not to have to

14:41

make those decisions and explain myself

14:43

on Twitter. And I think a lot of you

14:45

listening have found yourself in a very

14:46

similar situation. So, be nice, be kind.

14:49

And all my critiques, as you can see,

14:50

are more towards the leadership of

14:52

Anthropic, which is their constant

14:53

fear-mongering of engineering, saying

14:55

it's all over. Because even within their

14:57

own company, they suffer from the cost

14:59

of legacy. There's nothing more

15:01

permanent than a temporary fix. The name

15:05

is the primogen. Hey, is that HTTP? Get

15:09

that out of here. That's not how we

15:11

order coffee. We order coffee via ssh

15:13

terminal.shop. Yeah, you want a real

15:15

experience. You want real coffee. You

15:17

want awesome subscriptions so you never

15:19

have to remember again. Oh, you want

15:21

exclusive blends with exclusive coffee

15:24

and exclusive content? Then check out

15:27

Kron. You don't know what SSH is?

15:29

>> Well, maybe the coffee is not for you.

15:32

[singing]

15:34

[music]

15:36

Living the dream.

Interactive Summary

The video discusses the controversial engineering design of Claude Code's Terminal User Interface (TUI), which operates like a small game engine using React to render at 60 frames per second. The speaker, ThePrimeagen, critiques this approach as an engineering and management failure, arguing that using React's scene graph to manage a simple terminal interface creates unnecessary performance bottlenecks, with React alone consuming 11ms of the 16ms frame budget. He suggests that the decision was likely driven by developer comfort with TypeScript/React rather than technical necessity, advocating for a simpler event-driven architecture instead of a continuous game loop.

Suggested questions

5 ready-made prompts