The vibe code society would benefit way more if libraries hosted their docs in a way that's easy to copy and paste into an LLM.
Type-constrained code generation with language models
31–40 of 134 posts
Re: Type-constrained code generation with language models
#32I think TypeScript is uniquely positioned to be the optimal language for LLMs. Tons of training data (benefiting from all the JS examples as well) plus the structure of types for LLMs to follow and tools to enforce.
LLMs work well with any static analysis tool. I frequently instruct Claude to use stuff like “go vet” and “deadcode” when it goes on a tear and writes a bunch of broken trash and declares mission accomplished.
tsc error messages are so bad that every time my LLM sees one of those "SomeType is not assignable to SomeLongAssTypeDontEvenTryToUnderstandWhatsGoingOnHere>>>>>>>>>>>>>>>>>>>" it just gives up and casts to any. goes for python too.
Re: Type-constrained code generation with language models
#33Earlier quoted context omitted.
There are languages that constrain types a lot more tightly than TypeScript, e.g. Kotlin, Rust, and Haskell. The more constrained the types, the more correct the program could be.
Yep, and Rust famously goes beyond this by modelling memory ownership at compile time. In fact, the more behaviour we can model at compile time the better when it comes to LLMs - there's some cool ideas here like transpiling Rust into languages for formal verification. See https://github.com/formal-land/coq-of-rust as an example. Formal verification was one of those things that was previously so annoying to do that i…
Re: Type-constrained code generation with language models
#34Earlier quoted context omitted.
Go’s compiler is WAY faster than Rust’s. As far as speed of the actual program, Rust will generally be faster.
cargo check is WAY faster than go build
Re: Type-constrained code generation with language models
#35The vibe code society would benefit way more if libraries hosted their docs in a way that's easy to copy and paste into an LLM.
many docs now include llms.txt https://llmstxt.org/
Re: Type-constrained code generation with language models
#36Earlier quoted context omitted.
many docs now include llms.txt https://llmstxt.org/
I saw that but it doesn't work for me. I use Gemini 2.5 Pro Preview right now, and it cannot fetch content from links. What I am looking for is a large text file with public API class, function, etc. signatures, plain text documentation and code examples.
Re: Type-constrained code generation with language models
#37Earlier quoted context omitted.
I saw that but it doesn't work for me. I use Gemini 2.5 Pro Preview right now, and it cannot fetch content from links. What I am looking for is a large text file with public API class, function, etc. signatures, plain text documentation and code examples.
https://ai-sdk.dev/llms.txt
Re: Type-constrained code generation with language models
#38Earlier quoted context omitted.
Yep, and Rust famously goes beyond this by modelling memory ownership at compile time. In fact, the more behaviour we can model at compile time the better when it comes to LLMs - there's some cool ideas here like transpiling Rust into languages for formal verification. See https://github.com/formal-land/coq-of-rust as an example. Formal verification was one of those things that was previously so annoying to do that i…
Can LLMs properly code in Rust yet? There is way more TypeScript code out there compared to Rust, and I doubt structured output can alleviate this.
Re: Type-constrained code generation with language models
#39Earlier quoted context omitted.
This is about the speed with which the compiler can advise an LLM that a particular thing checks or doesn't check. Typescript is much slower than Go
okay so basically the faster compiling means a tigher feedback loop for the LLM to -know- if the code compiles or not etc? interesting is go faster than rust?
The reason for this decision is that they wanted a near 1:1 port of the typescript code to go, keeping design and structure almost identical.
You can’t do that in rust as easily because of all the cyclical references and indirection involved.
A rust port would be a rewrite. This is merely a migration.
Re: Type-constrained code generation with language models
#40That this research comes out of universities, and not large AI labs, makes me think those labs believe that larger models are still the way to go.