中文 →
The Peterman Pod · 2026

The creator of TypeScript: port, don't rewrite; fix JavaScript, don't replace it

Anders Hejlsberg × Ryan Peterman · Creator of TypeScript: 10x Faster Typescript, Why AI Won't Replace SWEs

Show The Peterman Pod · 2026-08-17 · Length 66 min · Guest Anders Hejlsberg · Host Ryan Peterman · Video YouTube

The moment

While talking about using AI to migrate code, Anders Hejlsberg tells a story that has nothing to do with compilers. He went on a trip with friends; one paid for the hotel rooms, another for something else, and afterwards they needed to work out who owed whom. They handed all the costs to an AI, which very authoritatively produced an answer, and the answer was wrong, because it forgot some of the settlements made along the way.

Had they asked it for a spreadsheet, he says, they would have got the right answer. A spreadsheet is just a program, and AI is very good at writing programs.

"You ask it for a program that computes the answer."— Anders Hejlsberg · [00:18:23]

That is not an aside in this episode. The TypeScript compiler has just moved from JavaScript to Go and got roughly ten times faster, and the way the team moved it follows the same idea: do not let an error-prone process produce the result directly; build a deterministic tool first, and let the tool do the work. Several threads of the conversation run back to it.

Who's talking, and when

Anders Hejlsberg is Danish. He built Turbo Pascal, Delphi and C#, and has led TypeScript since 2012. His first product, Turbo Pascal, was Z80 assembly from top to bottom: compiler, editor, runtime library. He remembers squeezing it into a 12K EPROM, being 20 bytes over budget, and replacing a long jump with a short jump to another jump to save a single byte, then moving on to the next. It was, he says, almost like woodworking.

His most vivid confession here is about the C# years, when he "drifted up into the stratosphere". His job was language design and writing the spec; he coded less and less, became, in his words, an "architecture astronaut", and grew unhappier without quite knowing why. Only when TypeScript came along and he went back to writing a compiler did he realize he is simply a happy coder. He had plenty of chances to become a manager and chose to stay an individual contributor.

Host Ryan Peterman interviews senior engineers and the creators of systems; he has also had C++'s Bjarne Stroustrup on. This time he brought a list of popular AI takes from the internet and asked Hejlsberg to rule on each.

The timing: in March 2025 Hejlsberg himself announced the port to Go; in April 2026 the Go-based TypeScript 7.0 Beta shipped; this episode went up in August. The 10x had gone from demo to something people could install, and what he offers here is a look back at a finished project.

The episode, in depth

Port, don't rewrite

Why touch the compiler at all? Performance and scalability, he says. JavaScript was designed for a few hundred lines of UI in a browser; running a compute-heavy workload like a compiler costs a 2–3x penalty against native code from the start. Worse, JavaScript is single-threaded by design: web workers cannot share objects, only serialize data to JSON and pass it along. Moore's law now gives us more cores rather than faster ones, and a compiler that cannot use shared-memory concurrency is leaving money on the table.

Why not sooner? When the project began in 2012, nobody imagined people writing something the size of VS Code in TypeScript, let alone the in-house codebases of over ten million lines he mentions. Meanwhile every new feature, union types, control-flow analysis, made the checker smarter and a little slower. By his account TypeScript 6 runs at about half the speed of TypeScript 1.5, which did a great deal less.

Before choosing a language, the team made a more important choice: port, not rewrite. Only a line-by-line port preserves the existing compiler's semantics, algorithms and exact behavior. Starting from scratch would yield a "different language", one that gives different errors and makes different choices wherever it has to pick between possibilities.

"…rewrites are toxic often for ecosystems because they sacrifice compatibility…"— Anders Hejlsberg · [00:19:23]

A port means the new language must accommodate the old code's assumptions: garbage collection, first-class functions and closures. Go meets them, and adds mature native code generation on all major platforms and excellent shared-memory concurrency. Asked what Rust lacked, Hejlsberg names garbage collection, and the borrow checker, which does not allow circular data structures, while this compiler is full of them: trees with parent pointers, recursive types, symbols that refer to each other. They tried; it was not feasible.

AI played only a small part, because the project started two years ago, when models were nowhere near good enough. The team hand-wrote prototypes of the scanner and parser, convinced themselves 10x was real, then wrote a tool that translates TypeScript into Go syntactically. The output had no syntax errors but did not compile; types and data structures had to be reworked by hand. Even today he would not hand half a million to a million lines to an AI to translate, because unless you have 100% test coverage you must check every line for hallucinations. Better to have AI write the translator, parking the stochasticness in a program that does the same thing every time you run it.

Fix it, don't replace it

Hejlsberg tells TypeScript's origin in detail. As he recalls, the Outlook.com team asked the C# group to productize something called Script#, which transpiled C# into JavaScript so the team could get Visual Studio's type checking, refactoring and navigation. His reaction: is JavaScript really that busted? Your fix is to abandon JavaScript, treat it as an instruction language and point a code generator at it?

"I'm like, couldn't we like fix JavaScript? Wouldn't that be better?"— Anders Hejlsberg · [00:47:41]

That stance shapes how he judges the competition. CoffeeScript, he says, was just a different syntax, with the same semantics and no new tooling; Dart was about replacing JavaScript. Facebook's Flow was the direct rival, and he credits TypeScript's win to two things. First, self-hosting: the compiler is written in TypeScript, so contributors did not have to learn OCaml, and the team used its own tool daily and knew at once when something was slow or broken. Second, a language service built into editors from day one. They never wrote the compiler to generate machine code, he says, but to make better tooling. TypeScript's types are erased at compile time and have no effect on runtime behavior; they exist for completion, red squiggles and refactoring, so you can type half your code and leave the rest, which is gradual typing.

