Skip navigation
Why Microsoft didn't have LLMs do their recent Typescript native rewrite in Go
0:00 / 0:48

Why Microsoft didn't have LLMs do their recent Typescript native rewrite in Go

Ryan Peterman

@ryanlpeterman30K followers

Visit on X
602 likesDownloadOriginal post

84,913 views

Why Microsoft didn't have LLMs do their recent Typescript native rewrite in Go Anders Hejlsberg (Creator of Typescript): "If we just let AI loose on, what is it, half a million lines of code that we have in the old compiler? Well, I don't know that that would absolve us from then having go in and carefully examining every line that came out of it to make sure that there were no hallucinations. Right. Unless you have 100% perfect test coverage, you probably still gotta go check all of that. Now I think a better approach, quite honestly, would be enlist AI to write a program that helps you translate from TypeScript to go, because at that point you can park the stochastic ness in that program and then you can get deterministic behavior whenever you run the program, which means you get the same transformation every time you run it. Right. That's always the thing about AI that people forget it's not deterministic. Right. So you can't really trust that it's going to do the same thing twice. For the full conversation, you can search Anders Hejlsberg's name on my YouTube, Spotify or Apple Podcasts (link in bio)

35 Comments

Comments from the original post on X (Twitter)

  • Rubén's profile picture

    @enrub_en

    "You can't really trust that it's going to do the same thing twice" When you are truly aware of this, is the first big step to learn to use it properly

    22 likes

  • Sam Rose's profile picture

    @samwhoo

    Completely agree. Had the same problem porting chunks of Kubernetes to TypeScript for Ultimately it’s very difficult to know for sure the code is correct without carefully reading it.

    11 likes

  • Jordan Henderson's profile picture

    @jordanhenderson

    100% perfect test coverage is a hallucination. It doesn't test your assumptions in the design. “Program testing can be used to show the presence of bugs, but never to show their absence!” ― Edsger W. Dijkstra

    10 likes

  • P@ulLuo's profile picture

    @IamPaulLuo

    I think 90% if the people talking AI don't understand what none deterministic means.

    9 likes

  • JD Conley's profile picture

    @wackie

    i think they would have if they had fable/sol class models at the time. see: bun zig -> rust

    6 likes

  • James J's profile picture

    @Jamestjsp

    Btw, bun was rewritten in 11 days

    5 likes

  • Alex Lavaee's profile picture

    @alexlavaee

    I'm a Research Engineer at Microsoft Research. You still have to know what good looks like. You can parallelize the verification around that. If you want an example of how to encode verification automatically you can refer to OSS Atomic (bastani-inc/atomic) on Github. It's a verifiable coding agent runtime that comes with builtin verification primitives. It's used for complex tasks and we've measured conservatively about 1.5 hrs less time to verify each task. Sharing in case it's useful for others to have a real world example on how to encode verification that's already in production use.

    4 likes

  • nivelepsilon's profile picture

    @FpeSre

    Determinism is not the real hurdle here, type theory semantic mapping is. Compilers are abstract syntax tree transforms where JS structural typing, prototype chains, and tricky union narrowing have zero direct 1:1 idioms in Go interfaces. Writing a meta transpiler just isolates the translation rules, but human engineers still have to design the underlying memory layout. You cannot automate architecture decisions you have not formalized yet.

    2 likes

  • Jaap Frolich's profile picture

    @JaapFrolich

    @BrendanEich Ngmi

    2 likes

  • spion's profile picture

    @spion

    I'm not sure on this one, the main thing AI is really good at is porting from one language to another. The programs encode perfect specs about desired behavior, an the AI knows a lot about language idiosyncracies already to detect subtle behavior drift for naive translation.

    1 like

  • Riy Adh's profile picture

    @RiyAdh125243

    Brilliant methodology

    1 like

  • Ruben Distinct's profile picture

    @RDistinct

    the compiler port from ts to go was something very unique, something ai doesnt have experience with. Also he said that they tried it but it didnt work as expected.

    1 like

  • Christian Findlay's profile picture

    @CFDevelop

    Regardless of how the code is written, tonnes of tests are needed. The main task here is converting the test corpus to Go. The actual code SHOULD be far less important because the tests should have mutation testing to guarantee correctness of the code

    1 like

  • Alex Rebula's profile picture

    @AlexRebula

    What a great podcast! Wow! I did not imagine I would hear so much behind-the-scenes and history about so many of the languages I've worked since high-school! And I don't remember when was the last time someone mentioning Turbo Pascal we used to learn programming in 1996! 🙂

    1 like

  • rusa's profile picture

    @rusabuilds

    a port needs to produce identical output on the existing test suite, and a model that improvises will quietly change behaviour in the cases nobody tested. for a compiler that is fatal, so a mechanical line by line rewrite is the correct boring choice.

  • TT Aspiring's profile picture

    @Farooq_AI

    Spot on. Park the randomness in the build step, get deterministic output every run. Same principle we apply when building AI tooling for financial systems.

  • rusa's profile picture

    @rusabuilds

    hejlsberg's point is underrated. a line-by-line port preserves the original's structural decisions, which is exactly what you don't want when the language changed

  • Riasat's profile picture

    @riasat

    Behind times. Bun leads the way

  • P. Scott DeVos's profile picture

    @pscottdv

    LLMs can be completely deterministic. What's he on about?

  • Chiang Long King's profile picture

    @longkingchiang

    Nice!