Comment on AP Shares Guidelines Prohibiting Staff From Using AI to Write Publishable Content

<- View Parent
kava@lemmy.world ⁨1⁩ ⁨year⁩ ago

It depends how you use it, I think, like any tool. I might ask ChatGPT to help me write an algorithm to do a certain thing in pseudocode so I can understand it. Ask it a few questions about optimization just so I have a sense for how it works then I implement it myself.

It can also help you think about ideas. I will copy paste a function or file and then ask questions like “what are some considerations do you think I should have?” “is there anything I could be missing?” “what could make this code better?” “how would you optimize this?” “how would you make it simpler?”

let me find some simple example

function findAbsoluteMax(arr) {
  return arr.reduce((val, next) => {
    if (Math.abs(next) > Math.abs(val)) {
      return next;
    } else {
      return val;
    }
  });
}

Let’s ask GPT4 “how could we make this code better?”

It offers two suggestions

  1. there should be some simple error handling. for example if the arr is length 0 then it should throw an error or return a null. this makes sense and is a good thing to add - perhaps this would have saved me a lot of headache in some scenario where I’m getting a weird bug

  2. add a ternary operator to make the arr.reduce call shorter

    return arr.reduce((val, next) => Math.abs(next) > Math.abs(val) ? next : val );

I think this does actually make it more readable and condenses it - a pretty good thing

Now, this is a simple function but you can actually copy in a whole file and ask it to analyze things you might be missing or considerations you could make. It’s like talking to the yellow duck except the yellow duck talks back

There’s a lot of power in this technology and it doesn’t simply revolve around copy pasting code. Perhaps my example wasn’t the greatest but someone else can share how they use it

source
Sort:hotnewtop