• forrcaho@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    9 hours ago

    I recently asked ChatGPT to generate some boilerplate code in C to use libsndfile to write out a WAV file with samples from a function I would fill in. The code it generated casted the double samples from the placeholder function it wrote to floats to use sf_writef_float to write to the file. Having coded with libsndfile over a decade ago, I knew that sf_writef_double existed and would write my calculated sample values with no loss of precision. It probably wouldn’t have made any audible difference to my finished result but it was still obviously stupidly inferior code for no reason.

    This is the kind of stupid shit LLMs do all the time. I know I’ve also realized months later that some LLM-generated code I used was doing something in a stupid way, but I can’t remember the details now.

    LLMs can get you started and generate boilerplate, but if you’re asking it to write code in a domain you’re not familiar with, you have to understand that — if the code even works — it’s highly likely that it’s doing something in a boneheaded way.