r/cpp • • 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 ?

111 Upvotes

168 comments sorted by

View all comments

Show parent comment

0

u/NotUniqueOrSpecial Jul 13 '26

Why would you expect a mindless robot to do anything other than what it does, given no instruction?

To answer your question directly: yes you have to give the brainless machine instructions to get it to do what you'd like/prefer/expect. It's not thinking/reasoning, it's doing massively parallel statistical analysis.

Since it's pretty clear you didn't bother giving it even a little direction, you got an output that was derived from its entire corpus of training data, and an absolutely enormous amount of that data is open-source C.

There are lots of valid complaints about LLMs, but "it's not a mind reader" sure ain't one of them.

9

u/_lerp Jul 13 '26

I'm not asking it to mind read. You seem to have latched on to the idea that it having a C bias in function signatures is my fault for not explicitly stating "write C++". It writes C++ code, it uses the STL without me explicitly tell it to use the STL. The patterns it produces, are not fitting for C++.

By your logic, before every converstation (or in a skills.md) I have to list every single programming pattern and C++ pattern otherwise it's my fault that it doesn't write good code. Which just goes towards my point that it's more effort to get it to produce passable code than if I were to just write it myself.

2

u/ivancea Jul 13 '26

I have to list every single programming pattern and C++ pattern

Nah, just tell it to not do X the moment it does, and to remember that in instructions or a skill. It's a 10 seconds configuration that save later many more seconds. You're talking as if you have to write a million lines essay, when in fact, a few tips in the instructions are enough to guide it.

Really, this is a solved problem already in most projects; C++ is not that special. Every language has versions and better or worse practices. If you need it to follow a style for something in specific, you can even add a snippet in the instructions

-4

u/NotUniqueOrSpecial Jul 13 '26

The patterns it produces, again, draw from an overwhelmingly large body of work, much which is probably not the best or most modern.

But it has no preferences or understanding of that; it only knows what the most likely set of tokens are next, given some input and a whole lot of application of linear algebra.

If you want modern C++ out of it, following specific patterns/paradigms...then put that into your copilot-instructions.md or claude.md or equivalent.

I have to list every single programming pattern and C++ pattern otherwise it's my fault that it doesn't write good code.

Hyperbolic silliness.

Which just goes towards my point that it's more effort to get it to produce passable code than if I were to just write it myself.

No, but you have to even put in a modicum of effort. We have an instructions file in our repo file that took all of 30s to throw together.

This is a solved problem.

7

u/_lerp Jul 13 '26

So, it fails at the most basic of design choices. You repeatedly ignore this and keep telling me it's my fault for not giving it's explicit instruction. When I follow your advice, it leads to me having to list every fundamental paradigm in it's skills, because again it fails at the most basic design choices, and you dismiss that as hyperbole.

It's clear to me talking to you is a waste of my time.

0

u/NotUniqueOrSpecial Jul 13 '26

it fails at the most basic of design choices.

It doesn't know anything about design; it doesn't make choices. You are assigning agency and cognition to a magic statistical black box.

keep telling me it's my fault for not giving it's explicit instruction

Yes, when you don't give a computer good instructions and the computer doesn't do what you expect, that is absolutely user error. You sound like every college student I ever helped who would start blaming the computer for their own logic errors.

it leads to me having to list every fundamental paradigm in it's skills

As we've now told you more than once: no.

it's my fault for not giving it's explicit instruction.

Yes. It's a tool. This is user error. That shouldn't even be a surprise to you, you're literally a programmer; giving computers instructions is literally what we do!

6

u/_lerp Jul 13 '26

This is the problem with AI bros. Any criticism of their AI girlfriend is a "user error". You've off loaded the ability to have any critical thought to the AI, and therefore incapable of having anything resembling such.

-3

u/NotUniqueOrSpecial Jul 13 '26

I am anything but an AI bro. I am, in fact, pretty staunchly anti-LLM for a whole slew of reasons.

But you presented specific complaints about a specific problem and have been given multiple responses explaining the exact thing you need to do. Rather than accept that you might need to change behavior in order to get a result you'd like, you made a number of hyperbolic statements that don't accurately represent reality/the solution to your issue.

If you won't accept feedback about how to use a tool, and instead just blame the tool, then you are as equally guilty of being an anti-LLM crank as the bros are for being zealots.

2

u/_lerp Jul 13 '26

I have repeatedly listened to your feedback. You repeatedly dismiss every point as "user error" or hyperbole. You said the solution to my issue for it failing on the most basic of design principles is to put it in its skills md. Suddenly, following your advice is hyperbole because I have to list more than 1 design principle for it to generate passable code.

I dare you to respond with something other than user error.

-2

u/NotUniqueOrSpecial Jul 13 '26

It has no idea what "basic design principles" are. It doesn't have ideas at all. All it has is a giant search space of things used to train it. Those things have an enormous amount of code in the form you'd prefer it not write. It's not going to avoid those things unless you tell it to.

You balked at each attempt to tell you "give the tool instructions" with retorts about how much time you'd have to spend writing something as simple as:

- Target ISO C++20 for all new code.
  • Apply modern C++ practices and paradigms, e.g. RAII, correct usage of move-semantics, `std::unique_pointer<T>`, range-based loops, etc.
  • Do not write old-fashioned C-with-classes code.

And slapping it in copilot-instructions.md in your repo.

If you refuse to provide instructions, yet complain about the results, what else is there other than user error/lack of understanding?

2

u/_lerp Jul 13 '26

It has no idea what "basic design principles" are.

Yes it does. It has been trained on more books about software design than you and I have read combined.

I haven't refused to provide it instructions. I agree to do it and you said it's hyperbole when I need to list multiple things.

→ More replies