Live data from Hacker News

Ask HN: Can ChatGPT generate fully functional code?

news.ycombinator.com

41–50 of 69 posts

Re: Ask HN: Can ChatGPT generate fully functional code?

#42

YEs, but in small blocks and with specific asks. I asked it to generate code based on an existing project of mine, which generates analytics from social media activity. It does a good job of producing function bodies from prompts equivalent to a short comment you might use to document your function in the IDE. For your example, I'd ask it to 'generate code, using Python, that accepts input and updates a display to al…

This is what i asked it for. In separate sessions it built functions slightly differently and only one of its programs had a minor bug. It was interesting to watch it answer the same prompt differently more than once.

Re: Ask HN: Can ChatGPT generate fully functional code?

#44
I believe ChatGPT has some kind of response token limit, which is why longer code snippets commonly get cut off. I've seen some people recommend to enter something like "Continue your previous message starting from the last token", which sometimes works, but even when it does, it often breaks formatting, making it difficult to read the resulting code without copying it somewhere else. What I found to work better is instructing it to output a single function at a time, this usually results in short enough code that it can output all of it in a single message. Something like:

  I want you to send a single function in each response, I will say "Next" when I want you to send the next function.
I was able to get it to generate decently lengthy programs using this (on the order of a few hundred lines) that were syntactically and logically correct without any modification. This may work for some languages better than others, though I imagine you can find some way to logically split up the program for most.

Re: Ask HN: Can ChatGPT generate fully functional code?

#45
post #44

I believe ChatGPT has some kind of response token limit, which is why longer code snippets commonly get cut off. I've seen some people recommend to enter something like "Continue your previous message starting from the last token", which sometimes works, but even when it does, it often breaks formatting, making it difficult to read the resulting code without copying it somewhere else. What I found to work better is i…

All you need is to prompt it with "Continue" and it will keep going exactly where it left off.

Re: Ask HN: Can ChatGPT generate fully functional code?

#46
post #44

I believe ChatGPT has some kind of response token limit, which is why longer code snippets commonly get cut off. I've seen some people recommend to enter something like "Continue your previous message starting from the last token", which sometimes works, but even when it does, it often breaks formatting, making it difficult to read the resulting code without copying it somewhere else. What I found to work better is i…

All you need is to prompt it with "Continue" and it will keep going exactly where it left off.

I've heard this quite a lot too, but it commonly doesn't work. I've had it respond thinking I was talking about using a `continue` statement somewhere in the code, and other times it simply just reprinted the whole code starting from the beginning. If you hit the "Try again" button enough it will usually eventually work, but it again has the problem where a lot of the time the formatting of the text gets messed up.

Re: Ask HN: Can ChatGPT generate fully functional code?

#48
post #46

Earlier quoted context omitted.

All you need is to prompt it with "Continue" and it will keep going exactly where it left off.

I've heard this quite a lot too, but it commonly doesn't work. I've had it respond thinking I was talking about using a `continue` statement somewhere in the code, and other times it simply just reprinted the whole code starting from the beginning. If you hit the "Try again" button enough it will usually eventually work, but it again has the problem where a lot of the time the formatting of the text gets messed up.

That's due to the front-end markdown codeblock ending and the model not outputting it again since it's continuing from the last token. I believe if you tell it to continue but include code blocks again, it will do it

Re: Ask HN: Can ChatGPT generate fully functional code?

#50

Take a look at this: https://www.dropbox.com/s/gq2hkp7w37c5y6q/ai.png?dl=0

It did write incorrect tests for non-Latin characters though.

It wrote a lot of incorrect tests at this point not only when non-Latin characters where involved.

Look at the mixed case tests below. Always the same string but sometimes a palindrome and sometimes not.

Same for the trailing whitespace test.

Maybe it got tired at this point. Could also explain why the performance test is missing warmup :D

Post reply on HN