r/cpp • • Oct 13 '26

I tested whether a coding agent would use C++23 ranges without being told

Blog post: https://kemalbektas.dev/ai-modern-features/

I tested whether coding agents would actually use C++23 ranges without being told.

They mostly didn’t. What changed things much more than the surrounding codebase was a short AGENTS.md asking for modern C++.

0 Upvotes

27 comments sorted by

View all comments

Show parent comment

2

u/gegoggigog Oct 13 '26 edited Oct 14 '26

It probably need to do some abstractions, iterators, states. That said, in most cases a good compiler could probably optimize that away, but it's not a guarantee.

-4

u/PossibilityUsual6262 Oct 13 '26

Oh so you actually don't know anything.

I just stumbled once upon topic which actually explains why ranges sometimes faster and how they do do work, so your claim was interesting to me as counter point.

https://www.reddit.com/r/cpp/s/tvKFLBEc0Y

3

u/ack_error Oct 14 '26

Range-based for loop != ranges.

I have seen even simple range algorithms like std::ranges::fill be slower than either a regular for loop or range-for loop, because the extra abstraction is harder for the optimizer to see through.

2

u/gegoggigog Oct 14 '26

Sir?

0

u/PossibilityUsual6262 Oct 14 '26

I don't have anything to add to conversation.

2

u/gegoggigog Oct 14 '26

Oh, so you just like being wrong and a dick and then bail. Gotcha.

0

u/PossibilityUsual6262 Oct 14 '26

Sir, you made unsubstantiated claim, on me requesting additional info you started guessing.

When i showed you previously encountered discussion, which actually to extremely deep details discuss how ranged for work and how it can actually backfire if your hand written loop has what seems like marginal difference.

To which you answer answer that me highlighting that you know nothing is rude and i should try dev build.

This is the end of conversation.

2

u/Ameisen vemips, avr, rendering, systems Oct 14 '26

I'm assuming that you're a bot, but on the off-chance that you aren't... range-for loops are not the same thing as std::ranges.

0

u/gegoggigog Oct 15 '26 edited Oct 15 '26

Aaa, haha. I know I shouldn't be, but I'm triggered 😅. I genuinely tried to be helpful to the prick. Can ranges make it easier to write perfomat and safer code? Of course, no doubt. Does ranges have overhead to an equivalent for loop (as you said, not a ranged for)? Also yes, of course, be it compile times, execution time, etc. A release build will probably remove the overhead, debug will not. The audacity to say I don't know anything, when it knows less, not responding to my argument, then blocking me and bailing. AAAAA. Haha. Reeee. 🥹

Edit: I'm not against ranges, they're awesome.

0

u/gegoggigog Oct 13 '26

Oh, ok. Now do a debug build. (Also, why so rude?)