Ask HN: Those with success using GPT-4 for programming – what are you doing?
Personally, GPT-4 has wasted about as much of my time as it's saved with its constant hallucinations and lack of insight when writing NixOS derivations and a Rust web backend. I wouldn't let it near my delicate-hackish checkpointing work in C++.
What are you doing where it serves you well?
109 comments
[ 4.2 ms ] story [ 212 ms ] threadI just use Amazon CodeWhisperer as a nice autocomplete but that's it.
Regular Expressions. I hate doing regexps. It is excellent at them.
Wiki articles for an encyclopedia I'm developing. It is great at this, but occasionally I catch it hallucinating articles out of whole cloth because it has access to zero information about what I asked it about, so it just goes from the article title and imagines what it must be about.
I know where to use it right, and I've found my output has not only doubled since I started using it, I am enjoying coding even more than ever because it has got rid of the worst drudgery that would cause me to switch from my IDE to my browser and bring up HN to avoid working.
Here's an example of one that helped me a lot. This takes no time at all to get ChatGPT to generate by giving it anonymized snippets of table data saying:
"here's an example of the relevant tables, I want output that looks like this, what query does that?"
and it just works instantly.
ChatGPT did NOT format it this way, I changed the line breaks and indentation formatting to better fit viewing in Chrome/Safari. I also renamed tables/columns out of personal responsibility, to generic names which make it all the more confusing.
So now, rather than take time to get complex queries right, I quickly sketch a query that's roughly what I want, and tell ChatGPT to "Fix this Sqlite query."
Short, functional things like this I've found to really be ChatGPT's strength. For example, I had some godawful nested PHP code that had been written years ago I was trying to muck with. Asking GPT to sort it out for me took me way less time than trying to figure it out myself.
I've also used it for SQL queries and things like list comprehension, etc.
The few times I've pasted in whole code blocks and asked it to do XYZ, I've ended up basically debugging my prompt instead of my code.
I probably could have spent more time framing the query to get better results.
2. For more complicated tasks it requires good prompting. Example: Tell me three ways to fix this error, then pick the best way and implement it. <paste error> <paste relevant code>. Without the "step-by-step" approach it almost never works.
3. It's pretty good at writing microbenchmarks for C++. They always compile, but require some editing. I use the same prompting approach as (2.) for generating microbenchmarks.
4. It's pretty useful for explaining things to me that I then validate later via Google. Example (I had previously tried and failed to Google the answer): The default IEEE rounding mode is called "round to nearest, ties to even". However all large floating point numbers are even. So how is it decided whether 3,000,003 (which is not representable in fp32) becomes 3,000,002 or 3,000,004?.
5. It can explain assembly code. I dump plain objdump -S output into it.
The main limitation seems to be UI. chat.openai.com is horrible for editing large prompts. I wrote some scripts myself to support file-based history, command substitution etc.
https://www.h-schmidt.net/FloatConverter/IEEE754.html
And AFAIK the LLMs, lacking the ability to actually calculate, can't check which numbers are such?
I'm now using the optimized Go code in production.
[1] I stopped the process early, as it was taking too long
There’s also an interesting paper about providing it guidance that it can make a “tree of thoughts” which allows it to move forward and backwards as it comes up with solutions then present its best solution to you. The paper suggests you can squeeze a lot more performance out of LLM’s (even smaller ones) this way. I’ve been wanting to experiment with my prompting in this fashion: https://arxiv.org/pdf/2305.10601.pdf
It's saving me time (sometimes 2x speed up on certain, well-specified, tasks), and I enjoy using it. I wrote a blog post with some details on how it has helped me code the database: https://www.philipotoole.com/what-did-gpt-4-find-wrong-with-...
That said, the most recent release of GPT-4 seems a little more buggy[2].
[1] https://www.rqlite.io
[2] https://news.ycombinator.com/item?id=35970711
Simple as that. Of course, sometimes I got the "message too big" error. So I pasted bits of the sources files, choosing pieces I thought were reasonably self-contained. I also fed much of my unit tests through it, asking "see any missing test cases?" While some of the answers were not that helpful, digesting the feedback from GPT-4 made me think more about my code, and make some changes for the better.
Right now Sam Altman is channeling Zuckaberg by claiming to be the good guy changing the world, but in reality hoarding data and asking congress to build him a moat.
I just didn’t feel like looking up the language specific regex syntax I needed and poring over the verbose examples for an hour.
Worked perfectly.
Sometimes I ask it to write complete classes for me. My longest prompt was full page long and it wrote a county-city autocomplete from a database: the back end in Go, the front end in plain vanilla JS with a non-jQuery based lightweight library (I asked it).
These models are good for ideation, scaffolding, and prototypes. It's currently clumsy to fully build an app with an LLM, but they are quite useful for certain tasks.
Computing how to dilute a concentrate into a fruit punch, how to create and render a template in golang, how to parse an int in golang, what makes a chord progression a "lydian" chord progression... it goes on and on.
And that’s for things I’m fairly competent in, to judge the quality of an answer.
* If you can write it from memory, go ahead and do so. Do not consult GPT-4
* If you know what to do but need to look a few things up - put your best effort into GPT-4. It will flesh it out
* If you're using a library that is new, you can copy paste the library examples into GPT-4 and then describe what you want to do. It will give a great starting point
I know how to for example divide and multiply on paper. Still I use calculator for that.
Maybe it's good at trivial stuff, but then I don't need it for trivial stuff so why use it then. This example is more like saying you'd use a calculator to solve (5 / 10) when it's faster to solve that yourself.
Now if I was just learning my times tables, sure I'd use ChatGPT, but once I've learned them it's not helping me on the basics anymore, and may be actively hindering me.
For example, a utility to use the bitbucket api to dump all of the environment variables configured for a pipeline.