Live data from Hacker News

Trying to Understand Copilot's Type Spaghetti

rtpg.co

31–40 of 89 posts

Re: Trying to Understand Copilot's Type Spaghetti

#31
post #28

The first thing I see when I look at this is "Where are the unit tests?" This is somewhere in the realm of "clever" or "efficient" code: it looks like it could be written in an easier-to-grok way as dozens of lines of if statements, but I assume there is a reason it wasn't (that is better than "just because"). AI-generated or not, someone or team is responsible for making sure the code/app/service is working for cust…

These tools can also generate tests, the OP just doesn't discuss it.

Re: Trying to Understand Copilot's Type Spaghetti

#32

from the original tweet linked in the post "ceiling is being raised. cursor's copilot helped us write "superhuman code" for a critical feature. We can read this code, but VERY few engineers out there could write it from scratch." I don't really agree that code is superhuman if VERY few is able to understand it haha..! Code should complex but easy to follow to make it brilliant in my opinion

I think Kernighan said something along the lines of "Because debugging code is twice as hard as writing it, only write code half as smart as you are or you'll never be able to fix it later". AI-assisted code generators seems to make this problem much worse as I can now write code 2x, or 3x as smart as I am. What hope will there ever be in debugging this? A more optimistic take is that maybe such tools will let us wri…

The optimistic take is a feedback loop that makes them both better and more capable, writing code you can't debug is bad, but it could help you understand and build your own skills to a point that you can.

The pessimistic and more likely outcome is that people just want shit done and so they will slap any half working garbo together as they have done for the last 20 years I have been in the industry.

Re: Trying to Understand Copilot's Type Spaghetti

#33

Earlier quoted context omitted.

