Playback speed
undefinedx
Share post
Share post at current time
0:00
/
0:00

Using ChatGPT to improve your code

I welcome my AI overlords.

In the circles I hang out with I only see criticism of AI when it comes to programming. I question this because I see AI as a tool, and like any tool, it has the potential to be useful. I also hope to be employed as a programmer years from now so my mindset is to embrace it more than criticize its shortcomings. In this post, I’m going to give one example showing how I’ve been using it. The video says it all. It’s also on YouTube.

I demonstrate how I have been using chat GPT/AI to improve code. I start by showing a function that I wrote a while ago in Elixir, which is written using nested case conditions as that’s the natural way of thinking for a programmer coming from a procedural background.

I later discovered Elxir’s with clause, and decided to use that instead since it’s more of a functional style and promotes Elixir’s approach of passing the output of one line to the next. I used ChatGPT to rewrite and refactor the code and I think you’ll agree I’m better for it. I had to make some minor edits to get the tests to pass (it used a token variable which was not defined in the function), but overall this saved me a lot of time.

Yeah, this is a small blog post but I wanted to encourage more people to give it a shot. I’ve also been using Amazon Codewhisperer as an IntelliJ plugin and its auto-complete features are beating anything IntelliJ could ever come up with on its own. Maybe more on that some other time.

0 Comments
Bit Byte Bit
Bit Byte Bit
Authors
Zarar Siddiqi