by benmorris · 3y ago · 0 comments
I've had chatgpt help me with the following just this week among other things.
- solved a complex issue with scaling and transformations using pixijs upon providing a code example. The solution was 99% there and saved me hours of debugging.
- refactored JavaScript to the async/await pattern
- simplified a complex nested logic in c# with citations
- scaffolded a MySQL create table statement upon providing several c# classes. Again saved me the tedious steps of typing them out.
It supplied this :
// Parse the Diameter header
ByteBuffer buffer = ByteBuffer.wrap(message);
int version = buffer.get() & 0xff;
int flags = buffer.get() & 0xff;
int length = buffer.getShort() & 0xffff;
First problem, it's version, length, flags. Second problem, length is 24 bits, not 16. Third, 24 bits unsigned won't fit in a Java int (which is signed). Then there is the extra masking, which isn't a bug but is (I'm reasonably sure) unnecessary.That's 3 sneaky bugs in 4 lines of code, and it didn't even try to parse the rest of the header.
I'm impressed that it produces _anything_, but it's dangerous to trust.
ChatGPT is as reliable a source as any friend in a pub after 3 beers. It is definite in its answer, convincing with its phrasing and more than likely misremembering something it overheard on the radio while driving to work.
When I tried re-prompting, it produced more complicated, just as incorrect code.
Apparently it costs OpenAI a couple cents per prompt. So I assume this is an attempt to limit spam to keep costs down.
I use ChatGPT for 200-300 queries per day and it’s astonishingly accurate.
I’ll double check with Google if I’m unsure but it’s almost always been correct.