Posts

Showing posts from April, 2023

Pair Programming with ChatGPT

  Earlier today I started work on a small admin project to help me organise my excessive collection of repositories on GitHub. I wanted a list of my repositories, showing the name, url, description, stars and forks. I decided to get ChatGPT to write the code for me. In the conversation that follows, you can imagine an embodied ChatBot sitting next to me as we pair program. I'm the customer, ChatGPT is the programmer. If I'm not happy with the results, I ask my pair to change the code. My part is in italics. Everything else came from ChatGPT. As you'll see, there are a couple of wrinkles I didn't anticipate, but ChatGPT fixed them. This took less time than I'd have taken to write the code, and it was much more fun. I recommend it. Here's the session. Write python to find the names of all my repositories on GitHub, My username is romilly. You can use the GitHub API to retrieve the names of all your repositories. Here is the Python code to achieve that: i

Can ChatGPT code like a pro?

I've been experimenting with the code generation capabilities of ChatGPT, and I'm blown away. As a test of its capabilities I decided to ask it to write a generic version of some code I've used, over and over, in slightly different forms, in real applications. The Problem The code implements a Throttler - a class that wraps something that makes requests and makes sure that requests are not made too often. Lots of APIs apply rate limits to requests, and this code makes it easy to enforce those limits within your application. A coding session with ChatGPT Here'es the session I had with ChatGPT. My instructions are in italics . Everything else - code, comments, and explanations - was written by ChatGPT in response. Write Python to create an Abstract Class called Requester. It should have a single abstract method called request that takes an argument called command. Add docstring comments. Here is the Python code to create an Abstract Class called Requester with a single

Will ChatGPT save your job - or take it over?

Wondering whether ChatGPT will make you more effective, or do your job so well that you are no longer needed? ChatGPT is one of the new generation of AI tools. You can ask it for help and it can turn its hand to a huge range of tasks. ChatGPT as a Python coder Today I used it to write a very simple but useful computer application. The task would have taken me half an hour or so. ChatGPT did the job in a few seconds, and the code it write was well-structured, readable and well commented. So far so good - but what about other tasks? I decided to make a short video about what I'd done. (Watch this space to see it when it's ready).  I knew that my first step would be to write a script. Could I ask ChatGPT to help me do that? Sure. Here's what happened next. ChatGPT as scriptwriter Here's what I typed: Earlier today I got ChatGPT to write a simple application for me. Now I want to make a video showing the process and the result. I'd also like to explain why the automatio