Live data from Hacker News

Type-constrained code generation with language models

arxiv.org

51–60 of 134 posts

Re: Type-constrained code generation with language models

#51
post #34

Earlier quoted context omitted.

Working with both I can say that this is a big no, go mod is as fast if not faster, usually Go dep are much faster because Go does not import as much dependencies as Rust.

In Rust you only need to compile your dependencies once. After that it's just your app because dependencies don't change.

that is also the case in Go…?

Re: Type-constrained code generation with language models

#52
post #10

This was an obvious next step. Most current products can only restrict the token prediction to valid JSON or a specific JSON schema at best. There's no reason that this should be the only grammar available for constrained output mode. The real challenge will be to make this detect and switch languages automatically. For example, a snippet of code could include a LaTeX formula in a comment and SQL in a string literal.…

SRLCG: Self-Rectified Large-Scale Code Generation with Multidimensional Chain-of-Thought and Dynamic Backtracking https://arxiv.org/abs/2504.00532 IterGen: Iterative Semantic-aware Structured LLM Generation with Backtracking https://arxiv.org/abs/2410.07295 ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code Generation https://arxiv.org/abs/2411.07112v1

Another one: SequenceMatch: Imitation Learning for Autoregressive Sequence Modelling with Backtracking https://arxiv.org/abs/2306.05426

There was also an hn thread: https://news.ycombinator.com/item?id=36425375

Re: Type-constrained code generation with language models

#54
post #13
post #12

Earlier 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?

Go has a very simple type system that is easy to typecheck on every token.

TypeScript has a type system that is complex enough, you can literally implement wasm inside it (and then use that to run e.g. Doom: https://socket.dev/blog/typescript-types-running-doom)

Re: Type-constrained code generation with language models

#55

I 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.

It’s better sure but as a power TS user it still sucks at generating better code, and consistently fucks up with generics (or doesn’t use them) or simple types sometimes.

Re: Type-constrained code generation with language models

#57
post #24

Earlier quoted context omitted.

God help us…

what do you dislike about it?

TypeScript is arguably one of the weaker statically typed languages, with how it allows `any` to quietly violate the type checked assumptions. It makes it harder to do a lot of the basic typing mistakes in JS, but it doesn't prevent them by any means, especially if you have to interface with (typeless) JS code.

So for these reasons alone I would be against using TS as a lingua franca for LLM codegen (as is GP I assume). As another commenter mentioned, LLMs have a tendency to throw their hands^Hlogits up when presented with complex TS type errors and just resort to using `any` to get it to compile (and probably hiding bugs).

And that doesn't even touch the issues with the JS/TS ecosystem and runtimes more broadly.

Re: Type-constrained code generation with language models

#58
post #36

Earlier quoted context omitted.

https://ai-sdk.dev/llms.txt

Depends on the library I guess, I spent 12~ hours today vibe coding with LiveKit and their /llms.txt is https://docs.livekit.io/llms.txt

thanks for the feedback. let us see how we can organize this better for compat with diff LLMs.

Re: Type-constrained code generation with language models

#59
Been using Devin for a few months now, for Typescript and Python.

I've never seen it check-in uncompilable code, but watching the Devin console I can see it building and using the code to ensure commits are not complete garbage. When it has checked-in compilable and almost right but slightly wrong code, automatically running lint and tests (it doesn't always run them before checking in) from ci triggers it to push a fix on its own.

Feedback loops are nice, but they can be expensive, and time consuming (oh look at me complain that it takes Devin a whopping 15 minutes to complete a task) so I can definitely see the value in type constraints.

Post reply on HN