"write a function in java to decode a rfc 3588 diameter header"
They both need a lot of hand-holding. Too much to make it worth using them.
Things they get wrong...
1) They are confident about the structure, but are 100% wrong.
2) They get Java types wrong, and try to put unsigned data into the same size signed type (8 bits into a byte, 24 bits into an int).
3) They marshal data into ints in a way that is correct for C code, but wrong for Java code (missing the 0xFF mask)
4) They forget previous instructions and keep re-introducing bugs.
5) ChatGPT kept thinking that version only had information in bits 6-8.
If you know _anything_ about what you're trying to do, it's a waste of time to use a LLM. If the code has anything interesting, a LLM will write broken code.
On the plus side, Bard was quoting sources, complete with license. That led to my first pull request to hopefully fix Bard's upstream source, and let me understand what (byte[0]&0x77) << 16 does, why it works and why byte[0]<<16 doesn't. But then, the LLMs didn't help with that, my need to fix it did.
http://blog.jason.pollock.ca/2023/04/trying-to-write-code-wi...