That’s not the claim. It’s well commented and formatted so actually quite readable. The claim is that very few could write it. Though I would say that ‘very few’ is a larger group than they think - there are plenty of people doing metatype programming in TS; I’ve dabbled enough that given the problem I could probably tackle it and I know I learned from seeing others do it (because I am far from a typescript professio…

[flagged]

Blog author, yes on being a PLT dork. It was mainly very funny to me how I _immediately_ knew what category of code the tweet's snippet was about. Just instantly knew this was a type spec translator. Seen 10 of them, seen them all.

Re: Trying to Understand Copilot's Type Spaghetti

#34

So unraveling AI generated code is the new programming?

If you are the #2 or later programmer on a project, unraveling human generated code is the old programming.

A big enough quantitative change is a qualitative change. There is a big difference between a bad programmer who banged on that code for three days before finally getting it to do what they wanted it to do, and never went back to try to minimize it and clean it up, and that same programmer pushing a prompt into X-GPT and getting that code in five minutes, then moving on to do it again and again and again dozens of times faster than before.

Like everyone else here of any experience I too have waded through gooey code that was impossible to discern any purpose or design in, because there really wasn't any, after everyone was done hacking on it. But the hacking was still bounded by human speeds.

Our only two options for a code base produced that way would be 1. discard it and start over or 2. hope that the next-generation AIs that aren't just LLMs are able to clean it up, since "automatically cleaning up LLM-generated code bases" is going to be a rather lucrative field. LLMs, no matter how much you hypetrophy them, aren't suitable for coding at scale, and they can't be. Their architecture is just wrong. But that's a claim I only make about LLMs, not AI in general.

Re: Trying to Understand Copilot's Type Spaghetti

#35
post #30
post #28

The first thing I see when I look at this is "Where are the unit tests?" This is somewhere in the realm of "clever" or "efficient" code: it looks like it could be written in an easier-to-grok way as dozens of lines of if statements, but I assume there is a reason it wasn't (that is better than "just because"). AI-generated or not, someone or team is responsible for making sure the code/app/service is working for cust…

You can scaffold up "unit tests", but honestly for type-level stuff you are working in a different space entirely. Your types are correctness proofs, so your underlying code is either typed correctly or not. There's not really a middle ground that unit tests catch. Having said that, typescript's soundness issues make it easy to drive a truck through a certain kind of issue, but generally speaking if your type-level p…

You can't test the function or endpoint from a business definition "does the right thing" perspective?

Re: Trying to Understand Copilot's Type Spaghetti

#36

from the original tweet linked in the post "ceiling is being raised. cursor's copilot helped us write "superhuman code" for a critical feature. We can read this code, but VERY few engineers out there could write it from scratch." I don't really agree that code is superhuman if VERY few is able to understand it haha..! Code should complex but easy to follow to make it brilliant in my opinion

I think Kernighan said something along the lines of "Because debugging code is twice as hard as writing it, only write code half as smart as you are or you'll never be able to fix it later". AI-assisted code generators seems to make this problem much worse as I can now write code 2x, or 3x as smart as I am. What hope will there ever be in debugging this? A more optimistic take is that maybe such tools will let us wri…

And AI-assisted code is almost certainly code that AI can't debug...

Re: Trying to Understand Copilot's Type Spaghetti

#37
post #13

Earlier quoted context omitted.

> It was difficult enough with other people spaghetti code, but being able to generate vast amounts of hard to decipher spaghetti code it only going to make this horrible I've seen some legacy code and the kind of spaghetti humans are able to generate - especially with multiple layers of "I'll just throw in something to make feature X work/fix that bug" - is pretty bad already. I honestly doubt code generation will m…

I fear it will be a quantity issue more than a quality one. Why refactor some code to make it extensible, when AI can write a whole new module from scratch? Don't understand the 10 AI written classes? Leave them be and have AI write some more. Once we get AI code deletion and refactoring I guess it will be ok, but generative models are a problem because code is a liability.

> generative models are a problem because code is a liability.

I wish I could upvote this many times. This is a major, major problem. AI may get your version 1 out the door faster. But when you try to modify it to create version 2...

But someone may ask, "How is this different from any other machine-generated code?" It's different because those tools were built very carefully to generate correct code, and the generated code usually did not have to be modified after it was generated. But when a generative AI is writing the bulk of your application code, neither of those conditions is true.

Re: Trying to Understand Copilot's Type Spaghetti

#38

from the original tweet linked in the post "ceiling is being raised. cursor's copilot helped us write "superhuman code" for a critical feature. We can read this code, but VERY few engineers out there could write it from scratch." I don't really agree that code is superhuman if VERY few is able to understand it haha..! Code should complex but easy to follow to make it brilliant in my opinion

That’s not the claim. It’s well commented and formatted so actually quite readable. The claim is that very few could write it. Though I would say that ‘very few’ is a larger group than they think - there are plenty of people doing metatype programming in TS; I’ve dabbled enough that given the problem I could probably tackle it and I know I learned from seeing others do it (because I am far from a typescript professio…

> It’s well commented and formatted so actually quite readable.

Are you looking at the same code I'm looking at? The first block of code from the article?

I've seen more readable code in Perl Golf competitions.

Re: Trying to Understand Copilot's Type Spaghetti

#39
post #35
post #30

Earlier quoted context omitted.

You can scaffold up "unit tests", but honestly for type-level stuff you are working in a different space entirely. Your types are correctness proofs, so your underlying code is either typed correctly or not. There's not really a middle ground that unit tests catch. Having said that, typescript's soundness issues make it easy to drive a truck through a certain kind of issue, but generally speaking if your type-level p…

You can't test the function or endpoint from a business definition "does the right thing" perspective?

You cannot because if you're testing the type level wizardry, the failure case will not compile.

Re: Trying to Understand Copilot's Type Spaghetti

#40
post #15
post #7

Earlier quoted context omitted.

Even an average programmer can understand it if they bothered to read the TypeScript documentation. “Superhuman” in this case means “has read the manual”.

That's also how you become an extreme outlier at Bash. Actually read the manual.

My favorite kind of manual to actually read is sprinkled with hijinks-enabling arcana, and the Bash manual doesn't disappoint on this front.
Post reply on HN