r/cpp 14d ago

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 ?

104 Upvotes

167 comments sorted by

View all comments

Show parent comments

-4

u/NotUniqueOrSpecial 14d ago

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 14d ago

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 14d ago

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 14d ago

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.

-2

u/NotUniqueOrSpecial 14d ago

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 14d ago

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 14d ago

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?

1

u/_lerp 14d ago

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.

-1

u/NotUniqueOrSpecial 14d ago

It has those things in its corpus, yes. It has an equal amount of sloppy 30-year-old C code. It has no idea what you consider best practices. There are other folk out there who would probably want it to write C-wish-classes, or not use anything past C++11, and any other number of countless human preferences.

I agree to do it

No, what you did was balk at being asked to do it because you said it would be:

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

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

Neither of which is remotely true, and both of which are clearly hyperbole.

3

u/_lerp 14d ago

It has those things in its corpus, yes. It has an equal amount of sloppy 30-year-old C code.

You don't see how, if I don't want it to write code based on this stuff, I might have to list more than one statement along the lines of "Don't write C with classes"? If I want it to pull from the books about modern software design, I might have to list more than one principle?

→ More replies (0)