Live data from Hacker News

Trying to Understand Copilot's Type Spaghetti

rtpg.co

51–60 of 89 posts

Re: Trying to Understand Copilot's Type Spaghetti

#51

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…

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

That’s just how type programming looks.

Here’s (https://github.com/unional/type-plus/blob/main/packages/type...) a human written example that’s well-factored and uses loads of subtypes to clarify what it’s doing - but it’s still going to read like the black tongue of Mordor to you if you’re not familiar with how this kind of type stuff is structured and used.

And factoring all that stuff out may help readability but it doesn’t help comprehension - try and trace what the actual underlying type definitions for some of those utility types like IdentityEqual are actually doing (look at https://github.com/unional/type-plus/blob/main/packages/type...) and realize the rabbit hole runs deep in this stuff.

Re: Trying to Understand Copilot's Type Spaghetti

#52

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

Technically they're saying they can read it but wouldn't be able to come up with it on their own.

Which is impressive, generally reading code is considered harder than reading it so in that sense it is inhuman.

Re: Trying to Understand Copilot's Type Spaghetti

#53
post #50

Hi, CopiotKit CEO here (I wrote the original viral tweet). This article is great! Thanks for posting. I'd also written an analysis of the code - including announcing a $1000 prize for the best alternative code: https://ai88.substack.com/p/ceiling-has-been-raised-analyzin... We were going to announce the winner this week but if we get a few more submissions we will definitely consider them. Just submit a PR to https:/…

Could you help me understand which Copilots are involved in this? Your tweet at https://twitter.com/ataiiam/status/1765089261374914957 mentions "Cursor's copilot". The blog post at https://rtpg.co/2024/03/07/parsing-copilots-type-spaghetti/ talks about GitHub Copilot - did they make a mistake there? And your product is CopilotKit - is that related to the GitHub and Cursor Copilots in some way or is it something diffe…

Hah, too many copilots… let me try to clarify:

We are building CopilotKit = a framework + platform for building context-aware AI assistants into any application (not necessarily coding related applications).

Part of CopilotKit is about giving the Copilot / AI agents access to the application through a typed "inline realtime API". And to make ergonomics great for _our_ users, CopilotKit ships with hardcore type programming.

Cursor's Copilot (unrelated to CopilotKit) helped us write this type code (that's what went viral). And yes, GitHub Copilot is a mis-attribution.

Re: Trying to Understand Copilot's Type Spaghetti

#54
post #34

Earlier quoted context omitted.

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 ti…

Based on what you're saying, it seems like in the future people will only choose 1, not 2.

Re: Trying to Understand Copilot's Type Spaghetti

#55

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…

TS type formatting is an unpleasant language to write in, but it’s touring complete and not that different from C++ type formatting. Writing complex statements in it is just like complex statements in any language - break it down to understandable parts and build those up.

Re: Trying to Understand Copilot's Type Spaghetti

#56
I've been noticing a steady uptick in increasingly complex types like this making it into libraries/@types packages in the definitely-typed repo, and I'm concerned. There are potentially severe performance implications for being too clever, especially since the TS compiler is written in TS. For example, recursive types can seriously bog down the compiler/checker. It doesn't take long to start hitting diminishing returns, especially in larger codebases. You either get perfect type checking while the TS language server uses 800% of your CPU, or you bite the bullet and supplement the lack of typing with unit tests. I think rewriting TS in a more performant language like Zig or Rust would alleviate this to some extent, but TS will still give you more than enough rope to hang yourself with.

Re: Trying to Understand Copilot's Type Spaghetti

#57

Earlier quoted context omitted.

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

That’s just how type programming looks. Here’s ( https://github.com/unional/type-plus/blob/main/packages/type... ) a human written example that’s well-factored and uses loads of subtypes to clarify what it’s doing - but it’s still going to read like the black tongue of Mordor to you if you’re not familiar with how this kind of type stuff is structured and used. And factoring all that stuff out may help readability bu…

The fact that unclear code is common does not make it clear.

Single-letter variable names, ternary operators and long run-on lines, like salt, are delicious in small quantities. But when you're writing code so complicated you need multiple comments, within a single statement?

I appreciate that you've got to piss with the cock you've got. I've certainly done things with C++ template metaprogramming, with perl, with TLA+ and with bash that I'm not proud of. But the fact the tool forces me to write something unclear doesn't mean I'm not writing something unclear.

Re: Trying to Understand Copilot's Type Spaghetti

#58

Earlier quoted context omitted.

What is typing. Lets say you have no hands, no eyes, and cannot speak or to speed this up- All you can do is communicate with foot taps (in great detail) to a human translator. Would we tell this person they are not programming?

What is your point?

[deleted]

Re: Trying to Understand Copilot's Type Spaghetti

#59

Earlier quoted context omitted.

What is typing. Lets say you have no hands, no eyes, and cannot speak or to speed this up- All you can do is communicate with foot taps (in great detail) to a human translator. Would we tell this person they are not programming?

Depends -- are the foot taps communicating a program or was the message for human consumption? If self-modifying code executes in the forest but nobody is there to observe it, does it have an author?

Programming. All Im trying to illustrate is that, it's not the typing that makes the sausage, it's the ideas. Who cares how the code gets created, if the people involved care, they can provide input and assistance to make the final outcome exactly what they want.

Re: Trying to Understand Copilot's Type Spaghetti

#60
post #9

Earlier quoted context omitted.

What is your point?

They should have used copilot to write the comment, might hav been coherent them /s

Here you go:

Typing, in the broad sense, refers to the action of inputting information into a device, whether it's done via a keyboard, voice, or any other method. When you describe a scenario in which a person can only communicate through foot taps to a human translator, this still qualifies as a form of inputting information. The method of communication might be unconventional and require translation into a form understandable by a computer, but it remains a way of interacting with a device or system.

In the context of programming, what fundamentally matters is the ability to formulate logical instructions that a computer can execute. If a person can convey these instructions through foot taps, and these are then translated accurately into a programming language by a human or machine, this person is indeed programming.

Programming is defined by the cognitive process of solving problems and giving instructions, not necessarily by the physical act of typing these instructions in a conventional manner. Therefore, we would not tell this person that they are not programming; rather, they are programming using an alternative method of communication. This highlights the inclusive and adaptable nature of technology and programming, which can accommodate various methods of interaction to include individuals with different abilities.

Post reply on HN