30 Non-Trivial Ways for Developers to Use GPT-4
I confess: My use of ChatGPT has been limited. I don’t like the fact it hallucinates facts. If I have to check everything it says, what is the point? That said, I have used it to design a kitchen garden, which I admit is a pretty trivial use.
Developers, however, have found many non-trivial uses for GPT-4, OpenAI’s latest large language model. In a recent Hacker News thread, developers shared how they’re using the LLM. We’ve compiled the best suggestions here, along with additional suggestions from ChatGPT itself about how developers should use it.
1. SQL Queries
One poster reports being bad at writing SQL queries with bunches of joins. So, the coder just showed the bot the table definitions and told it what was desired. As is often true with AI, it may take a few iterations to get it right, the poster warned.
2. Writing RegExps
The same commenter also uses ChatGPT-4 to write regular expressions. “It is excellent at them,” the programmer reported.
3. Prototypes
Another coder uses it to brainstorm and prototype approaches to a problem. In particular, he used it mostly for machine learning pipelines, small React sites and Python command line interfaces (CLIs).
“First, I’ll ask it to give me an overview of the problem domain; this gives the LLM context,” he stated. “Then, I describe the problem and ask it to generate solutions, along with pros/cons of each approach. This is iterative: you might ask it questions, modify its suggestions, and periodically summarize. After that, you can either ask it to give you code for a prototype or build it yourself.”
4. Rubberducking
Rubberducking is the practice of debugging code by explaining the problem in spoken or written natural language. It comes from a story in The Pragmatic Programmer in which a programmer carries around a rubber duck and debugs their code by forcing themselves to explain it, line by line, to the duck. ChatGPT-4 can be used to explain the code, line by line, according to one programmer.
5. Personal Tutoring
While ChatGPT-4 “is not there yet” when it comes to pure development or peer review, said one user, it is good at clarifying follow-up questions as a virtual tutor.
6. Coding a Database
Along with 7. finding a bug in the metrics, 8. speeding up the test cycle, 9. reducing pressure on the garbage collector and tightening some timer handling, and 10. finding unnecessary type assertions.
Developer Philip O’Toole used ChatGPT-4 for #6-10 and more. It saved him so much time and he enjoyed it so much, he wrote a blog post about how it helped him code the database. At one point, he wasn’t sure how ChatGPT-4’s suggested changes would help reduce pressure on the garbage collector so he asked it to explain, which it could. He made the changes.
11. Writing Micro-Benchmarks for C++
“They always compile, but require some editing,” noted Simon Boehm. It also requires good prompting, Boehm added.
12. Explaining Assembly Code
Another way Boehm used ChatGPT-4 was to just “dump plain objdump – S output into it.”
13. Optimizing Code to Reduce Memory Usage
“I had to optimize some Python code to reduce its memory usage,” wrote Vitor Baptista. “After trying all ideas I could think of, I thought about rewriting it in a different language. Copied and pasted the code into ChatGPT 4. Tried Rust at first, but there were too many compilation errors. Then I tried Go and it worked perfectly.” The developer had never used Go and used ChatGPT-4 to improve the Go code. It gave me great answers, I think maybe once or twice the code didn’t compile (I used it dozens of times per day),” Baptista wrote. “I’m now using the optimized Go code in production.”
14. Writing in JavaScript (or Any Language That Isn’t Your Strength)
Another programmer uses it to generate code in languages that are not that well known to the programmer, which in this case was JavaScript. ”My JavaScript isn’t the strongest, so I’d prolly have to spend 30-45 minutes just coming up to speed again on my basic AJAX and modern syntax, or BAM write a schema of my idea and get GPT to get my idea on paper with halfway decent style, syntax,” the programmer stated. “I can take it from there.”
15. Looking up How to Do Something
“GPT-4 is bad at doing things and great at looking things up for you,” read one submission. “Rather than trying to get it to do things, I ask it how I should do it.”
16. Frontend Writing
One developer used GPT-4 to write a simple React app to test out an endpoint. Once the code was working, the developer put the app back into the AI and asked it to make it “more visually appealing” — and it did.
17. Testing and Documentation
One of the big predictions with AI is that it will be customized for testing. One person is already using it to do unit testing and some documentation. “ I find that the code it spits out isn’t perfect but getting some boilerplate and fixing it up is pretty fast compared to writing from scratch,” the person stated. “I’ve used this enough that I wrapped some cli glue around it…” Mostly the commentator has used it to write Python and Bash, although it’s also been used “with some Makefiles and Dockerfiles thrown in.”
20. OpenSearch (or ElasticSearch) Query Building
“I was new to the technology and their syntax took a while to wrap my head around. Instead I’d just tell ChatGPT my document format and then ask for specific data in natural language,” wrote one poster. “Fair warning, the queries were not always perfect on first try, but it was a lot easier than parsing replies to somewhat similar questions on Stack Overflow. Now I mostly write my own queries but it really helped me get started.”
21. Getting the Ball Rolling in General
The code may not be perfect, but a number of developers said they use GPT-4 to “get the ball rolling” on coding problems. One used it to get started with TypeScript and React. Essentially, the AI acts as a scaffold for learning how to do something complex. One tip for that: Iteratively ask the bot to summarize everything that’s agreed upon before asking it to write the code, suggested another programmer.
22. Image Processing
One programmer reported using GPT-4 to do image processing in OpenCV. “It’s saved a lot of time I would’ve spent figuring out the required transforms and matrix operations,” the developer wrote.
23. Shell Scripting
It’s great for any type of shell scripting and works well for fleshing out type definitions, according to one hacker news reader. Another developer reported using ChatGPT-4 to produce a working web socket server in Rust when the developer had no experience with the networking crate for async runtimes.
Inspired by these ideas, The New Stack decided to asked ChatGPT-4 itself how developers can best use it for building applications. Here’s what it suggested:
24. Natural Language Processing
“Integrate me into your application to provide natural language understanding and generation capabilities,” the AI told The New Stack. “I can assist with tasks like language translation, sentiment analysis, text completion and summarization.
25. Developing a Chatbot
ChatGPT-4 can be used as the backend for building chatbots. It can help developers create interactive user experiences by generating responses based on user queries or instructions.
26. Generating Content
“If your application requires generating content such as articles, product descriptions, or social media posts, you can utilize my language generation abilities to create coherent and contextually appropriate text,” the bot suggested and indeed, one developer on Hacker News did report using the AI to develop wiki articles pages for an encyclopedia in development.
27. Researching and Knowledge Assistance
This one seems most self-evident but is non-trivial. It can also be used to summarize dense passages developers may find in their research.
28. Integrating a Virtual Assistant
“Incorporate me into virtual assistant applications to provide intelligent and context-aware responses,” the AI suggested. “I can help users with tasks like scheduling, reminders, recommendations, and general information retrieval.”
29. Following Best Practices for Code Generation and Debugging
This may seem repetitive, but it’s worth pointing out that the chatbot can also provide insights into programming concepts and best practices.
30. Simulating End User Interactions
“Employ me to simulate user interactions and test the functionality of your application.” the AI suggested. “You can generate sample inputs, evaluate outputs, and perform scenario-based testing.”