from Hacker News

Ask HN: How do you use AI for software engineering?

by CityOfThrowaway on 3/16/24, 3:14 PM with 49 comments

Hey HN,

It feels like so much has changed in the last 18 months and I feel like I'm behind the curve.

I love software engineering and have been somewhat hesitant to use these new tools. But I am now committed to becoming an expert on using AI in my development workflow.

What are the tips you would give to somebody who is trying to figure this stuff out for the first time?

I have Copilot installed. Are there other tools that are making a big difference? Any particular workflows that make these tools most effective? Etc. I'm open to hearing everything!

Thank you all!

EDIT: So many amazing answers. One thing I'm curious about... if you can, I would love to see example transcripts from ChatGPT. Obviously many won't be able to be shared, but hopefully somebody has something that can!

  • by throwaway74432 on 3/16/24, 4:28 PM

    In my opinion, using these tools daily and extensively, AI and AI copilots are an extreme force multiplier for in writing boilerplate code, debugging simple (but non-obvious) mistakes in existing code, and context immersion ("How do I X in framework Y"). It truly helps elevate the craft of SWE above writing code to complexity management and system evolution.

    I also feel like this generation of senior/staff SWEs (the senior pre-AI engineer) is in a very unique position for the following reason: we know what the correct code should look like, because we've written it ourselves many times, and we know how to review and modify it quickly. I don't think new SWEs will have that same ability. At the same time, that ability may not be required in the future as AI gets better and better at following instructions correctly.

    AI's future in coding is uncertain. I think there is a new unrealized engineering platform on the horizon that can only be realized through a very small and focused group of architects using AI (maybe even 1 person), and that this new platform, which is focused on complexity management and system evolution, will change how we "code" completely, at the same time resetting AI's copilot utility in this new world.

  • by Strom on 3/16/24, 5:10 PM

    I use ChatGPT (paid GPT-4) as a quick & competent secretary. Mostly for discussion of architecture, bouncing ideas and seeing if it can spot any problems, and for questions answerable by reading manuals. Stuff that previously meant a lot of manual searching by myself is now a quick question.

    For code, I use it rarely. Mostly for small snippets, like shell scripts or SQL queries. It makes too many mistakes when dealing with bigger problem spaces and validating its work takes so much effort that I might as well write the code myself.

    Overall I think it has a significant positive impact on saving me time, even though I still write almost all of the code myself. That's because writing code has never been a significant time chunk of my work. Figuring out what exactly to write is the hard part. Once you can describe it in detail, the actual mechanical act of converting it from English to a programming language is rather trivial.

  • by BewareTheYiga on 3/16/24, 4:20 PM

    I find the paid version of ChatGPT to be an effective pair programmer with me. From ideas to initial scaffolding to get my thinking straight about outcomes. I write mostly Python, and I find it great at typing my functions and writing docstrings. I also write alot of infrastructure code for the AWS Cloud, and I find ChatGPT better at that than Code Whisperer/Q, but I expect in the AWS context it will catch up.
  • by Zambyte on 3/16/24, 4:29 PM

    I use Kagi Ultimate for access to GPT 3.5, 4, 4 Turbo, Claude 1, 2 3, and Mistral Small and Large. I also run a local language model that I can pass data to that my employer wouldn't be happy with me shipping to external APIs.

    I use the language models conversationally as a supplement to, and interface to documentation. Things like high level design questions. I also use it to parse through error logs that I don't understand. Sometimes it can point me in the right direction faster than doing web searches for random snippets in the log. My actual code generation is fairly minimal. At most I usually just ask it for an example to convey an idea in some language, and then I adapt the example to meet my needs.

  • by abroadwin on 3/16/24, 4:32 PM

    1) Glorified doc search

    2) Mechanical operations (e.g. translate this SQL query into a knex query)

    3) Code review, verification of modern idiomatic approaches in languages I use infrequently

  • by Ashken on 3/16/24, 3:27 PM

    I personally have found that ChatGPT is great to bounce ideas and concepts off of. If I’m unfamiliar with something or I’m trying to learn a new skill or get a second opinion on some design or architecture details, it’s very helpful in that regard.

    When it comes to pure code, ChatGPT will deceive you. I’m at the point now where I’m very hesitant to copy and paste ChatGPT code. I’ll have to completely vet it first, or it’ll have to literally just be a line or two. And even then I’ll likely have to refactor it. ChatGPT is just wrong too often when it comes to the actual code either due to lack of context about the problem or just downright hallucinations. It’s even gotten some boilerplate wrong.

    When it comes to Copilot, I honestly haven’t been able to quantify how beneficial it’s been for me. I’ve often had to delete or modify its code. I think it could partially be because I’m not as skilled with it. It could also be that I’ve just had to write a lot of JS lately, and there’s probably a ton of bad JS that it’s been trained on. I remember being more impressed with it when I write Rust. But I’m also new with Rust. I need to try it with something like C#, which has more difficultly than JS but I’m also proficient with it.

    All in all, AI tools for me have been just that, tools I can use to help me get the job done.

  • by al_borland on 3/16/24, 8:12 PM

    I've started to look at the quick answers more in Kagi which use AI. That's saved me some time.

    I have Copilot installed, but don't really use it much. I had to disable the auto-complete, because it uses tab to accept, which made it impossible to simply use the tab key... you know, to indent my code. The idea that I would need to hit escape every time I wanted to press tab was stupid. Accepting a suggestion should require a modifier key, and there didn't seem to be a setting to change this. Therefore, I only use Copilot when I explicitly invoke it, which is almost never. (If someone knows how to make this better, I'm all ears)

  • by onion2k on 3/16/24, 4:30 PM

    I'm not a dev any more so I guess saying I use AI for software engineering is a stretch, but I run Mistral 7b locally and use it to assist with engineering management things. Recently I took a several lists of things from the 6 teams I run, that were all roughly the same things but written differently, and prompted Mistral to dedupe the lists based on the semantics of what my leads had written. It didn't do a terrible job. To have done the same thing by hand would have taken a couple of hours. I was impressed.
  • by wrs on 3/16/24, 5:00 PM

    I’ve been doing a lot of AWS infrastructure setup lately and use ChatGPT frequently to generate possible solutions and starting examples in CDK. It doesn’t solve the problems reliably by any means, but it’s good for getting an idea of an approach so I can go read the docs. It can even output a diagram if you ask for mermaid format.

    It’s good for “rubber duck” debugging when things don’t work. I just give a brief description of what I’m trying to do, and paste in some code with an error message or some log entries, and it’s pretty great at pointing to the problem and suggesting a fix.

    Since its capabilities are opaque, I constantly try new things. Yesterday I asked it “what was the earliest version of sass-loader that supported the quietDeps option” and it actually answered the question, with a citation. That saved a lot of time!

    There was a cookie error that showed up as a pop up in the Chrome devtools. I couldn’t copy and paste the error from the pop-up, but I took a screenshot of it and pasted that into a chat. ChatGPT read it and gave me a little tutorial on the SameSite cookie setting.

    It seems to be getting a little bit more introspective lately. Last week I asked it about something, and it described a solution, then apologized and said that wouldn’t actually work, and gave a different answer. I mean all of that happened in one answer, not because I prompted it. Then I asked for clarification, and it apologized again and said the original solution would work. (It wouldn’t).

  • by mellosouls on 3/16/24, 4:25 PM

    ChatGPT (paid) for everything from mentoring to memory-refreshing to creating wiki pages. It's a complete game changer for me.

    I also use copilot/chat in VSCode and have used GitHub copilot in the terminal in the past.

    But really nothing above is as useful as ChatGPT.

    Apparently Claude 3 Opus is it's first serious competitor, I haven't tried it.

    Ignore negative feedback on ChatGPT from anybody who hasn't used the paid version, free stuff isn't the same.

  • by rekoros on 3/16/24, 4:36 PM

    I recently upgraded to the paid version of ChatGPT and it's actually proven to be a pretty effective partner in getting unstuck.

    The two areas where it's been particularly helpful:

    - Tricky Postgres queries - it essentially explains the pretty dry docs to you like you're five

    - Partially because I use nvim without intellisense (made the switch after 23 years of vim last year!) - occasional TypeScript type issues

  • by pabe on 3/17/24, 7:31 AM

    I'm using Jetbrains AI, ChatGPT 4 and Cursor.

    Cursor is great for diving into third party codebases as it can read your whole project if you tell it to. So, let's say you're in some frontend file and don't understand why it behaves weird, it can point you to a different file (e.g. "Hey, there's a global CSS file that has an impact here!"). I hope Jetbrains will catch up, soon.

    Jetbrains mainly differentiates from ChatGPT through their IDE integration. You can select code and ask it to refactor, find issues or chat about it. It proposes Git commit messages.

    When I feel lazy, I use AI to create simple functions, e.g. "write a function that recursively reads all files in a given directory and returns all file names containing a given string". But most of the time it's more about dealing with existing code than implementing something new.

  • by etothet on 3/16/24, 4:23 PM

    I often use ChatGPT to generate code for specific tasks. For example, maybe I need to pull thousands of files from S3, perform some sort of manipulation, and then send them back to S3. I can ask ChatGPT about this and have it generate the basic functionality of what I want, but then refine it myself to get the details exactly how I want them. So I find it extremely good at getting me 80%+ through basic tasks, saving me often many minutes on the mundane parts of these tasks. I gladly pay the $20/month for this.

    I have briefly tried it in my IDE, but so for I don’t like the experience of any of the plugins. They feel a bit awkward to me in their current state. But, I know other devs who love the integration directly in their IDE.

  • by Difwif on 3/16/24, 4:32 PM

    Mostly ChatGPT but I recently added https://aider.chat/ semi successfully into my workflow. It doesn't replace ChatGPT but it has replaced certain tasks that involve editing files. It uses GPT-4 (or Claude Opus) to write and apply diffs to my git repo and automatically includes my code in the context. In summary:

    Design - ChatGPT

    Major features - Aider

    Fixups - GitHub Copilot

    I'm thinking about forking Aider because I think it could easily handle the design portion if I had more control of how it applied diffs. Right now it decides when it applies diffs in chat and sometimes you want to go back and forth before it starts to wreck a file without enough requirements.

  • by standeven on 3/16/24, 4:26 PM

    Anytime I find myself coding something easy, but repetitive and boring, I hand it off to ChatGPT.

    “I’m going to give you a list of 50 variables and I want you to format them into functions like this:”

    It’s faster and easier than writing a script to do it.

  • by dakom on 3/16/24, 4:39 PM

    I write frontend web code in Rust (dominator). There is no plugin for Figma that handles this out of the box, but by copy pasting the CSS and putting it in a comment, Co-Pilot can then infer the transformation to Rust syntax. In the past I would have taken the time to write my own parser/mapper, now I don't have to, nor does _anyone_, it's even _better_ for it to learn from local context e.g. for my own personal formatting style etc.
  • by vander_elst on 3/16/24, 4:39 PM

    Are there any tutorials you recommend to see how to better leverage AI? I looked at some videos on YouTube and it seemed that the overall workflow was quite slow.
  • by corytheboyd on 3/16/24, 4:34 PM

    Same as pretty much everyone else, give copilot the easy/dumb stuff. I sometimes throw it oddball questions I know it won’t give a great answer to, but an ok answer is sometimes enough information for further targeted searching of my own. I started work on a side project recently and was missing copilot enough (only had it on the work computer) to go buy a personal license.
  • by hafley66 on 3/16/24, 4:33 PM

    I like re-implementing libraries for learning. Take something you know very well and redo it with something you are trying to learn.

    For example, making both redux and react-query drop in replacements using just rxjs.

    I learned a great deal from these. I'm not going to use them but now I understand rxjs way more

  • by can16358p on 3/16/24, 4:26 PM

    I sometimes have nasty bugs in my code which are not directly visible to my eyes, and I ask ChatGPT 4 to find the bugs, and it usually does, and explains what I'm doing wrong.

    In some sense, it's a bit like pair programming... with a partner available 7/24 and responding immediately.

  • by ramesh31 on 3/16/24, 4:50 PM

    The biggest gain for me has been avoiding Google/SO for API references and "How do I just do this thing" type questions. The productivity increase is insane versus sifting through the nightmare of whatever web results have become today.
  • by the_arun on 3/16/24, 4:48 PM

    Someday imagine we save only prompts in git & generate entire app in the build pipeline. This expects app generation is always consistent.

    However, not using ai today. Mainly because, I am running legacy ucode.

  • by chc4 on 3/16/24, 4:50 PM

    I don't use it at all. The handful of times I have tried to ask ChatGPT questions or to implement some algorithm it has made up or gotten wrong integral parts.
  • by jasfi on 3/16/24, 4:38 PM

    I use it as conversational search. That said, I'm actually building a platform for writing software (and more) with AI.
  • by shambu2k on 3/16/24, 4:22 PM

    phind.com has pretty much replaced googling for me, I've been also using it a lot for code reviews.
  • by FrustratedMonky on 3/16/24, 4:27 PM

    As a better search. Also Can be like junior dev to hand off boilerplate or easy tasks.
  • by hu3 on 3/16/24, 4:20 PM

    The usual:

    ChatGPT to find fixes for weird errors.

    Copilot to autocomplete code.

    I feel guilty for not using paid ChatGPT subscription more.

  • by Havoc on 3/16/24, 4:26 PM

    ChatGPT to generate what amounts to building blocks and then assemble them by hand.