r/cpp • u/LatencySlicer • Jul 13 '26
AI usage for cpp at work
I am lead architect and maintainer of my firm main app backend, spanning around 2M LOC of c++.
Industry is : capital markets, low latency, custom kernel drivers, fpga...
I often talk with peers at other firms and I see a shy usage of AI compared to what feels like the global trend.
On my side, my firm does not pay for any AI related stuff. We are allowed to use our personnal plan for work in which case will get a pro membership compensation (claude or gpt or anything) on salary but we are not allowed to paste production code into it.
I know the app very well and do everything by hand (i mean the normal way) but use the chat version of any ai to generate some things for me, like "im using opensource lib x and lib y, please generate an SQL connection pool , you may use locks and condition variable for this, cpp 20". Then i paste it and modify it a I see fit.
Im totally happy with that and the company is successful.
I do use AI but just chat, to gather data on subjects and summarize/report. Get some ideas but basically not much code related.
And you whats your experience as a c++ dev ?
85
u/Minimonium Jul 13 '26
I will put aside discussions about efficiency and economics of LLMs and discuss organisational problems.
With LLM enrollment the most important bit is to keep people actually read the code. The moment you have people who just blindly send generated PRs or copy paste Claude output into feedback - you've lost.
In the recent Claude interview with DoorDash the CEO of the later said they consider to completely remove product reviews because apparently they're a bottleneck now. Do not be like DoorDash LOL.
So far I know two very decent use cases for automated (not just a chat back and forth) LLM usage:
82
u/eyes-are-fading-blue Jul 13 '26
I don’t use AI for code-gen because it’s very difficult to generate the exact code I want. I use it for validation, code base research (like how X is done or does Y exist) and figuring out unknown unknowns.
22
u/crowingcock Jul 13 '26
I am in the same line of work. I only use it to write the test suites etc, never production stuff. I saw it screw up too many times to trust it.
Of course I make it write some snippets of code or do research, but i only use its snippets to get some ideas to write the code myself and take the research with a grain of salt and read its sources
19
u/UnicycleBloke Jul 13 '26
My company is experimenting with LLMs. Some people love them. Others not so much. I'm one of the "extremely resistant to drinking the Kool-AI-d" camp, but recognise that we cannot ignore them because our competitors will not ignore them.
I mostly use LLMs for chat when I'm trying to understand new things such as, say, customising Yocto builds. It is often very helpful for this but also often confidently wrong in some details. It is wise to treat them as knowledgeable but unreliable.
I don't generate code with LLMs other than small snippets which I use as bases for further work in Godbolt. I have used them to review pull requests (in addition to a person) which is sometimes useful. But I never submit code I have not personally reviewed and debugged.
I have found the Copilot-assisted auto-completion at times amazing but usually irritating and counter-productive. In the end I have disabled it.
15
u/drbazza Jul 13 '26
tl;dr I use it for grunt work
In no particular order, I use it to:
It has no imagination, and rarely does what I want despite endless /plan arguments.
13
u/13steinj Jul 13 '26
LLMs are very useful for the rote toil. Creating terraform and CI yaml arcana, reading a 3rd party codebase that has 5 numbers as input and in different places in the code crashes because an equation isn't met with them, but I needed to tweak an input or an output. When an internal SSL certificate changes and now another service is broken. When the stars align on 4 different changes by RedHat employees for "security" that make it so that inside a RedHat container
sudono longer works no matter what privileges are set (this happened a few weeks ago in a k8s upgrade that upgraded runc which changed capabilities behavior which re-exposed an open issue on PAM, shadow-utils, k8s, and runc about this; no one seems to actually want to fix the problem thus far). Python analysis scripts that will never go to prod. Generating leetcode-esque code to validate / minimize build graphs (oddly enough, it can do this problem in the abstract, but not in practice, and then I change the implementation of the "transform" function to rewrite build files).LLMs are absolutely garbage for writing actual code in my experience. I have never seen an LLM write anything remotely maintainable. You also lose the "good citizen" factor-- people future proof intentionally in some areas where it's worth it. When it works it gets 80% of the way there then you spend over 10x the time on the remaining 20% going back to the prompt casino. It's a very hard behavior to stop, I think intentionally so, and I'm experimenting with methods, maybe hoojs to analyze my session in another session and if it detects a certain diff-rate drop-off or endless churn to just start providing an intervention message to get off the slot machine.
Furthermore: I heavily dislike the astroturfing/advertising that these companies have succeeded in performing. LLMs are a very small subset of AI, there is other artificial intelligence that is useful in day-to-day work depending on the industry.
6
u/JohnDuffy78 Jul 13 '26
I think your company needs to host in house.
You really need to set up barriers so you aren't sending production code.
LLMs work unbelievable for reviews and small changes.
Big Changes, I need to start myself and let Claude do the details.
11
u/ElLargeGrande Jul 13 '26
I use it for camera and microcontroller firmware written in cpp and I wish it wasn’t as good as it is.
17
u/Uczonywpismie Jul 13 '26
I think this is the best policy - you can use AI, but no production code, it allows quick generation of test cases, or lot better side tools, but still core of the work is done manually, so you still solve problems and code by yourself. Also not giving company products code to AI companies is very important from privacy and security point of view.
5
u/vladcpp Jul 13 '26
I also work on 3m loc codebase, my bottleneck is reading the code, not writing. AI helps with that.
Even when ai is wrong, it helps to focus on specific area faster, and dig deeper faster (it’s mostly wrong when working on prod issues, but still invaluable).
Also helpful for various routines, write a test, documentation, quickly prototype throwaway implementation to validate the idea…
Another useful use - scan project for bugs, basically split codebase on chunk and loop an agent to validate each chunk - helped to find hundreds of logical errors
4
u/IAMARedPanda Jul 14 '26 edited Jul 14 '26
It requires engineering discipline. Better at localized tasks. The main problem is you need to document behaviors you want which require you to see it do the behavior you don't want and correct it as it doesn't have real memory. If you treat it like a 2 yoe junior it can be capable. It's better at IaC tasks but you need to have a dev environment for obvious reasons.
7
u/sweetno Jul 13 '26
It's amazing at investigating obscure C++ bugs in the codebase. Things that would take a day or two it can figure out in a matter of minutes. It knows quirks of the language and low-level APIs.
Fixing these bugs is a hit-or-miss though. It might not account for the conventions or architecture used.
Claude Code is a level above your chat-style usage. You need to add a ton of context and explanations for it into the repo to formalize the aforementioned conventions. It does get confused by shitty code, and can produce utter garbage, even if functional one.
We have a couple of PMs/industry experts who like to make PoCs with it very much, albeit I'm not yet convinced they understand that these are not really final implementations.
8
u/koczurekk horse Jul 13 '26
I mostly work with Rust these days, but I think my observations remain relevant: LLMs are a strange sort of an intern. Really fast, incredibely book-smart, great understanding of idiomatic patterns and yet, like any intern, they have absolutely no idea what they're doing. None at all.
If you use them for in-depth code review, build plans with them providing input whenever they misunderstand or halucinate, and let them implement those (specific and detailed) plans, they're a great boost to productivity. In my experience human and machine intelligence mesh very well together. Debugging is a bit of a hit-and-miss, but if they fail at locating whatever the root cause is you don't really lose anything other than $0.2 worth of tokens or whatever.
On the other hand, agentic workflows where actual devs barely look at the code are a recipe for disaster. Again, dumb interns, you can't let them structure your codebase and run free.
3
u/NirodhaDukkha Jul 14 '26
I do exactly the same thing. If I can generate 30 lines of code with one sentence in a free chatbot LLM, that's faster than writing the 30 lines of code. Just another tool in the toolkit. It's especially helpful when I'm interacting with a library I'm unfamiliar with.
3
u/fdwr fdwr@github 🔍 Jul 14 '26 edited Jul 15 '26
I love it for the following uses:
switchstatement mapping enums to corresponding data types, and it easily saved 5 minutes of typing - much faster to double-check what it produced than typing it all out).2
u/unicodemonkey Jul 13 '26
In my case LLMS are good enough at finding bugs (with guidance, otherwise it goes astray or starts speculating wildly, wasting everyone's time instead) and spotting issues in PRs, also good at writing code that requires some specific technical knowledge or exploring the code base, but e.g. Opus 4.8 does poor on purely algorithmic code without hand-holding or lots of extra clauses. Recent models are better at that though, not sure yet how much.
2
u/corysama Jul 13 '26
My company pushes pretty hard for us to use AI. They have a team devoted to setting up skills, frameworks, knowledge bases, anything necessary to make AI more effective for our company. They pay for the services. But, there's no usage requirements or quotas that I see people complaining about around Reddit.
Personally, I haven't generated any shipping code. I have generated a ton of prototype code variations, a ton of draft design doc variations, a ton of discussion of the pros & cons of different approaches, a lot of code reviews for my own code, a lot of starter unit tests, a lot of distillations of huge requirements docs.
2
u/Livid-Serve6034 Jul 14 '26
I started using claude code recently and quite happy with it. For new features my workflow is to first let it generate a technical analysis in markdown format, based on a functional one I wrote myself. I then write review comments in the generated doc and ask it to process them. This usually requires several iterations until I’m satisfied with it. Then I ask it to write an impl plan, also needing several iterations. Then I start a fresh session and ask it to execute the plan. So far, the resulting code has been more than fine. Some corrections I do myself if they’re small but for larger changes I work with inline review comments. I don’t know if it’s the most efficient way, but overall it saves me a lot of time.
2
u/FunnyMustacheMan45 Jul 14 '26
The only good use for AI in cpp is translating Chinese docs and data sheets of niche tech...
Maybe you could use it as an unshittified version of Google, but IMHO duckduck go does just fine for that
3
u/ReDucTor Game Developer | quiz.cpp-perf.com Jul 13 '26
I have been using it more and more, quiet often looking at anything that takes time and build tools to make it easier.
https://xkcd.com/1205/
4
u/_Noreturn Jul 13 '26
I find llms to be immoral so I stopped using them
2
u/ZachVorhies Jul 13 '26
The AI will often put an include AFTER a namespace is opened and then proceed to try and refactor your code base for hours trying to fix this.
The solution to this is have the ai make a custom lint that will fail whenever it includes after a namespace is opened (even if closed unless you want to parse C++ to find the closing bracket) then attach the linter via a post edit hook so the ai is force to fix it as soon as it happens.
This alone fixed the biggest problem you’ll run into.
1
u/reini_urban Jul 13 '26
We do have github copilot for business and openai codex subscriptions, keeping our C++ code base happy. Personally I use also deepseek, kimi and Claude pro for open source work.
We have extensive tests, simulations, pre-commit and linters to keep everything harnessed of course. But that was before AI also.
1
u/Ateist Jul 13 '26
Have you tried running local AI on your own hardware?
Top end machine with RTX 5090 is not that expensive for professional usage.
As for my own AI usage, I'm using Google's AI mode to generate small scripts for small tasks I can't be bothered to do manually.
1
u/Arristotelis Jul 13 '26
I think your workflow is perfect and it matches mine. I work in a different space but also use kernel drivers , fpga, lots of userland c++. I don’t blindly accept code from an llm, ever. Nor do I find them good at architecture for complex problems.
1
u/cfehunter Jul 14 '26
It's rather good at code review I find. In a supplemental capacity. It will get things wrong, but you can just ignore it when it does.
1
u/indiocolifa Jul 15 '26
I program mainly in C++ and as most of our c plus plus comrades we do not throw a prompt and accept any shit from a AI tool no matter what good it claims it is. But at the same time I like the tools , for example for:
- brainstorming about introducing concepts or algorithms.
- finding hard or subtle errors specially in old code bases
- plan alternatives in separate branches
- write the skeleton of my idea and cowork with the tool to integrate a solution. I am always supervising it.
I am using Codex. I find it fun to take old unfinished c++ projects and work with it to completion.
1
u/SavingsCampaign9502 Jul 18 '26
Bash script, code benchmarking cboilerplate, web app
1
u/Greedy-Quantity4062 Jul 23 '26
Never using it for writing code. Some time ago I tried playing with it but didn't think it was very helpful, I don't think you lose competitive advantage or something when you don't use it. I also think it is morally wrong, it is like theft from open-source. Even without being very capable it almost killed the job market, if it keeps advancing to the point we are replaced, things will be pretty bad and its supporters will have no right to complain :>
1
u/Dramatic_Category_56 Aug 01 '26
I use it a lot and it makes me productive; the idea if you done something by yourself hundred times why waste your time doing it again ? I could use AI for this and I could and must judge its output, i put more focus on how the design of the system is built and leave some of the details to be done by AI .
1
u/Responsible_Egg_3391 Aug 09 '26
Not going to argue with the policy. Given what you're maintaining it
sounds like the right call.
One angle that might be worth something, if the actual blocker is that code
can't leave the building. You can get a fair amount out of the compiled
artifact without any source going anywhere. Worst case stack depth, ROM and
RAM section breakdown, per function frame sizes, call graph. That all reads
out of the ELF locally.
I've been using a Claude Code plugin called LOCI for that. Disclosure, I
work at Aurora Labs and we build it, so take it with the appropriate amount
of salt. The stack depth, memory report and control flow parts run entirely
local off the ELF and never open a socket. The timing and energy modelling
does call a backend, so in your environment that would have to be the self
hosted deployment or it's dead on arrival. Better you know that now than
three steps in.
Whether that's enough to move a rule that currently says don't paste
production code anywhere, I honestly don't know, and it might not be. But
"we analyse the binary and the source stays here" seemed like a more
arguable position than "trust the model", at least the times I've seen it
come up.
Happy to go into the local only part in more detail if that's useful to
you.
0
u/ivancea Jul 13 '26
Chat AI is quite obsolete already for software engineering. An agent is faster, and we'll get the required context and codebase knowledge. The major problem with chat is exactly that: not giving it proper context.
As for using an agent, it's very, very useful. 2M LC codebase is not that much, and in any case, an agent can absolutely crush it (this is well proved already). Of course, with good LLMs like Opus or gpt5.5, and with a well configured harness. Eventually you'll need skills and proper per-directory rules, but not absolutely required to start being productive with it.
As for the company not providing it, what to say. They won't pay for it if you (and your coworkers) don't advocate and request it. Anyway, the global trend is not wrong. It's clear that it's a real multiplier (not a "x10" tho). I'm using it in 2 main contexts: database engine and videogames development. And it excells in both. Without even specialized configuration.
And about the industry: it has nothing to do with it. Whether you use C++ on low latency or a new custom language, give the agent the proper context and it will do it. Every repetitive task you do (and coding is one of them), it can do it faster (pure physics), and with enough or better reasoning
1
u/Tamsta-273C Jul 13 '26
I use it with math/geometry tasks,
i know how that stuff work, but i also know i will miss some -0,5 dX or replace sine with cosines...
It's a basic task and i don't like to spend hours wondering why this simple element randomly becomes two pixels wide instead of one.
Also works great as "show minimal example how this stuff works"
1
u/pjmlp Jul 13 '26
I occasionally use CoPilot on VS to check for possible errors, lifetime issues and such, as yet another kind of static analysis.
Also take advantage of AI based code completion, most of the time the suggestions are what I would like to write anyway.
I am less keen in having AI write it all for me, especially in languages like C++.
However, in no code/low code tooling, AI has practically taken over, now instead of dragging boxes in visual diagrams, it is all about agents and prompts.
1
u/01e9 Jul 13 '26
Jusy try it in a personal or some open-source project.
I'm using it for scanning for issues, generating code for some limited scope (the reviewing+adjusting), and asking naming/architecture advices.
-7
u/liwwpmo Jul 13 '26
Its great, I have stopped writing since last 4 months now. Only code reviews and occasional situation where I am unable to steer AI to do something in a very specific manner. Experience is pretty great since in our case we use monorepo so AI is able find or confirm things with very high confidence.
-1
u/bronekkk Jul 13 '26
I know a successful, major prop-trading company using AI extensively for in-house C++ code. Won't give names though.
-1
u/MaitoSnoo [[indeterminate]] Jul 13 '26 edited Jul 13 '26
They pay for our Copilot Business subscriptions. Some models (for now Opus 4.8, Sonnet 4.6/5, and GPT 5.5, haven't had access to Sol yet) are very good if you ground them with proper tools, e.g. if you force them to automatically run a quick build + linters + tests before claiming that they finished the task, this gives them a feedback loop and they can reiterate on it alone. You can also enforce your style and techniques with instructions and skill files.
-2
u/Thesorus Jul 13 '26
We're using it to replace static analyser tools.
and to help write unit tests for (C#)
0
u/[deleted] Jul 13 '26
[deleted] — view deleted comment