YouTube2Text

You can rewrite typescript in rust for $420k — Transcript

by Theo - t3․gg · 9,890 words · 1,403 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Announcing TSC RS, aka TypeScript Rust,
  2. 0:03my complete rewrite of the TypeScript
  3. 0:05compiler, type checker, and LSP all in
  4. 0:09Rust. This is a project I've had agents
  5. 0:11working on for 5 months now. I burned
  6. 0:13$400,000 of Codex tokens and got
  7. 0:16nowhere. I burned $20,000 of Opus 5.5
  8. 0:19and I got there in 2 weeks. Important
  9. 0:21note,
  10. 0:23I have not read a single line of code.
  11. 0:26If you've been around for a bit, you
  12. 0:27probably know I've been using this
  13. 0:28TypeScript Rust rewrite as my favorite
  14. 0:30little playground for trying out new
  15. 0:31models and seeing where capabilities are
  16. 0:33going. I did that because I was looking
  17. 0:35for things that just seemed impossible
  18. 0:37for the models to do. The reason I first
  19. 0:38started the TypeScript Rust project was
  20. 0:40because I had a crazy amount of
  21. 0:42inference with the early access testing
  22. 0:43for GPT 5.6 Soul and it was crushing
  23. 0:46everything I threw at it. So, I decided
  24. 0:48to reach for something a bit bolder. Not
  25. 0:50a bit bolder, like just impossible. It
  26. 0:52didn't seem viable to just rewrite all
  27. 0:54of TypeScript in Rust. It seemed like a
  28. 0:56meme.
  29. 0:57And it was. The furthest I got using
  30. 0:59OpenAI models was roughly 84%
  31. 1:01compatibility. And while like impressive
  32. 1:04that it could get that far, didn't
  33. 1:06really seem like it was going to get
  34. 1:07much further because at that point the
  35. 1:09last 16% is way harder and as you get
  36. 1:11closer and closer the edges that are
  37. 1:13left get worse and worse. Which is why
  38. 1:15it feels extra insane that not only is
  39. 1:17TS Rust now out and available for people
  40. 1:19to use with a real package on NPM, more
  41. 1:22importantly, it's way faster. When
  42. 1:25compared to TypeScript V6, which was the
  43. 1:27last version written in TypeScript and
  44. 1:28JavaScript itself, it is 12.5 times
  45. 1:31faster. When compared to TS Go, which is
  46. 1:34TypeScript V7, the version that the
  47. 1:36official folks at Microsoft built, it's
  48. 1:38around two times faster. We're not the
  49. 1:40only ones who did this. Bun also dropped
  50. 1:42Bun Check, which is a rewrite of the
  51. 1:44TypeScript checker in Rust that is also
  52. 1:47way faster and I'll be real, is even
  53. 1:49faster than what we built with TS Rust.
  54. 1:52But there are catches to all of this.
  55. 1:54From how I built it to how I verified it
  56. 1:56to the secret reasons I actually wanted
  57. 1:58this to exist, which believe it or not
  58. 2:00aren't just RAM usage and how long it
  59. 2:03takes to run. I have one very
  60. 2:05interesting secret reason I wanted to
  61. 2:06build this. And I actually have a demo
  62. 2:08of it working now. This little vibe
  63. 2:10coding demo here is a lot cooler than it
  64. 2:13might seem initially. I want to talk
  65. 2:15about all of this, from how much it cost
  66. 2:17to how it worked to why I care so much
  67. 2:19about this project and most importantly,
  68. 2:22what does this mean for engineering
  69. 2:23going forward? But after burning
  70. 2:24$420,000
  71. 2:26of tokens, I hope you can forgive me for
  72. 2:28a real quick break for today's sponsor.
  73. 2:29How the heck did we get here? AI models
  74. 2:31are capable of rewriting pretty much any
  75. 2:33piece of software from scratch in
  76. 2:34whatever language you want, but trying
  77. 2:36to find the right three rows in your
  78. 2:37database using an agent is it nearly
  79. 2:39impossible. Once the data isn't
  80. 2:41perfectly structured and doesn't have
  81. 2:43the exact keyword the model's looking
  82. 2:44for, it's not going to find it. This is
  83. 2:46why good vector search and retrieval
  84. 2:47systems are so important. And today's
  85. 2:49sponsor Quadrant has it absolutely
  86. 2:51figured out. I'm going to quickly
  87. 2:52mention two things to make the haters go
  88. 2:53away. It's fully open source and also
  89. 2:56written in Rust. You can use the cloud
  90. 2:57if you want or you can self-host, both
  91. 2:59are incredible. My team's been using the
  92. 3:00cloud version a bunch and the things
  93. 3:01we've been building are genuinely super
  94. 3:03useful. For example, let's look for
  95. 3:05videos where I talk about my agent MD.
  96. 3:07When I do basic keyword search, I get 10
  97. 3:09results that aren't really good fits for
  98. 3:12what I was looking for.
  99. 3:13But on Quadrant, I'm getting ranked
  100. 3:15results based on how well my question
  101. 3:17actually matches the content. And
  102. 3:19obviously, the video on the right here
  103. 3:20is a much better fit than the one on the
  104. 3:22left. I can even get more vague and
  105. 3:23search for something like anti-clod. And
  106. 3:25what's funny here is the video that was
  107. 3:27recommended on the left is the same as
  108. 3:29before cuz this is basic keyword search
  109. 3:31like what your agency by default. On the
  110. 3:33right with the vector search, we get
  111. 3:35videos that are very much me being
  112. 3:37anti-entropic. I didn't plan this one
  113. 3:39ahead. I did not think this gap was
  114. 3:40going to be so big. That's hilarious.
  115. 3:42The more vague the query, the more
  116. 3:43valuable it is. For example, I can have
  117. 3:45it go through all of my issues and PRs
  118. 3:47on GitHub for T3 Code and ask something
  119. 3:49vague like T3 Code is making my whole
  120. 3:51Windows PC lag even when it's sitting
  121. 3:53idle. I fire this, I get no results from
  122. 3:55the keyword search, and I get eight
  123. 3:57relevant results from Quadrant. This
  124. 3:58makes deduplicating and finding similar
  125. 4:00issues so much easier. We're even using
  126. 4:02it now to index all the faces I use in
  127. 4:03my thumbnails. I can search for
  128. 4:05shrugging with both hands out and
  129. 4:07immediately get results that are good
  130. 4:09matches for that request. Or I can
  131. 4:11search something like angry and get all
  132. 4:13of the thumbnails where I looked kind of
  133. 4:14mad. There's a reason companies like
  134. 4:15Canva, Discord, and more have been
  135. 4:17moving to Quadrant. Give your agents
  136. 4:18search that feels magical at
  137. 4:20swiy.io/quadrant.
  138. 4:21I'm going to do everything in my power
  139. 4:23to not make this video 2 to 4 hours
  140. 4:26long, which is tough because I have so
  141. 4:28much to say about this. But, I think we
  142. 4:31should do a brief history lesson to
  143. 4:33explain what this is and why it exists.
  144. 4:35TypeScript is a language, kind of.
  145. 4:38The point of TypeScript is to build a
  146. 4:39system on top of JavaScript so that we
  147. 4:41can have more confidence about the
  148. 4:43behaviors of our JavaScript apps. The
  149. 4:45main thing that we're talking about
  150. 4:46today is TSC, the TypeScript compiler.
  151. 4:49The point of the TypeScript compiler is,
  152. 4:51of course, to turn the TypeScript that
  153. 4:53is in your editor into JavaScript that
  154. 4:55your browser can run because your
  155. 4:56browser doesn't know how to deal with
  156. 4:57TypeScript. If you have a function like
  157. 4:59function user name string,
  158. 5:03console.log
  159. 5:05user.name, wow, we're writing code. Such
  160. 5:08advanced stuff. Been a while, right,
  161. 5:09guys? Wait, there's even a code button
  162. 5:11there. Look at that. If you took this
  163. 5:13function and ran it in Chrome or Node or
  164. 5:16any other JavaScript runtime, it will
  165. 5:18immediately fail an error because the
  166. 5:21syntax for the type definition here,
  167. 5:22where I describe user as a parameter
  168. 5:25that is of type object with a name key
  169. 5:27that's a string, this is not valid
  170. 5:29JavaScript syntax. You can't just do
  171. 5:31this there. Also, the function needs a
  172. 5:33name, so log user. You get the idea
  173. 5:36though. This would not be valid
  174. 5:38JavaScript because of this guy here.
  175. 5:40Turning this into valid JavaScript is
  176. 5:42actually quite easy. You can go through
  177. 5:45and trim out all of the TypeScript-isms
  178. 5:48in the JavaScript code. And once you've
  179. 5:49done that, you can just run it and it
  180. 5:51works. So, the first important thing to
  181. 5:54understand here,
  182. 5:55turning TypeScript files into JS files
  183. 5:57is easy, borderline trivial. And there
  184. 6:00have been lots of cool tools doing this
  185. 6:02for a while now. In particular, one blew
  186. 6:05up a few years ago and kind of changed
  187. 6:06how we think about web dev, esbuild.
  188. 6:09esbuild was built by Evan W, who was the
  189. 6:12CTO of Figma, because he wanted to make
  190. 6:14it faster to get updates when you change
  191. 6:16files in your editor to see them in your
  192. 6:18UI. And running all of your code through
  193. 6:21JavaScript just to remove some things
  194. 6:22from it so you can put it in the browser
  195. 6:24was not efficient. So, esbuild was built
  196. 6:26to do a lot of those steps, not just the
  197. 6:28turning TypeScript to JavaScript, but
  198. 6:30also a lot of the other steps, like
  199. 6:33bundling in the CSS, creating the other
  200. 6:35assets needed, turning it all into one
  201. 6:37file the browser could actually receive
  202. 6:38instead of all of these files scattered
  203. 6:39around your code base. All the things
  204. 6:41you need to bundle the app to get it
  205. 6:43ready for your browser, written in Go so
  206. 6:46that it could be as efficient as
  207. 6:48possible, reasonably, without having to
  208. 6:50like reinvent the universe and manage
  209. 6:51all your memory yourself. And esbuild
  210. 6:53was incredible, but it was missing
  211. 6:55something. We're just talking about
  212. 6:56turning TypeScript into JavaScript.
  213. 6:58That's an easy part. The actual hard
  214. 7:00part is checking the TypeScript, making
  215. 7:02sure the types are valid and being used
  216. 7:05and honored correctly throughout your
  217. 7:06application. I'm going to be so real
  218. 7:08with y'all, doing the transpilation,
  219. 7:10turning TS into JS, was so easy that
  220. 7:13even just doing it in JS wasn't that big
  221. 7:15of a deal. Checking the TypeScript to
  222. 7:17make sure it's correct, way harder and
  223. 7:20also way slower. This ended up being
  224. 7:22where most of the time was spent. As a
  225. 7:24result of this, the maintainers of lots
  226. 7:26of big code bases split their
  227. 7:28transpilation and type checking
  228. 7:29compilation paths separately. I remember
  229. 7:32how bad the hot reloading was initially
  230. 7:33at Twitch. I would run the dev command,
  231. 7:35it would take 2 minutes to start up, and
  232. 7:37then I would go and edit a file, save,
  233. 7:38and it would take 30 seconds to a minute
  234. 7:40to appear in the browser. I was so hyped
  235. 7:42that we got it under 5 seconds by making
  236. 7:44it so the path that puts it in the
  237. 7:46browser is separate from the path that
  238. 7:48is type checking the code to make sure
  239. 7:50it's correct in its type definitions.
  240. 7:53Something like ESBuild that you go even
  241. 7:54further for those hot reloads from
  242. 7:56saving to seeing it in the browser, but
  243. 7:58it doesn't give you enough info to know
  244. 7:59something like did the types check
  245. 8:01correctly? And as you've probably seen
  246. 8:03if you've watched my old videos, the
  247. 8:04TypeScript type system is incredibly
  248. 8:06complex and flexible. It's a Turing
  249. 8:08complete system. Here's a fun throwback.
  250. 8:10One of my friends actually ported all of
  251. 8:13Doom into TypeScript's types. Not
  252. 8:15TypeScript the language, TypeScript the
  253. 8:17type system. Insane project. Highly
  254. 8:19recommend watching that video if you
  255. 8:21haven't seen it before. The point I try
  256. 8:22to make here is that TypeScript's type
  257. 8:24system is complex. And it's complex
  258. 8:27because it can represent all the things
  259. 8:28you do in JS. Therefore, rewriting the
  260. 8:31checker in a non-JavaScript language
  261. 8:33would inherently suck because of all the
  262. 8:36weird things that JavaScript does
  263. 8:38inherently. Like the way you can change
  264. 8:40what variables types are as you execute
  265. 8:42your code. The way that objects inherit
  266. 8:45traits and the way all of the
  267. 8:47prototyping systems work. And all the
  268. 8:49the weirdness of JavaScript that
  269. 8:51TypeScript faithfully encodes is a lot
  270. 8:53easier to encode when the language
  271. 8:55encoding it is the same language as the
  272. 8:57one you're encoding. A sillier way to
  273. 8:59explain this is that it's much easier to
  274. 9:01explain how English works in English
  275. 9:03than it would be to explain how English
  276. 9:04works in Spanish. Just imagine that
  277. 9:06complexity but like times a hundred.
  278. 9:08That's what makes this so hard is all
  279. 9:10the weirdness of JS has to be encoded
  280. 9:11faithfully in whatever thing you choose
  281. 9:13instead. But that was not enough to stop
  282. 9:16Microsoft. Which is why Microsoft
  283. 9:18decided to rewrite TSC. They wanted it
  284. 9:21to be native and super fast to make
  285. 9:23these compilation and type check times
  286. 9:25way better, which is why they picked Go.
  287. 9:27You might be confused. In fact, I'll
  288. 9:29switch over to chat and see how people
  289. 9:31feel about their choice for Go. What
  290. 9:33language do you guys think they they
  291. 9:35have chosen? Jai, C++, C#, C# is a funny
  292. 9:39one cuz the creator of TypeScript is
  293. 9:40also the creator of C#. I have the hot
  294. 9:42take
  295. 9:43that Go is the right language for this.
  296. 9:47I know everybody else has opinions, but
  297. 9:48let me explain why. I recently got
  298. 9:51dunked on for these tweets, and I think
  299. 9:53they're relevant here more than ever. I
  300. 9:54posted in February of 2024,
  301. 9:57"Go is probably the right language for
  302. 9:59most JavaScript build and dev tooling."
  303. 10:02I followed up with the following,
  304. 10:03"Tweeting this now for reference in 3
  305. 10:05years when we realize we up going
  306. 10:07all in on Rust." This take aged poorly,
  307. 10:10but not for the right reasons. I need to
  308. 10:13explain the Go one first because this
  309. 10:15almost directly contradicts with my
  310. 10:16other takes on Go. For example, here
  311. 10:19where I'm making fun of Melkey saying,
  312. 10:21"I suddenly understand why you think Go
  313. 10:22is a good language." I'm notoriously a
  314. 10:24Go hater. I just never liked the
  315. 10:27language much. I I get where it's
  316. 10:29benefits are. I just makes you feel like
  317. 10:31a monkey more than an engineer from
  318. 10:32being real. So, why did Go make sense
  319. 10:35here? Go's biggest strengths compared to
  320. 10:38something like Rust are its flexibility
  321. 10:41because it's not trying anywhere near as
  322. 10:42hard to be like super type-safe and
  323. 10:44memory-safe. It's type system's a
  324. 10:45meme. It's concurrency stuff
  325. 10:48built in is awesome. Like Go's
  326. 10:49concurrency model has its issues like
  327. 10:51channels are stupid, but the like core
  328. 10:53parts in Go routines, there's some
  329. 10:55really cool stuff in there. And
  330. 10:57concurrency is one of the big things
  331. 10:58that the team wanted with the TypeScript
  332. 11:00rewrite so that they could take more
  333. 11:01advantage of your cores. Its syntax was
  334. 11:03surprisingly similar to JS which made it
  335. 11:05easier to look at two functions from one
  336. 11:07in the other and understand what they're
  337. 11:09doing. But, I would argue the biggest
  338. 11:10piece, garbage collection.
  339. 11:13Garbage collection is one of the flaws
  340. 11:14in Go because it means that your memory
  341. 11:16isn't being managed by you, and at some
  342. 11:18point it has to be cleaned up, which
  343. 11:20means that the performance
  344. 11:21characteristics of your app are not
  345. 11:23reliable. Usually, it will respond to a
  346. 11:25request pretty fast, but sometimes if
  347. 11:27that request comes in when you happen to
  348. 11:29be out of memory and need to do garbage
  349. 11:30collection, then you'll have these
  350. 11:32random latency spikes that suck. The
  351. 11:34benefit is that you get crazy
  352. 11:35concurrency and you have to think about
  353. 11:37memory constantly at the cost of garbage
  354. 11:40collection causing your latency to
  355. 11:42spike. So, if you have a system that you
  356. 11:44care a lot about and like you want to
  357. 11:45make sure every request is resolved in
  358. 11:47under 25 milliseconds, Go might not be
  359. 11:49the right language because sometimes it
  360. 11:51will have to garbage collect and it will
  361. 11:53hold off on executing code until that
  362. 11:55garbage collection passes done. To be
  363. 11:56clear here, JavaScript and TypeScript,
  364. 11:59those are garbage collected as well. Go
  365. 12:01is an interesting language because it's
  366. 12:02both low-level and garbage collected.
  367. 12:05So, why would you ever want to use this
  368. 12:07for a compiler then? Isn't that going to
  369. 12:08be super slow? No. If you have 100,000
  370. 12:12requests that all come in at 25
  371. 12:13milliseconds, and then you have to do
  372. 12:15GC, and the 1,001st request comes in at
  373. 12:18300 milliseconds instead, that seems
  374. 12:21horrible because that one request is now
  375. 12:2410 plus times slower than all the other
  376. 12:26requests were. But if one out of a
  377. 12:27thousand requests is 10 times slower,
  378. 12:30the total time is like less than 1%
  379. 12:32slower. It's nothing. The impact of
  380. 12:34garbage collection on the scale of a
  381. 12:36long process with lots of things in it
  382. 12:38is much less than when you're timing
  383. 12:40each individual request. So, if you're
  384. 12:42doing work that you want to have resolve
  385. 12:44in milliseconds, a garbage collecting
  386. 12:46language will have flaws you should work
  387. 12:48around. But if your average request is
  388. 12:50going to take more than 100
  389. 12:51milliseconds, like I don't know,
  390. 12:54multiple seconds cuz you're compiling a
  391. 12:55giant app, I don't care if you garbage
  392. 12:57collect one, two, three, 10, 100 times
  393. 12:59during that request because the garbage
  394. 13:00collection is going to make up such a
  395. 13:01small percentage of the runtime, it
  396. 13:03barely matters. It washes out. So, if I
  397. 13:05was building a web service I wanted to
  398. 13:06have respond as quickly as possible, Go
  399. 13:08is not the right language. But if I'm
  400. 13:10trying to take something written in
  401. 13:11JavaScript that's really slow that takes
  402. 13:13minutes to run and shave the time down
  403. 13:15and get more concurrency, Go is one of
  404. 13:17the best languages to do this with. But
  405. 13:19it couldn't have been too hard to do the
  406. 13:21Rust thing, right? Cuz you had an agent
  407. 13:22do it in 2 weeks. Now, I would like to
  408. 13:25introduce TS Rust. Writing all of
  409. 13:27TypeScript from JS to Rust would not
  410. 13:30have been viable. I know this to be the
  411. 13:31case because of how much the other
  412. 13:33models I tried, like 5 6 Soul and Astra,
  413. 13:36struggled with this port. I think a lot
  414. 13:38of that was because going from
  415. 13:39JavaScript to Rust is not trivial with
  416. 13:41things as complex as TypeScript itself.
  417. 13:44And this is where things start to get
  418. 13:45interesting with my TS Rust port. We hop
  419. 13:47into the crates, a lot of things were
  420. 13:50done, many of which are uh I think
  421. 13:52questionable is a fair word for it.
  422. 13:54One of those things is this.
  423. 13:57Go STD. This is the standard library
  424. 13:59from Go
  425. 14:01ported to Rust. Because the way Opus
  426. 14:03chose to do this wasn't to rewrite
  427. 14:07things from Go to Rust. It was to go
  428. 14:10through this Go port line by
  429. 14:12line and faithfully port it over to the
  430. 14:15Rust language. And the result of this
  431. 14:18was actually quite a bit slower than the
  432. 14:19Go version because when you have to
  433. 14:21re-implement things like Go routines,
  434. 14:23which is in here somewhere, I have
  435. 14:25forgot which it's in. I think it's in
  436. 14:27the runtime RS, yeah. Runtime RS. This
  437. 14:29is Go routines ported to Rust.
  438. 14:34This happened because Go was a much
  439. 14:36better starting point for a Rust port
  440. 14:38than JavaScript is. The Microsoft team
  441. 14:41faithfully by hand went through every
  442. 14:43line of code in TypeScript, ported it to
  443. 14:45Go, and then started refining it to make
  444. 14:47it better and faster in Go. My agents
  445. 14:49did the same thing from the Go version
  446. 14:51to Rust, and they succeeded. I didn't
  447. 14:54even know that my agents had done this
  448. 14:55until somebody else pointed it out on
  449. 14:56Twitter. And as soon as I saw that I was
  450. 14:58like, "Oh, that's hilarious. That
  451. 14:59explains a lot." Because again, when TS
  452. 15:01Go RS was ready for its first run when
  453. 15:04Opus finished, it was two to three times
  454. 15:05slower than the Go version. So, I told
  455. 15:07it in a slash goal, "Your objective is
  456. 15:10to make it at least two times faster in
  457. 15:12every way." And then I let it run for 2
  458. 15:14weeks.
  459. 15:15More importantly,
  460. 15:16I let it run on my six Claude accounts.
  461. 15:19All of the work done in TS Rust with
  462. 15:21Opus 5 5, which effectively gave up on
  463. 15:23the old version and restarted, was
  464. 15:25roughly $24,000
  465. 15:27of inference if I had paid full API
  466. 15:29prices. But as you know, I didn't
  467. 15:31because I have subscriptions. So I also
  468. 15:33tried pricing it out using all my logs
  469. 15:35to see how much of my utilization went
  470. 15:37to this. The equivalent in your sub
  471. 15:40usage for all the work I did here was
  472. 15:42between 925% and 983% of one account's
  473. 15:45weekly limit, which means about 2 and
  474. 15:471/2 months of usage on a Claude sub.
  475. 15:50When you consider that we got a free
  476. 15:52reset, this ends up being about 500-ish
  477. 15:54dollars give or take of subscription
  478. 15:57usage. And at that price this is
  479. 15:59actually a good value to have built. I
  480. 16:01know it sounds insane, but $500 to have
  481. 16:04TypeScript in Rust, which is more memory
  482. 16:06efficient and faster, 2x faster than the
  483. 16:08Go version, is genuinely super useful.
  484. 16:10And I am To me, this is money well
  485. 16:12spent. I know that seems insane because
  486. 16:14the 20,000 or the $420,000 headline
  487. 16:17number sounds crazy, but with the
  488. 16:18subsidization from a subscription and
  489. 16:20the fact that only the 20K of Claude
  490. 16:21mattered, this being 10 weeklies of
  491. 16:24usage is just uh hilariously good value
  492. 16:26in my opinion. So if you were thinking,
  493. 16:27"Man, the Microsoft TypeScript team
  494. 16:29wasted so much money and time porting to
  495. 16:31Go, they could have just waited and let
  496. 16:33AI do it in Rust." No, I don't think the
  497. 16:35AI would have done this viably from
  498. 16:37JavaScript and TypeScript to Rust, but
  499. 16:39it was able to do it with Go relatively
  500. 16:41trivially. And the result is a pretty
  501. 16:44much 100% drop-in replacement for TS Go
  502. 16:48and TSC 7. I know that for a very silly
  503. 16:51reason, the issues. There were five,
  504. 16:53there are now four. I audited these
  505. 16:55issues. Well, my agent and I audited
  506. 16:57these issues. And of the six issues that
  507. 16:59have been opened total so far, one of
  508. 17:02them was specific to TS Rust. The other
  509. 17:05five issues were problems that exist in
  510. 17:08TSC 7, the specific version that we were
  511. 17:10targeting. So these aren't things that
  512. 17:11are wrong with the rewrite, these are
  513. 17:14bugs in TypeScript itself currently that
  514. 17:16were faithfully ported to my rust
  515. 17:18version. And I think that is hilarious
  516. 17:20that not only did I port the intentional
  517. 17:21things, I ported the bugs, too. Because
  518. 17:23this truly is a fully compatible drop-in
  519. 17:26replacement. I suppose now it would be a
  520. 17:28good time to talk about the resulting
  521. 17:30performance. Since I started this before
  522. 17:32Bun check was even a thought from Jared,
  523. 17:34I was initially running all my numbers
  524. 17:35against TypeScript 7. And for real-world
  525. 17:38projects like T3 Code, we saw a 2x
  526. 17:41improvement from TS7, which is TS Go,
  527. 17:43and as much as a 20x improvement on
  528. 17:45various things for TSC 6, which was the
  529. 17:47last TypeScript JavaScript-based TSC. I
  530. 17:49started with the T3 Code checks because
  531. 17:51I did something fun here. One of the
  532. 17:52things Affect TS does, and if you're not
  533. 17:54familiar, Affect is a popular library in
  534. 17:55TypeScript to make building reliable
  535. 17:58concurrent systems more viable and
  536. 18:00composable as well. Affect uses and
  537. 18:03abuses TypeScript so heavily that
  538. 18:04they've actually built their own fork of
  539. 18:07TypeScript effectively. It's a patch you
  540. 18:09apply to your TypeScript config and your
  541. 18:11TypeScript like package in your repo to
  542. 18:13get more diagnostic and features from
  543. 18:16Affect into the type checking. I built
  544. 18:18that directly into TS Rust because we
  545. 18:20rely on this a lot for things like T3
  546. 18:22Code. So, for our use case in T3 Code,
  547. 18:25not only are we way faster than TS7 with
  548. 18:29Affect's TS Go plugin, we're actually
  549. 18:31way faster, like four-ish times faster
  550. 18:34than Bun as well. Not because Bun check
  551. 18:36is slower, Bun check is super fast, but
  552. 18:37because we have to do the Affect check
  553. 18:40on top of it after. And as soon as
  554. 18:41you're doing both, it just ends up way
  555. 18:43slower end-to-end. But this is just
  556. 18:44checking in T3 Code. Let's check other
  557. 18:46projects, some real simple things like,
  558. 18:49I don't know, the entirety of tRPC
  559. 18:50server or Sentry's code base or
  560. 18:54Excalidraw. And funny enough, I was
  561. 18:56checking Affect as well. I actually
  562. 18:57think Bun couldn't pass on the Affect
  563. 18:59code base, if I recall. Bun also raised
  564. 19:02incorrect errors on Sentry and tRPC. So,
  565. 19:05the Bun checker, while incredibly
  566. 19:07impressive and faster in a lot of cases,
  567. 19:09does not have faithful enough checking
  568. 19:11for me to trust it in these types of big
  569. 19:13projects. I think Bun check fits well
  570. 19:15with like the other Bun tools in that
  571. 19:17like if you start a new project with Bun
  572. 19:19and you use it for everything, Bun check
  573. 19:20is a great solution. I actually honestly
  574. 19:22would recommend Bun check over TS Rust
  575. 19:24for almost everything simply because I
  576. 19:26have higher faith it'll be maintained,
  577. 19:27but TSCRS, my project TS Rust, is a way
  578. 19:30more faithful recreation and as a result
  579. 19:32it does not get weird errors in these
  580. 19:34projects. It works faithfully in
  581. 19:36projects like tRPC, in projects like T3
  582. 19:39code, in projects like the effect repo
  583. 19:41itself. And the improvements we see here
  584. 19:43for most of this stuff is 13x plus for
  585. 19:47going from TSC 6 to TSCRS. And it's
  586. 19:50usually a 2x improvement from the go
  587. 19:52version. But ready for the spicy take
  588. 19:54that's going to make all of this way
  589. 19:55more confusing?
  590. 19:57I didn't do this for performance. I did
  591. 19:59not make TypeScript Rust because I
  592. 20:00wanted something faster than TypeScript
  593. 20:02go. So why did I do this? There is the
  594. 20:05silly reason and then the potentially
  595. 20:07groundbreaking one, and I'm going to
  596. 20:09start with the silly one. The silly
  597. 20:10reason is because LLMs couldn't do it.
  598. 20:13Models were not able to make these types
  599. 20:14of ports. It had become a meme. I got in
  600. 20:16flame wars with people for claiming they
  601. 20:17would be able to port TypeScript to like
  602. 20:19C++ and things in a month, which just
  603. 20:22obviously you couldn't do, and I got in
  604. 20:24a flame war with somebody, ended up
  605. 20:25getting blocked by them. It was a hit
  606. 20:27show. This is like back like the old
  607. 20:282020s, like early days of TypeScript
  608. 20:32posting on Twitter before AI took
  609. 20:33over all of it. And I was getting in
  610. 20:35like heated fights about these things
  611. 20:36because it was obvious you couldn't just
  612. 20:38rewrite TypeScript in another language,
  613. 20:40which is why it was always my like reach
  614. 20:43goal, the impossible thing that like you
  615. 20:45could never actually have, the
  616. 20:46unobtainium to an extent in the web dev
  617. 20:48world. And as such, it was a fun thing
  618. 20:50to throw practically unlimited tokens
  619. 20:52at. I had never tried any Anthropic
  620. 20:54model on this task because they would
  621. 20:55burn my usage too fast, but with Opus
  622. 20:575.5, usage was burning so slowly and I
  623. 21:00had so much, I said it, let's see
  624. 21:01what happens. And it was able to do it
  625. 21:04way more effectively than I ever could
  626. 21:05have guessed. I did it because I didn't
  627. 21:07think models could and now that they
  628. 21:09can, I'm running out of things to throw
  629. 21:11the LLMs at. Like, I don't know what
  630. 21:13tasks an LLM would ever be able to do
  631. 21:16that are impossible for them now, but
  632. 21:18could be possible in the future. It's
  633. 21:19like hard for me to comprehend. Like, I
  634. 21:21am out of engineering ideas that are
  635. 21:23like too much for the model. This was my
  636. 21:25too much for the model and now it's done
  637. 21:27it. But, what's the real reason? What
  638. 21:29reason did I have to want a Rust-based
  639. 21:33version of TypeScript when we already
  640. 21:35had a super fast Go one? I got almost
  641. 21:37everything I wanted out of TS Go. Why
  642. 21:39did I want something else? There are
  643. 21:41small things like I wanted the effect
  644. 21:42stuff built in. I wanted it to be a
  645. 21:44little easier to extend and play around
  646. 21:46with. But, the main reason
  647. 21:48little thing called WASM. This goes back
  648. 21:51to the garbage collection bit we talked
  649. 21:52about before. Garbage collection is an
  650. 21:54incredible way to take a burden off of
  651. 21:57engineers to allow them to ship software
  652. 21:59faster that is still really fast. But,
  653. 22:01since garbage collection is a complex
  654. 22:04process that requires you to analyze
  655. 22:06memory and do a lot of memory management
  656. 22:08stuff, taking a Go app and bundling it
  657. 22:10into WebAssembly is not trivial because
  658. 22:12you can't just bundle the code the
  659. 22:14developer wrote. You also have to bundle
  660. 22:16all of the garbage collection. The end
  661. 22:19result here is that it's pretty
  662. 22:20difficult to write a Go app and then
  663. 22:23bundle it as WASM less than 10 megs and
  664. 22:26it's still going to have lots of weird
  665. 22:27performance issues because of that
  666. 22:29garbage collection aspect of it. This is
  667. 22:31why tools like ESBuild struggled to get
  668. 22:33WASM working for so long. This is also
  669. 22:35one of the things we lost with
  670. 22:37TypeScript Go. Previously, since
  671. 22:39TypeScript was all just JS in the end,
  672. 22:41you could throw it in the browser. You
  673. 22:42could throw it in a V8 isolate. You
  674. 22:44could run it in Node and it just worked.
  675. 22:46With TS Go, we kind of lost that. In
  676. 22:49fact, we lost a lot of the JavaScript
  677. 22:50APIs we used to interface with
  678. 22:52TypeScript compiler in the past. Why do
  679. 22:54I care that much though? We're all
  680. 22:55running a region on our computers or
  681. 22:56someone else's computer, right? What if
  682. 22:58we're not in the future? Intelligence is
  683. 23:00expensive. People like Lauren, aka
  684. 23:02potato at cursor and SpaceX, are
  685. 23:05spending allegedly $132 million a year.
  686. 23:07This number's and I'll
  687. 23:08explain why in that other video.
  688. 23:10Subscribe if you haven't, by the way.
  689. 23:11That red button helps us a ton. And
  690. 23:13you'll get to be around for
  691. 23:15this rant, which will be fun. Ignoring
  692. 23:17the fact that those numbers aren't real,
  693. 23:19the rate at which prices go down is
  694. 23:21real. Flashbang warning for artificial
  695. 23:23analysis. I need to port this particular
  696. 23:25bench over and I haven't yet. This is
  697. 23:27the cost efficiency over time chart from
  698. 23:30artificial analysis. This takes a given
  699. 23:32score that models could get. So, like
  700. 23:34DeepSeek-R1 getting a score above a 10
  701. 23:37on their index in January 2025. And it
  702. 23:40tracks how much the price for models of
  703. 23:43that level of intelligence goes up or
  704. 23:44down over time. Where things get really
  705. 23:46crazy is all the way over here on the
  706. 23:48right, where we see models that are
  707. 23:49super smart, like Opus 5, which broke
  708. 23:52into the 50-point range for the first
  709. 23:55time, costing $5.86 per task when they
  710. 23:57ran it. And now we have models like 61
  711. 24:00Soul that got the same score for 32
  712. 24:02cents. So, it's already decreased by 10x
  713. 24:05in cost for that level of intelligence
  714. 24:07in just like 4 months. At a given level
  715. 24:10of intelligence, cost goes down absurdly
  716. 24:13fast. Like, 10x a year is a conservative
  717. 24:16estimate here. If you take the 30-point
  718. 24:18range, which cost $2.50
  719. 24:21in February of this year and got down to
  720. 24:233 cents by December of this year, that
  721. 24:26is 8x per month decrease, averaging out
  722. 24:29to 1,000x a year annualized. The rate at
  723. 24:32which prices for intelligence goes down
  724. 24:34is insane. But, intelligence isn't the
  725. 24:36only thing we're paying for. When you're
  726. 24:38building apps with AI, you also have to
  727. 24:40pay to host it. You have to pay to store
  728. 24:42the data in the database. You have to
  729. 24:43pay for whatever like off systems and
  730. 24:45providers you're doing. You have to pay
  731. 24:46Apple to distribute the app. You have to
  732. 24:47pay for all these other things. But,
  733. 24:48there's one more thing you have to pay
  734. 24:50for that people don't think about a lot.
  735. 24:52You got to pay for the compute that your
  736. 24:53agent runs on.
  737. 24:54If you're one of those $5 VPS bros,
  738. 24:57now's your time to shine because we
  739. 24:58actually need to talk. One of the
  740. 25:00[snorts] cool things Cursor does right
  741. 25:02now is the Cursor Cloud. When you spin
  742. 25:04up a cloud thread in Cursor, it will run
  743. 25:06on a full VM with 32 gigs of RAM, I
  744. 25:09think. It might be 16. I'm pretty sure
  745. 25:10it's 32. In Cursor's Cloud with a real
  746. 25:13GUI, real processor, real everything it
  747. 25:15needs in Linux, so that it can spin up
  748. 25:17your app and test it with a real
  749. 25:18computer. Every thread gets its own
  750. 25:20computer. You spin up four threads,
  751. 25:22that's 128 gigs of RAM reserved to you
  752. 25:24for that day. And right now, Cursor
  753. 25:26doesn't charge for that. So, the problem
  754. 25:28now is that your inference is way more
  755. 25:30expensive than the VMs, to the point
  756. 25:32where the VMs are almost a rounding
  757. 25:34error, which is why giving you those
  758. 25:36free VMs is not really a big cost. But,
  759. 25:39remember what I just said?
  760. 25:40The cost of inference is going down, and
  761. 25:43it's going down rapidly. What about the
  762. 25:45cost of compute? What about the cost of
  763. 25:47VMs? See where I'm going here? The cost
  764. 25:50of renting a 16 or 32 gig box is going
  765. 25:54up steadily thanks to AI sweeping all
  766. 25:57the demand for RAM. The result is that
  767. 26:00VMs and compute that you want to run
  768. 26:01your agents on, not the compute running
  769. 26:03the models, the compute running the code
  770. 26:05that the model's editing. That compute
  771. 26:07has been slowly going up in price over
  772. 26:09time, but the inference compute is
  773. 26:11plummeting in price.
  774. 26:13So, one of these things goes up by 25 to
  775. 26:1630% every year, the other goes down by
  776. 26:1910 to 100x every year. We're going to
  777. 26:21quickly get to a point where inference
  778. 26:23is cheaper than the VM. With a model
  779. 26:25like GLM 53 Flash, running it for an
  780. 26:28hour straight is going to cost you a few
  781. 26:30dollars. The VM it's running on is
  782. 26:33likely more expensive than the model in
  783. 26:36the inference you're doing in that
  784. 26:37window. And as models of that price get
  785. 26:39smarter, and as models at that tier get
  786. 26:42cheaper, this will be hit quickly. At
  787. 26:44which point, compute will be a
  788. 26:46constraint for when we're building with
  789. 26:48agents. Right now, we're being given the
  790. 26:49VMs for free, but that is not going to
  791. 26:52last. Even Cloud Code isn't doing this
  792. 26:53anymore. Cloud Code now gives every
  793. 26:55subscriber a credit that they can use
  794. 26:58towards the cloud compute that they use
  795. 26:59if they use Cloud's cloud product.
  796. 27:01There's a lot of layers to why it works
  797. 27:03this way. The compute and the memory are
  798. 27:05expensive, so they have to like worry
  799. 27:07about that. The reason that they have to
  800. 27:08be reserved this way is because of how
  801. 27:10our agents work. Our agents expect to
  802. 27:13run on a real computer with a real
  803. 27:15terminal with real bash so that it can
  804. 27:17run commands, it can run rip grep, it
  805. 27:19can search through the code base and
  806. 27:21find things. It expects to have native
  807. 27:23tools for editing, for checking how much
  808. 27:24CPU is being used, for searching for
  809. 27:26files, for moving files, for running get
  810. 27:28commands, for all these things. Our
  811. 27:30agents expect and are trained on real
  812. 27:33Linux boxes or Mac or whatever else.
  813. 27:35They're trained for real systems that
  814. 27:38they can do things on. And surely you
  815. 27:40can sandbox them some amount, but all of
  816. 27:42those additional layers cost additional
  817. 27:44resources. Sandboxing harder is not
  818. 27:47going to make the compute cheaper, if
  819. 27:49anything it's going to make the compute
  820. 27:50and the memory more expensive. Which
  821. 27:52means we need a better abstraction
  822. 27:54layer. Ideally, in a future where agents
  823. 27:56are cheap and writing code is incredibly
  824. 27:59cheap because the models and inference
  825. 28:00have gotten so cheap, the thing that
  826. 28:01they write them on and to test them on
  827. 28:04should not be this expensive.
  828. 28:06Thankfully, this is a thing we have
  829. 28:07explored for a very, very long time in
  830. 28:09the industry. And this is a word you
  831. 28:11guys have heard from here.
  832. 28:13And we get to revisit an old war that we
  833. 28:15have not talked about in a while. We get
  834. 28:17to talk about big orange.
  835. 28:19Cloudflare. What is the word that y'all
  836. 28:23associate most with Cloudflare? Spam me
  837. 28:26chat. When you think Cloudflare, what do
  838. 28:28you think? Cost, cheap, free, cheap.
  839. 28:31There's like cloud and CDN. Most of them
  840. 28:34here are free, cheap, cost related. A
  841. 28:38lot of what people associate with
  842. 28:39Cloudflare is cheapness. The reason for
  843. 28:42that is how Cloudflare's platform works.
  844. 28:45When I write code for a back end and I
  845. 28:48host it on Cloudflare, I'm not wrapping
  846. 28:50it in a Docker image that they deploy on
  847. 28:52a server. In fact, when I put code on
  848. 28:54Cloudflare, it's not deployed. It's not
  849. 28:56running. It runs when a request comes
  850. 28:58in. The request triggers Cloudflare to
  851. 29:01spin up a worker. A worker is an
  852. 29:03isolated JS process inside of V8, the
  853. 29:06JavaScript engine powering Chrome and a
  854. 29:08lot of other things. And that isolate is
  855. 29:10in the kernel. It's not Linux. It's not
  856. 29:11an OS. It is a isolated execution layer
  857. 29:15where your browser or whatever else can
  858. 29:18execute JavaScript. This is really
  859. 29:20useful in browsers because you can have
  860. 29:22different tabs doing different things
  861. 29:24and not have access to each other's
  862. 29:25stuff. Or you can have one tab with four
  863. 29:27things running in it that are different
  864. 29:29that can communicate with each other but
  865. 29:30not interfere with each other. V8's
  866. 29:32isolation layer is incredibly powerful.
  867. 29:34It's not the most secure thing, but it's
  868. 29:36pretty secure. And what Cloudflare has
  869. 29:37done is taken those isolates, made them
  870. 29:39as secure as possible, so that when a
  871. 29:42user goes to a website you built and
  872. 29:44deployed on Cloudflare, it can grab that
  873. 29:46code from storage, throw it on this
  874. 29:49isolate that's just sitting there
  875. 29:50waiting, execute it, then kill it. So,
  876. 29:52on a platform like a Vercel or Heroku or
  877. 29:55Hetzner or any other traditional host,
  878. 29:57if you and I both host an app on that
  879. 29:59platform, we both have our own Linux
  880. 30:01instance effectively that is running
  881. 30:02with our code in it. On Cloudflare, your
  882. 30:05code and my code are executing in the
  883. 30:07same instance of Linux, just split
  884. 30:10higher up in the V8 layer instead of
  885. 30:12with VMs and Docker. Hopefully this all
  886. 30:14makes sense. If it doesn't, ask your
  887. 30:16agent. I'm not going to keep ranting
  888. 30:17about this. I've talked about this in a
  889. 30:18lot of my videos before. There are
  890. 30:20problems with this model, though. If
  891. 30:22we're running inside of a JavaScript
  892. 30:23isolate, we lose a lot of things. Like
  893. 30:26we can't read files from the file system
  894. 30:28because the file system isn't in the
  895. 30:29isolate, and that would allow us to
  896. 30:31escape and screw with other people's
  897. 30:32stuff. We can't run native code because
  898. 30:35native code escapes the isolate and
  899. 30:36needs to run in the actual like system,
  900. 30:39which we can't do here. Which means we
  901. 30:40can't run a lot of other languages in
  902. 30:42Cloudflare Workers. Means we can't do
  903. 30:44traditional persistent servers in
  904. 30:45Workers. There's a lot of these things,
  905. 30:47and Cloudflare has built lots of clever
  906. 30:49solutions to these problems, but the
  907. 30:51code that we're talking about, the
  908. 30:52JavaScript, is running in this virtual
  909. 30:55layer above V8 instead of running at the
  910. 30:58VM layer. This makes Cloudflare an
  911. 31:00incredibly cost-effective and memory
  912. 31:02usage-effective platform, and that's why
  913. 31:04it's so cheap. It's actually cheap to
  914. 31:06run. They're not just pricing things
  915. 31:07cheaper because they want to win.
  916. 31:09They're doing it because their platform
  917. 31:10allows them to and still have margin. In
  918. 31:12this sense, Vercel's not overpriced
  919. 31:14because they want to make more money
  920. 31:15than Cloudflare. They are charging
  921. 31:17probably similar margins, but it's a
  922. 31:18higher cost to them, too. But since
  923. 31:20Cloudflare is just running in this
  924. 31:22JavaScript layer, you can't really run
  925. 31:24an agent in that because you can't write
  926. 31:26and read files. You can't run a dev
  927. 31:28server. You certainly can't run
  928. 31:30TypeScript to go to turn your TypeScript
  929. 31:32into JavaScript and get feedback on
  930. 31:34what's wrong to your agent. Oh. Huh.
  931. 31:37Weird. It looks like I did exactly that.
  932. 31:40This is the demo I built in Astra, and
  933. 31:42it has some dumb decisions that are
  934. 31:43wasting a bunch of memory, so I'm going
  935. 31:45to switch to this version that Opus made
  936. 31:47cuz it's a better presentation of what I
  937. 31:48have in mind here. Before I can justify
  938. 31:50the chaos I'm about to show you, I need
  939. 31:52to show one last reference. There's a
  940. 31:54library called just-bash. Just-bash was
  941. 31:57created by Malte at Vercel and has
  942. 31:59become a pretty legit library. The point
  943. 32:01of just-bash is to provide agents a full
  944. 32:04fake bash environment in memory in
  945. 32:07JavaScript so that you can import this
  946. 32:09bash from just-bash and then execute
  947. 32:11most traditional bash commands with a
  948. 32:13fake file system, fake processes, fake
  949. 32:15everything, allowing for an agent to
  950. 32:18operate as though it is working within
  951. 32:20bash, even if it isn't. But in order for
  952. 32:23this to work, you also need to be able
  953. 32:24to compile and type check and do all the
  954. 32:26other things that you would do in a
  955. 32:26normal file system if you wanted to use
  956. 32:28this to build. If you set this up as a
  957. 32:29way for your agent to explore fake files
  958. 32:31to find content, awesome. But you're not
  959. 32:33going to build a real app with this. You
  960. 32:35need too many other things, including
  961. 32:37TypeScript Rust, well, TypeScript Go or
  962. 32:39TSC traditional, but now with TypeScript
  963. 32:42Rust, we can do really stupid things.
  964. 32:44Like here, where I had a GPT-61 Soul
  965. 32:47build a full app that is entirely
  966. 32:50functioning all in a V8 isolate. This
  967. 32:53one is running in Node on a server
  968. 32:55technically, but this could just be run
  969. 32:57on your browser. There are some
  970. 32:59limitations, but not as many as you
  971. 33:00think.
  972. 33:01And this all just ran and worked and did
  973. 33:03its thing. And the entirety of
  974. 33:06utilization for this, everything that
  975. 33:08was used here, from the agent to the
  976. 33:11computer it ran on, to the compute that
  977. 33:12the app itself is running on, to the
  978. 33:15type checking and compilation and
  979. 33:17everything else, just ran on my isolate
  980. 33:20and used under 216 megs of RAM and it
  981. 33:22peaked at like 4% CPU.
  982. 33:25Do you understand how cool this is? This
  983. 33:28will allow for you to have an agent
  984. 33:31build an app where both the agent and
  985. 33:33the computer it runs on, not the like
  986. 33:35compute for the inference, but the
  987. 33:37compute that it's running the code on
  988. 33:39and building on, all together for
  989. 33:41pennies. And doing this with Go would
  990. 33:43suck because TS Go wastes a ton of
  991. 33:46resources simply because porting that to
  992. 33:49JS is not viable Wasm, but you get the
  993. 33:51idea. WebAssembly is not a good fit for
  994. 33:54Go. It is an incredible fit for Rust.
  995. 33:56And just to emphasize my point here,
  996. 33:58when I had Astro build this, it chose to
  997. 34:00use ESBuild for the bundler. And just
  998. 34:02sitting here idle, it's using 2x the RAM
  999. 34:05of the other version. Because the
  1000. 34:07inclusion of a Go-based package like
  1001. 34:09ESBuild inherently just eats memory and
  1002. 34:12resources and the data that has to be
  1003. 34:14loaded in. Like we have to load way more
  1004. 34:16in because of how much bigger the
  1005. 34:18bundle is. I see people confused about
  1006. 34:20how this would work on Cloudflare. Do
  1007. 34:21you know what Cloudflare, Chrome, and
  1008. 34:23Node all have in common? They're all
  1009. 34:25using V8 isolates. The way these things
  1010. 34:28work is that they are all using the same
  1011. 34:30JavaScript engine, and when you load a
  1012. 34:32Chrome extension or you load a new file
  1013. 34:35or you have some process in WASM, those
  1014. 34:39are all different isolate workers is the
  1015. 34:41term for it, and they can communicate
  1016. 34:42with each other if they're allowed, but
  1017. 34:43they cannot interfere with each other.
  1018. 34:45What I built here isn't impressive
  1019. 34:46because I rebuilt Bolt but used TS Rust.
  1020. 34:49What I built here is impressive because
  1021. 34:51I could turn my file system on read only
  1022. 34:54and it still works. Nothing here left
  1023. 34:57RAM. Nothing here left V8. I'm not doing
  1024. 35:00anything on the system. This all exists
  1025. 35:02within V8. The whole dev loop exists in
  1026. 35:06V8. There isn't anything comparable. I
  1027. 35:08see people mentioning like random like
  1028. 35:09database companies and stuff that let
  1029. 35:11you execute code to them. No, no, you're
  1030. 35:12you're not getting it. And if you guys
  1031. 35:14aren't getting it and you're my stream
  1032. 35:15audience, I am not excited to see how
  1033. 35:16others deal with this. Let's talk about
  1034. 35:18how computers work really quick. At the
  1035. 35:20bottom, you have hardware, CPU, RAM,
  1036. 35:23whatever else. Above that, you have
  1037. 35:25drivers.
  1038. 35:27Drivers are provided by the thing above,
  1039. 35:29the kernel. The drivers are the method
  1040. 35:31in which the kernel interfaces with
  1041. 35:33hardware. Above this, we have the
  1042. 35:34operating system. Above this, we have
  1043. 35:37applications.
  1044. 35:38I would argue actually we have file
  1045. 35:40system, kind of. Then you have
  1046. 35:41applications. So, let's figure out how
  1047. 35:44something like Heroku, Hetzner, or any
  1048. 35:47normal cloud works. If we wanted to
  1049. 35:50deploy a Docker image on AWS, we are not
  1050. 35:53deploying it here because these things
  1051. 35:55have to exist on AWS's hardware so that
  1052. 35:58they can put more systems above. So,
  1053. 36:01what they'll do is in the application
  1054. 36:03layer, they'll put something like
  1055. 36:04Docker. And you know what you do after
  1056. 36:06that? You copy-paste everything
  1057. 36:09and do this.
  1058. 36:11This is how hosting on normal VPS
  1059. 36:14providers works. On top of the file
  1060. 36:16system and operating system, you have an
  1061. 36:18application, usually something like
  1062. 36:19Docker, and it's not technically running
  1063. 36:21a new kernel instance always. Usually
  1064. 36:23it's doing a shim kernel. So, I could
  1065. 36:26claim like for this layer here that this
  1066. 36:28is all like the like Docker
  1067. 36:31hypervisor I don't fully
  1068. 36:32understand it, but like Docker shim to
  1069. 36:35kernel, which makes the kernel stuff
  1070. 36:37more efficient for sure. So, this shim
  1071. 36:39is there to allow you to skip steps when
  1072. 36:41it makes sense to. And then you're
  1073. 36:42building an OS on top, which is why on
  1074. 36:45something like AWS, you can have one box
  1075. 36:49that AWS is providing that has one
  1076. 36:51person running Ubuntu, one person
  1077. 36:52running Windows Server, and one person
  1078. 36:54running I don't know, Debian or
  1079. 36:55something. That's all happening in the
  1080. 36:57application layer of Docker on top of
  1081. 36:59the operating system, which means every
  1082. 37:01one of these things takes RAM.
  1083. 37:04This is why every time you spin up a new
  1084. 37:06Docker container on your computer, it's
  1085. 37:07using a bunch of resources. It takes
  1086. 37:09resources to run operating systems in
  1087. 37:11your operating system. Let's compare
  1088. 37:12this to how JavaScript works. So, we
  1089. 37:15have our whole stack here, but let's say
  1090. 37:17the application is Chrome.
  1091. 37:20Inside of Chrome, you have V8,
  1092. 37:23which is the JavaScript runtime. And in
  1093. 37:25V8, you have all of these isolates. And
  1094. 37:28all of these isolates can execute
  1095. 37:30different JavaScript files and functions
  1096. 37:32at the same time. This is way more
  1097. 37:34efficient because now every file or
  1098. 37:36application, if it fits in one of these
  1099. 37:38isolates, it doesn't need to shim out to
  1100. 37:41the kernel, run an operating system, and
  1101. 37:43steal a bunch of resources. Like like
  1102. 37:45let's be real here. What takes more
  1103. 37:47resources on your computer? A new Docker
  1104. 37:49instance of Postgres or a new tab in
  1105. 37:52Chrome? Tabs in Chrome, as slow as y'all
  1106. 37:55might think Chrome is, obviously uses
  1107. 37:58way less resources. Absurdly, comically,
  1108. 38:00obviously so. The reason why is the
  1109. 38:03insane billions of dollars that Google
  1110. 38:05has pissed into V8. They wanted to make
  1111. 38:07this engine as efficient as possible so
  1112. 38:09that the web could be a compelling
  1113. 38:11platform so they could finally stop
  1114. 38:12making shitty Windows apps. Google spent
  1115. 38:14a billion dollars so that Chrome would
  1116. 38:16be fast enough so they could stop making
  1117. 38:18Windows versions of Google Earth and
  1118. 38:20That was a lot of money and effort
  1119. 38:23put in to V8. And this has benefited the
  1120. 38:25whole ecosystem in ways that are hard to
  1121. 38:27comprehend, including all of Cloudflare.
  1122. 38:30Cloudflare's whole platform is built on
  1123. 38:32the idea that virtualizing at the
  1124. 38:34operating system level by putting an OS
  1125. 38:36at the app layer is stupid. And V8 is a
  1126. 38:40much better abstraction for putting
  1127. 38:42applications that customers are hosting
  1128. 38:43on top of. The catch is that these are
  1129. 38:46just JavaScript. They don't have full
  1130. 38:48system capabilities. You can't call the
  1131. 38:50kernel cuz there's no kernel you have
  1132. 38:52access to. You can't write files cuz
  1133. 38:53there's no file system. It is just
  1134. 38:55JavaScript. Anything that a Chrome tab
  1135. 38:57can't do, a V8 isolate can't do. With
  1136. 38:59the exception, of course, I don't even
  1137. 39:01talk about CORS now. But remember, all
  1138. 39:02the problems here are you don't have a
  1139. 39:03file system. You don't have native code
  1140. 39:05access. You can't do the things you need
  1141. 39:07to build. Isolates are a good place to
  1142. 39:09put the code once it's built. They are
  1143. 39:11not a good place to build. On Vercel,
  1144. 39:13for example, Vercel sandboxes are the
  1145. 39:15same compute and primitives as hosting
  1146. 39:17on Vercel is. On Cloudflare, Cloudflare
  1147. 39:19sandboxes suck because Cloudflare does
  1148. 39:22not know how to make things work well
  1149. 39:24with Docker because that's not their
  1150. 39:25focus. Their focus is this isolate
  1151. 39:27layer. So Cloudflare sandboxes run on
  1152. 39:29entirely different compute with entirely
  1153. 39:31different platforms than Cloudflare's
  1154. 39:33traditional like worker hosting. So the
  1155. 39:35thing I did here, the thing I enabled,
  1156. 39:38inspired by just bash cuz the thing that
  1157. 39:40makes just bash special is it lies to
  1158. 39:42agents living in this isolate layer so
  1159. 39:44they think they have access to the file
  1160. 39:46system and to these other things. And
  1161. 39:48that is what we have built here. If I
  1162. 39:49was to flip a switch on the file system
  1163. 39:52for the server running this demo to be
  1164. 39:54read-only, so I literally could not edit
  1165. 39:57files on the computer, I could only do
  1166. 39:59things in RAM in my V8 isolate and node.
  1167. 40:02This will still run exactly the same.
  1168. 40:04That is what makes this demo cool. It
  1169. 40:05would be fully possible to run this
  1170. 40:08entire demo in a Cloudflare worker. So
  1171. 40:10instead of needing half a gig of RAM and
  1172. 40:13a bunch of reserved CPU, I can throw it
  1173. 40:15in here and it costs nothing. Another
  1174. 40:18thing to think about here is how CPU
  1175. 40:20allocation works. If you have a VM that
  1176. 40:22has two CPUs and I have a VM that has
  1177. 40:24two CPUs and both are idling, we're
  1178. 40:27still wasting four VCPUs. There are some
  1179. 40:29things that make it easier to like
  1180. 40:30reallocate and have virtual like cores
  1181. 40:32not be guaranteed the same way. But the
  1182. 40:34way it's working on Cloudflare is with
  1183. 40:35the built-in event loop where when your
  1184. 40:37code isn't doing anything, it doesn't
  1185. 40:39cost anything other than a bit of RAM.
  1186. 40:41So when you're waiting for the next
  1187. 40:42token from an inference provider, that's
  1188. 40:44not costing you any compute because the
  1189. 40:46CPU is doing nothing. So that CPU is
  1190. 40:48being used by others. When suddenly data
  1191. 40:50comes in, it will execute the next task
  1192. 40:53because your app, my app, and another
  1193. 40:55person's app are all sharing the same
  1194. 40:57event loop. We're all sharing the same
  1195. 40:59scheduler effectively. So it becomes way
  1196. 41:01more efficient for us to run things
  1197. 41:02here. And even a long-running task that
  1198. 41:04takes hours probably spends most of its
  1199. 41:06time idle. Now that only costs money for
  1200. 41:08when a token comes in, not for the time
  1201. 41:10between tokens. If inference continues
  1202. 41:12to get cheaper, this type of building
  1203. 41:15will become essential because this will
  1204. 41:17enable us to build agentic developer
  1205. 41:19experiences that are cheap on all sides
  1206. 41:22where running the agent is cheap and
  1207. 41:24giving the agent compute to execute on
  1208. 41:26is also cheap. I see some people in chat
  1209. 41:28catching on here asking, is this related
  1210. 41:31to Lakebed? I won't say more yet. I need
  1211. 41:33to give you guys something to be excited
  1212. 41:35about because I just wanted to focus on
  1213. 41:37this. The fact that TS Rust is one of
  1214. 41:40the final pieces I need to take a full
  1215. 41:43end-to-end TypeScript developer
  1216. 41:44experience and do it in an isolate
  1217. 41:46instead of doing it in a VM. For those
  1218. 41:48who are curious and want to see the very
  1219. 41:50complex prompts I used to build TS Rust,
  1220. 41:52here you go. I told it to work in
  1221. 41:55CodeSandbox TS Rust on this computer.
  1222. 41:57Read the agents.md and the type check or
  1223. 41:59accountability files first. Those files
  1224. 42:02included auto notes from the 16-hour run
  1225. 42:04and asked for some things. Make the
  1226. 42:06cargo job count configurable, add script
  1227. 42:09state and split, yada yada.
  1228. 42:11And then update the agents.md D it could
  1229. 42:12do more parallel work. To which I said,
  1230. 42:14"Do it. Great work. I trust your
  1231. 42:15judgment fully. Keep going and doing
  1232. 42:17what you think is best to continue
  1233. 42:18improving compatibility and performance.
  1234. 42:19You can probably move to main soon as
  1235. 42:21well." I did a follow-up at some point
  1236. 42:22saying, "Get whatever the best current
  1237. 42:23state of the work is and set it as the
  1238. 42:25main branch ASAP. I don't care how. I
  1239. 42:26trust your judgment." Then later I did a
  1240. 42:28slash effort cuz I noticed I was on the
  1241. 42:29wrong effort level. Actually, I was on
  1242. 42:31ultra code and it kept bumping me down
  1243. 42:32to medium when it crashed cuz it was
  1244. 42:34running out of memory and crashing
  1245. 42:36system D constantly. But once I like
  1246. 42:38added some things at the OS level to fix
  1247. 42:41this, I had to rerun slash effort to put
  1248. 42:43it on ultra code again on XHI. And then
  1249. 42:44the slash goal of complete the port, get
  1250. 42:46as close as possible to 100%
  1251. 42:47compatibility with TSGo, and then also
  1252. 42:49improve performance. Do the efforts in
  1253. 42:51parallel. Multiple workflows and
  1254. 42:52sub-agents should be running at all
  1255. 42:54times to maximize parallelism.
  1256. 42:55Orchestrate how you need to keep them
  1257. 42:57working independently all on this
  1258. 42:58machine. And I noticed it was running
  1259. 43:00out of compute all the time. So I took
  1260. 43:02other machines I had in my fleet,
  1261. 43:04configured them for SSH access, and told
  1262. 43:06it, "You have SSH access to other
  1263. 43:08machines now, like cup two and Alvin two
  1264. 43:10of my uh VPS's." I noticed it kept
  1265. 43:12stopping because it like got full compat
  1266. 43:15and then like would make one performance
  1267. 43:16room and be like, "Look, I fixed
  1268. 43:17performance." So it needed a better end
  1269. 43:20state. So I told it with a new goal,
  1270. 43:22"Our target is minimum 2x faster than
  1271. 43:24the go build. Continue iterating until
  1272. 43:26we get there." And then it did for 2
  1273. 43:28weeks.
  1274. 43:30And now we are here. So as you see, I
  1275. 43:32wrote some very complex prompts for all
  1276. 43:34of this. Super super high IQ things I
  1277. 43:37was doing here. I'm a mega prompter.
  1278. 43:40Real talk though, the things I did here
  1279. 43:42were not around the prompts. It was
  1280. 43:44around the environment and setup to
  1281. 43:46allow it to do this stuff. So I like I
  1282. 43:48had other threads going where I was
  1283. 43:50auditing constantly figuring out where
  1284. 43:52the blockers were, what's taking a
  1285. 43:53while, what failure modes are happening
  1286. 43:55again and again, and then updating the
  1287. 43:57environment to allow agents to operate
  1288. 44:00more effectively in parallel without
  1289. 44:01stepping on each other. And after a bit,
  1290. 44:03we built systems that allowed that to
  1291. 44:05work and ended up shipping much faster
  1292. 44:06once we did, but my energy was honestly
  1293. 44:09similar to how I work as a manager,
  1294. 44:11where I wasn't spending my time in the
  1295. 44:13trenches writing code. I was spending my
  1296. 44:15time making sure that my team had
  1297. 44:18everything they needed to be as
  1298. 44:19effective as possible in finding where
  1299. 44:21the slowdown was and helping them get
  1300. 44:22around it so that the slowdown would
  1301. 44:23stop happening. Ended up being really
  1302. 44:25fun. And I know I was making a joke
  1303. 44:27about being a mega prompter, but uh I
  1304. 44:29have been politely requested to mention
  1305. 44:31Mega Dev a bit more. I am finally doing
  1306. 44:33a paid course for the first time ever.
  1307. 44:35Feels weird and I want to be very clear
  1308. 44:37about this. Any information that will
  1309. 44:39help you get a job is not going in here,
  1310. 44:41it's just going on my channel for free.
  1311. 44:43The point of this is for employed
  1312. 44:44developers that want to maximize how
  1313. 44:46much they use and abuse AI to ship real
  1314. 44:49software in the real world. I'm working
  1315. 44:51with three other incredible instructors,
  1316. 44:52people who have helped me learn how the
  1317. 44:54web and technologies work for years now.
  1318. 44:56I'll do the sidebar so you can see
  1319. 44:57Angie, who I love to death, Kent, who
  1320. 44:59taught me half of what I learned about
  1321. 45:00React back in the day, and John
  1322. 45:02Lindquist, the creator of Egghead. If
  1323. 45:04you have to pay for this with your own
  1324. 45:05money, I wouldn't recommend it, but if
  1325. 45:07you can get your boss to sign off on
  1326. 45:08using internal like expenses for
  1327. 45:11educational stuff for it, it'll be fun.
  1328. 45:13And I'm going to do a live workshop with
  1329. 45:14it as well, which should be very fun.
  1330. 45:15So, that's where I'll get to talk more
  1331. 45:17about all of these chaotic strategies
  1332. 45:18for maximizing what your agents are
  1333. 45:20capable of, which should be fun stuff.
  1334. 45:23What a journey this one was. I My AI
  1335. 45:26psychosis was already pretty bad, but
  1336. 45:28the fact that all of these truly crazy
  1337. 45:31ideas I've been thinking about for years
  1338. 45:33now are actually doable. Like I've
  1339. 45:36always wanted to have a full stack
  1340. 45:37developer experience that runs purely
  1341. 45:39within V8. Back when Bolt was still
  1342. 45:42StackBlitz and they first put out their
  1343. 45:45full like JS runtime thing inside of
  1344. 45:48WASM, so you could have a full VS Code
  1345. 45:50like experience with apps bundling in
  1346. 45:52the browser, I was blown away. I wanted
  1347. 45:55to go further with that with Cloudflare,
  1348. 45:56and I went as far as trying to reverse
  1349. 45:58engineer StackBlitz and like decode the
  1350. 46:01JS binary in their WASM to figure out
  1351. 46:03how they were doing it because there
  1352. 46:05there was so much cool stuff there.
  1353. 46:05That's how I became friends with Eric
  1354. 46:06back in the day and that stuff was so
  1355. 46:08cool. I've always been a nerd about how
  1356. 46:10the code we write actually runs and
  1357. 46:12executes and how these systems compose
  1358. 46:14and operate. It's such fun stuff. And
  1359. 46:17now I get to try out my crazy ideas.
  1360. 46:19Previously, the vast majority of this
  1361. 46:21was just like imaginary. Like I was
  1362. 46:23playing these games in my head and if
  1363. 46:25any of those ideas went far enough, I
  1364. 46:26could maybe talk about it with a smarter
  1365. 46:28person and maybe inspire them to build
  1366. 46:29something kind of like it in 5 years in
  1367. 46:31the future. Now when I have one of these
  1368. 46:32insane ideas, I tell Opus and then I see
  1369. 46:35if it works or not. Even now, I wanted
  1370. 46:37to see if this will actually run on
  1371. 46:39Cloudflare. So I just told Opus, go do
  1372. 46:41it. And it probably will. Absolutely
  1373. 46:43insane. I On one hand, the engineering
  1374. 46:46we know and love is dead and very very
  1375. 46:48much so. These types of YOLO projects
  1376. 46:50should not be viable at all. Like you
  1377. 46:52shouldn't even be able to get it past
  1378. 46:53the tests, much less actually work as a
  1379. 46:55drop-in replacement for TypeScript. But
  1380. 46:58yeah, if you still think AI dev isn't
  1381. 47:01the future and isn't obviously where all
  1382. 47:02of software dev is going, you deserve
  1383. 47:04the lack of employment you'll have in 3
  1384. 47:05months because this is insane. It's
  1385. 47:08actually hard to fathom how capable
  1386. 47:11these tools have gotten. I think this is
  1387. 47:12everything I had to say on this one. I
  1388. 47:14was up till 6:00 in the morning prepping
  1389. 47:15all of these demos and I'm so proud of
  1390. 47:17what Opus and I were able to cook. Not
  1391. 47:19because I think everyone should use
  1392. 47:20this, but because I can find out if
  1393. 47:22these ideas work or not in ways that are
  1394. 47:24just hard to fathom. I actually feel
  1395. 47:27like we're peering into the future with
  1396. 47:28some of this stuff and it's so cool to
  1397. 47:30see. I cannot imagine where we will be
  1398. 47:32next year. And I hope you guys are
  1399. 47:33excited to go on this journey with me
  1400. 47:35because it's only going to get more
  1401. 47:36chaotic from here. And with that, until
  1402. 47:37next time,
  1403. 47:39peace, nerds.

About this transcript

This page contains the full transcript of You can rewrite typescript in rust for $420k by Theo - t3․gg, generated from the public captions YouTube serves with the video. The transcript has 9,890 words across 1,403 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.