I find that LLMs tend to generate better Python code than TypeScript code.

Reply to this note

Please Login to reply.

Discussion

When it comes to types, python is arguably easier to reason about than typescript, given that the in-code types are just for reference.

Typescript types can break even when they are actually valid. But it takes some intuition to know when to use the escape hatches, so I can see why an LLM would have trouble with it.

I wonder if LLMs would write javascript better than typescript too.

Types are definitely a stumbling block for LLMs. I think you are onto something there.

My personal guess is that there’s just so much crappy TypeScript code out there that without a ton of guardrails it’s just a pasta machine.

Second to that is the lack of understanding of category theory which IMO needs some level of reasoning.

TS & CT? where? 🧐

What’s CT?

Category Theory

Ah, gotcha. What was your question?

Oh, just curious how category theory and typescript are intertwined.

Well, more like type theory has to do with category theory. It’s One of the first things you’ll like encounter when learning functional programming. Type operations, follow the rules from category theory (from math).

Yes, and it can generate better TypeScript code than Zig code and so on. In summary, older the language better the code. At the extreme if you invent a new language no LLM will be able to help you. So, LLM are an ossification force that will make newer languages adoption harder than ever.

That's because typescript is stupid. 😂

Don't you think it depends on the LLM provider? And when you say better, it isn't obvious what you mean since one would imagine the types on typescript would act as a feedback loop to the LLM when something is off?

Depends on the model, yeah, for sure. I tried multiple models and the generated Python was still better in my opinion.

I don’t think it was the types: the code was objectively better structured, more maintainable, less junior level mistakes, if you catch my drift.

its really bad at rust code

What’s your take? insufficient training on Rust?