Peterman asks whether, now that AI can rewrite codebases, people will migrate to the languages they would rather use. Hejlsberg thinks the opposite. Models are best at the languages they have seen most; a little language you just invented has none of it in the training set, so you burn untold tokens in the prompt teaching it first.

"I do think the incumbent languages are actually if anything getting stronger."— Anders Hejlsberg · [00:23:51]

He points to a knee in TypeScript's adoption curve that coincides with AI, and says that last year it became the most used language on GitHub. The numbers are checked below.

A compiler for agents, and where he gets off the bus

Why does tool speed matter more now? More and more work, he says, is done by agents running in the background; they make mistakes just like we do, but you can have as many as you like. If every edit costs a two-minute type check, that is horrible. And agents are now smart enough to know that renaming by grep is a trap: rename a property called version, and every other object with a version property breaks too.

"So you got to do semantic search and the only thing that can do semantic search is a compiler"— Anders Hejlsberg · [00:50:18]

The same logic explains, to him, why AI tools almost all write TypeScript rather than JavaScript: type annotations steer the model toward fewer mistakes, and an AI living in a sandbox may not be able to set up a runtime, but it can run the compiler and fix its own errors before telling anyone.

In the round of internet AI takes his line is consistent: AI is impressive, but he will not go to 100%. Will AI write 90% of code? For vibe-coded apps it already writes all of it, which makes the claim almost self-fulfilling by volume; for high-quality code nobody has written before, he is not convinced.

"I know that AI could not write our compiler, the TypeScript compiler. It just can't."— Anders Hejlsberg · [00:52:44]

A model, in his view, is a big stochastic machine that has memorized the internet and can extrapolate a little beyond it, and the concepts in this compiler are not in its training set. What about not reading the code, not using an IDE? If your app drains a user's bank account, he says, you are the one in court.

"They're going to sue you, not the AI."— Anders Hejlsberg · [00:54:19]

Why does his view differ so much from what people at Anthropic say? Not over what AI can do, he answers, but because people love to take it all the way to 100%, and that is where he gets off the bus: someone still has to understand what is going on and how it connects to the business. As for AI replacing junior engineers, he asks back:

"Well, if it does, then how do you ever get senior software engineers…"— Anders Hejlsberg · [00:56:13]

He grants that the pyramid has narrowed at the bottom, with companies wanting newcomers to rise faster into supervisory roles, and that the craft is shifting from typing code to reviewing agents' code. He is candid about himself: after forty or fifty years he still enjoys typing code, would happily hand tests to AI, and has always found reviewing other people's code the harder job.

Claim check

The native port made TypeScript ten times faster. Hejlsberg also says VS Code is 2.3 million lines. [00:15:16]

Supported

Microsoft's March 2025 benchmark has VS Code (counted as 1,505,000 lines) going from 77.8s to 7.5s, with six projects sped up 9.1x to 13.5x. The line count differs from the episode's, and the benchmark is the team's own.

Last year TypeScript became the most used language on GitHub, ahead of JavaScript and Python, so "more than 50% on GitHub" is TypeScript. [00:24:59]

Supported, but overstated

GitHub's Octoverse 2025 counts monthly contributors: about 2.64 million for TypeScript in August 2025, only about 42,000 ahead of Python. Ranking first by contributors does not mean half of all code; the report calls the link to AI a correlation, not a cause.

AI tools all write TypeScript because type annotations help models make fewer mistakes, and the compiler can check their work first. [00:25:41]

Supported, but overstated

A 2025 study by Mündler et al. had open models of 2B–34B parameters write TypeScript: on average 94% of compile errors were type errors; type-constrained decoding halved compile errors but raised functional correctness by only 3.5–5.5% relative. It never compared TypeScript with JavaScript directly.

Crossing over

Ten takeaways

  1. Anders Hejlsberg's advice: rather than asking AI for an answer, ask it to write a program that computes the answer, so the result is reproducible.
  2. The TypeScript compiler went native to escape JavaScript's 2–3x performance penalty and to use shared-memory concurrency across many cores.
  3. The TypeScript team chose a line-by-line port over a rewrite, because a rewrite changes compiler behavior and sacrifices the compatibility the ecosystem depends on.
  4. TypeScript chose Go over Rust because the compiler relies on garbage collection and closures and is full of circular data structures Rust's borrow checker disallows.
  5. For the move to Go, the TypeScript team first wrote a syntactic translation tool, then reworked types and data structures by hand, using AI only occasionally.
  6. TypeScript began with Hejlsberg's response to Script#: instead of treating JavaScript as a compilation target, fix JavaScript itself.
  7. Hejlsberg credits TypeScript's win over Flow to a self-hosted compiler that invited community contributions and to an editor language service from day one.
  8. Hejlsberg argues AI is best at the languages most common in its training data, so AI will make incumbents like JavaScript, TypeScript and Python stronger.
  9. Hejlsberg says the compiler is the only reliable tool for agents' semantic search, which makes type-checking speed matter more in the AI era.
  10. Biologist François Jacob called evolution a tinkerer; TypeScript tinkers with JavaScript the same way, except that its patch can be erased whole.

Sources