I've been using it for small blocks of code or specific functions - stuff I'd have to look up documentation or Stackoverflow for. I see it as a productivity booster, not a replacement. You can't tell it to "create a CRUD app", but you can ask it to create a nodejs function that gets all the records from a mongodb database.
Is it better than Copilot with comment-based incremental code writing?
Ask HN: Can ChatGPT generate fully functional code?
61–69 of 69 posts
Re: Ask HN: Can ChatGPT generate fully functional code?
#62It made a playable game, that was close to the output that it suggested would occur, but it did have a few mistakes - it missed 2 win conditions (rows and one of the diagonals), and the output didn't quite align fully (i.e. "" instead of " " being printed and no lines for board edges, it also doubled up the diagonal checks oddly.
# Check if there is a winner, and if so, print a message indicating who won
if board[0][0] == board[1][1] == board[2][2] and board[0][0] != "":
print(f"Player {board[0][0]} wins")
elif board[0][2] == board[1][1] == board[2][0] and board[0][2] != "":
print(f"Player {board[0][2]} wins")
else:
# If there is no winner, the game is a draw
print("It's a draw!")
It took me a while to find the right prompt to fix this as it seems to confuse the code checking for game over, which checks for a winner as one of the conditions, for the code that checks for the winner at the end of the game.One of my prompts led to the output being made the program be refactored into a function run in a loop rather than a one shot game. and then I tried:
>the play_game function prints the wrong output when there is a winner in the columns or rows
and got the desired fix.
I like the stateful nature of this.
Re: Ask HN: Can ChatGPT generate fully functional code?
#63Somewhat related — I’m curious has someone built a ChatGPT based Linux command line helper? Ideally should be runnable via CLI
Re: Ask HN: Can ChatGPT generate fully functional code?
#64Re: Ask HN: Can ChatGPT generate fully functional code?
#65The code I got for "write a small python program to play tic tac toe" was complete (though I had to write "continue" to get all the output. It made a playable game, that was close to the output that it suggested would occur, but it did have a few mistakes - it missed 2 win conditions (rows and one of the diagonals), and the output didn't quite align fully (i.e. "" instead of " " being printed and no lines for board e…
I noticed a bug, informed ChatGPT and it fixed it correctly, which is cool and all.
But I'm really interested in the next thing: I didn't save the code and so reran the same prompt a few days later. Now it was correct the first time. Did it learn the bug? It also lost the Exception handling it had in the first version, though. And it changed it's naming scheme for member variables from `m_foo` to `foo_`.
Re: Ask HN: Can ChatGPT generate fully functional code?
#66Take a look at this: https://www.dropbox.com/s/gq2hkp7w37c5y6q/ai.png?dl=0
Oh my! It does not really matter if this is actually self-aware, but in terms of productivity: well it has the potential to be revolutionary. No longer does a person need to know how to program. Just talk to a computer and the computer will generate the code to execute such task.
I think this is getting caught up in media sensationalism. ChatGPT is regurgitating copied code from various sources. A way to look at this is if you could type out questions to Stack Overflow, then it responded by giving you code that most closely matches to what you asked. The thing about that is it is taking and searching code that thousands of humans have created, "filtering" based on question asked, and giving it back to you. Instead of a person doing the hard work of searching Stack Overflow and other sources, ChatGPT can be the new centralized source to get copied segments of code.
Copying and pasting code from various sources is not anything new. Because a person has copied a piece of code from somewhere doesn't mean they don't need to know programming, what is going on, or how to troubleshoot it. Some people, who are being lazy, might think that ChatGPT is a way out of studying and understanding what is being done, and they will sooner or later found out that it isn't.
Re: Ask HN: Can ChatGPT generate fully functional code?
#67Try a simple calculator. It will give you the complete code for that. I think there's a set limit on output text so that's why your tic-tac-toe was incomplete. I've asked for the calc in Rust and Python and I got a working app for both. It was simple but the fact that it gave me what I asked for is amazing. I bet that you could break-up your app into functions and have ChatGPT write each function to get to a bigger p…
Instead of you having to Google search everywhere or look in multiple sources, you were able to just ask ChatGPT.
Re: Ask HN: Can ChatGPT generate fully functional code?
#68Try a simple calculator. It will give you the complete code for that. I think there's a set limit on output text so that's why your tic-tac-toe was incomplete. I've asked for the calc in Rust and Python and I got a working app for both. It was simple but the fact that it gave me what I asked for is amazing. I bet that you could break-up your app into functions and have ChatGPT write each function to get to a bigger p…
It's not that amazing. You can find complete examples of calc in Rust and Python all over the Internet. It just spit out a copy of someone else's code, and gave it to you. Instead of you having to Google search everywhere or look in multiple sources, you were able to just ask ChatGPT.
Overall, it's impressive tech.
Re: Ask HN: Can ChatGPT generate fully functional code?
#69Anyway, when this happens just use the prompt : “continue”. From this it’ll generally do a good job of continuing where it left off, but some refactoring is often required. As it doesn’t always exactly begin where it ended and leaves out vital code or in complete event handlers and functions for example.
From an initial prompt, you may need to continue several times Ron get to complete code you’re after.
Of course, you can throw the resultant incomplete buggy code back in as a new prompt and request analysis and bug fixes. Which it does a good job of resolving.
Of course, all of this subject to the complexity of your perk or/request