C++ Logo

std-discussion

Advanced search

Re: Distinguishing AI Codegen Comments from Programmer Notes: A Proposal for Cleaner Codebases

From: Andrew Schepler <aschepler_at_[hidden]>
Date: Wed, 9 Oct 2024 22:22:49 -0400
These aims are good ones: to distinguish between the comment purposes and
to do so in a consistent way for different tools. But I don't think the C++
Standard is the place to do that. Nothing about this means a change to the
C++ language or libraries, changes whether programs are well-formed or
ill-formed, or changes what the executed program must do. And nothing about
C++ stops current tools from recognizing that sort of distinction and
encouraging its use.

Doxygen is a relevant example here. It's a tool that converts in-code
comments to documentation in HTML and other formats, and it only processes
comments that begin with "/**" or "/*!" or "///" or "//!". That feature
fits in the overall C++ language definition as is. I'm a little surprised
that GitHub Copilot doesn't have a configuration of this sort, as far as
I can tell. But its use case isn't exactly parallel.

So instead I recommend making this a feature request for the code
generation tool(s) you use. And probably different tools should use
different markers or methods anyway, unless one is intentionally attempting
to be mostly compatible with another. (Would it be good to have some
process of claiming and assigning code prefix markers like Doxygen's and
this proposed "//$$"? I doubt it's worth it at this time, and again
the Standard's involvement would be either none at all or essentially just
"implementation-defined string with implementation-defined meaning goes
here".)

Cheers,
Andrew Schepler


On Wed, Oct 9, 2024 at 8:48 PM d3fault via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> GitHub Copilot and similar AI code assistance tools are becoming
> increasingly popular for good reasons. However, the way they require the
> use of basic comments to generate code is problematic. This practice
> overloads the traditional role of comments, which is undesirable.
> Well-placed comments are invaluable for helping programmers understand
> specific parts of code, but with AI overloading comments, it may become
> difficult to distinguish between useful comments and simplistic ones
> intended purely for AI.
>
> Perhaps C++ should introduce a way to differentiate between comments meant
> for AI code generation and those meant for programmers. For example:
>
> //$$ A function y that accepts an int x
> void y(int x);
>
> ^^This "comment" is trivial, but you may still want to keep it for future
> refactoring purposes.
>
>
> A good IDE could hide or collapse such "source text" used for AI-generated
> code by default, making sure that when comments are visible, they are meant
> to aid programmers rather than serve as prompts for AI. In this example,
> "//$$" is used as a placeholder to mark such comments, though a more
> suitable convention could be adopted.
>
>
> d3fault
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2024-10-10 02:23:06