Ask HN: ChatGPT best programming language to use?

2 points by tmaly ↗ HN
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

[ 2.9 ms ] story [ 29.1 ms ] thread
Rust is a good idea because "does not compile" is better than "contains lots of errors, but compiles/runs anyway". No one should be running ChatGPT-produced code without carefully proofreading it anyway.

The training set likely contains more JavaScript than any other language, so the resulting code quality would probably be the best, but JavaScript is also the most tolerant mainstream language and would tolerate a lot of runtime errors.

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

It generates pretty good Typescript, if it doesn't select a deprecated library.
What have you tried to prevent it from selecting a deprecated library?
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.

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

Chatgpt help me in a very nice way. though sometimes my needs not available. There's a trick how to proper ask chatgpt.
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.
I have tested it with Python doing function working with pandas dataframes and the code was perfect.
I’ve been using it to learn SQL - it’s been helpful asking it to explain queries or joins that I want to perform.