News for hackers. Stuff that matters.

Ask HN: ChatGPT best programming language to use?

If you are going to ask ChatGPT to write code, which programming language would you ask it to use and why?

I had thought maybe rust, but I read some threads and people were stating the code it writes would not compile sometimes.

( 11 comments | on HN )
Re:Ask HN: ChatGPT best programming language to use? by smt88 on Wednesday March 15, 2023 @12:39AM (#35163943)
* * *
Re:Ask HN: ChatGPT best programming language to use? by tmaly on Wednesday March 15, 2023 @08:29AM (#35167230)
I thought the same thing about the compiler, but the threads I read said GPT would just make up imaginary crates to use in some cases.
Re:Ask HN: ChatGPT best programming language to use? by smt88 on Wednesday March 15, 2023 @04:59PM (#35174630)
> GPT would just make up imaginary crates to use in some cases

I think this is where trial and error comes into play. If GPT makes up a crate for, say, an HTTP server, and the API is very close to a real HTTP server, then it's not a big deal. You can just swap in a crate you know works.

If GPT is making up a crate and also mangling the use of such a crate, then it's probably not worth the human effort to fix all of that.

The same is true with any language: you'd have to try it a few times to decide if it's even worth the time saved.

Copilot is probably a better product for coding regardless, although I think it's deeply unethical and hope it gets sued out of existence.

Re:Ask HN: ChatGPT best programming language to use? by darthrupert on Wednesday March 15, 2023 @02:20AM (#35164591)
It generates pretty good Typescript, if it doesn't select a deprecated library.
Re:Ask HN: ChatGPT best programming language to use? by tmaly on Wednesday March 15, 2023 @08:30AM (#35167240)
What have you tried to prevent it from selecting a deprecated library?
Re:Ask HN: ChatGPT best programming language to use? by kypro on Wednesday March 15, 2023 @02:11PM (#35172422)
Yeah, I've noticed that too. Its code is generally alright, but it has a habit of picking outdated / deprecated / poorly maintained libraries.

I wonder if that's because it's not weighting by recency in it's training or something.

Re:Ask HN: ChatGPT best programming language to use? by muzani on Wednesday March 15, 2023 @09:52AM (#35168340)
The original was mostly trained on Python[1], but JS seems a close second. So I assume python has the highest quality. If you don't specify a language, it seems pick either of these.

[1] https://openai.com/blog/openai-codex

Re:Ask HN: ChatGPT best programming language to use? by Princesscaraan on Wednesday March 15, 2023 @10:00AM (#35168445)
Chatgpt help me in a very nice way. though sometimes my needs not available. There's a trick how to proper ask chatgpt.
Re:Ask HN: ChatGPT best programming language to use? by speedgoose on Wednesday March 15, 2023 @10:49AM (#35169158)
I think it works best in Python, but I don’t have numbers to bring. It’s just how I feel. Other languages have more wrong answers.
Re:Ask HN: ChatGPT best programming language to use? by tmaly on Wednesday March 15, 2023 @03:56PM (#35173856)
I have tested it with Python doing function working with pandas dataframes and the code was perfect.
Re:Ask HN: ChatGPT best programming language to use? by jawmes8 on Wednesday March 15, 2023 @12:37PM (#35170905)
I’ve been using it to learn SQL - it’s been helpful asking it to explain queries or joins that I want to perform.