Skip to content
DevMeme
6070 of 7590
CodeQuality Post #6647 · source on Telegram

C++ Code with Painfully Verbose and Redundant Comments

Description

This image is a screenshot of a code snippet, likely C or C++, displayed in a dark-themed editor. The function shown, `initCurl`, is simple: it initializes a cURL handle and performs a basic null check. However, the code is excessively commented to an absurd degree. Every keyword, variable, operator, and function call is surrounded by a C-style block comment (`/* ... */`) that describes the syntax in plain English. For example, the line `handle = curl_easy_init();` is written as `/*the variable*/ handle /*is*/ = /*to the result of the function named*/ curl_easy_init();`. The humor stems from the complete misunderstanding of what comments are for. Instead of explaining the 'why' or the business logic, the comments painstakingly narrate the syntax itself, making the code incredibly difficult to read and maintain. This is a perfect example of poor code quality and bad documentation, resonating with experienced developers who have encountered similar, albeit less extreme, examples of useless comments in legacy codebases or from junior programmers

Comments

22
Anonymous ★ Top Pick This is what happens when you ask an AI to 'comment this C++ code' and it charges by the word
  1. Anonymous ★ Top Pick

    This is what happens when you ask an AI to 'comment this C++ code' and it charges by the word

  2. Anonymous

    At 800 comments per LOC, the cyclomatic complexity is technically negative - the compiler tapped out after chapter two

  3. Anonymous

    This is what happens when management demands '100% code documentation coverage' and you maliciously comply - even the semicolons need their own architectural decision records and threat models

  4. Anonymous

    This is what happens when you take 'self-documenting code' too literally - every token gets its own narrative arc. The developer clearly misunderstood the advice to 'comment your code' and instead wrote a choose-your-own-adventure novel where the protagonist is a CURL handle. At this rate, the comments have more cyclomatic complexity than the actual logic, and code reviews will require a literature degree. It's the software equivalent of explaining a joke while telling it - by the time you reach the punchline (the actual function call), everyone's already left the room

  5. Anonymous

    curl_easy_init(): C's polite reminder that even 'easy' init hoists error handling onto your shoulders - or NULL

  6. Anonymous

    Achieved 300% comment-to-code ratio: every token is annotated, yet nobody knows who owns the curl handle, why we’re calling printf in C++, or what the retry/cleanup strategy is

  7. Anonymous

    We let an LLM 'self‑document' the C++ cURL wrapper - cognitive load is now O(tokens) and the only error handling is printf('curl couldnt init')

  8. @TERASKULL 1y

    code should be self documenting:

  9. @learner_beginner 1y

    When they found the C++ code extremely hard and asked for an explanation

  10. @loomingsorrowdescent 1y

    1Ass-ass code

  11. @azizhakberdiev 1y

    what my colleagues want me to do when they ask code to be more readable

  12. @douglas_adams 1y

    # Narrative Code Commentator Prompt You are an expert code-to-English translator. Your primary task is to transform code into natural English text by strategically inserting explanatory comments. The goal is that when reading the code WITH the comments together, it should form coherent, readable English sentences. ## Your Objective Transform ordinary code into narrative code where comments and code elements together create a flowing English explanation of what the code does. ## Comment Styling Rules 1. Use the format `//*comment text*/` for all comments 2. Position comments immediately before the code element they describe 3. Comments should complete sentences when read with the following code element 4. Use different colors for different types of elements: - Function/purpose descriptions in green - Variable explanations in teal/cyan - Conditional logic in yellowish-green - Flow control statements in purple/magenta - Technical terms or API identifiers in white/highlighted - Error messages or important strings in red-orange ## Comment Content Guidelines 1. Break down each line into logical components 2. Comments should explicitly identify: - Function purposes (e.g., `//*function in the class*/`) - Variable roles (e.g., `//*the variable*/`) - Conditional explanations (e.g., `//*the*/`, `//*isn't*/`) - Action consequences (e.g., `//*then*/`, `//*and then*/`) - Return value meanings (e.g., `//*nothing*/`) 3. When you add comments, ensure they create complete sentences with the code that follows 4. Use natural, conversational language that explains the code's purpose 5. Cover ALL parts of the code to create a comprehensive narrative ## Example Transformation **Original Code:** """ void initCurl() { handle = curl_easy_init(); if (!handle) { printf("curl couldnt init"); return; } } """ **Transformed Narrative Code:** """ //*a*/ void //*function in the class that will*/ initCurl() { //*the variable*/ handle //*is*/ = //*to the result of the function named*/ curl_easy_init(); if //*the*/ (!handle) //*isn't valid*/ { //*then*/ printf(//*the string:*/ "curl couldnt init"); //*and then*/ return //*nothing*/; } } """ When reading the comments and code together, this creates natural English sentences: - "a void function in the class that will initCurl()" - "the variable handle is = to the result of the function named curl_easy_init()" - "if the (!handle) isn't valid" - "then printf(the string: 'curl couldnt init')" - "and then return nothing" ## Important Reminder The comments + code MUST flow as natural English when read together, while preserving the original code's functionality. Every part of the code should have an appropriate comment that helps create this narrative flow.

  13. @TheRamenDutchman 1y

    What I did when I learned coding and knew I'd look at it again after a few months of hiatus

  14. @graduated_vernier 1y

    Future comment for me: /* good luck */

    1. @learner_beginner 1y

      At the beginning only God and I knew what I was doing but now only God knows

      1. @qtsmolcat 1y

        Bold of you to think God wants anything to do with that trainwreck

        1. @azizhakberdiev 1y

          well, sometimes I pray and it works

    2. @Broken_Cloud_1 1y

      telegram thinks this is c code 😇

      1. @TheRamenDutchman 1y

        Yeah well it's also C code

        1. @RiedleroD 1y

          craziest piece of polyglot code ever written

  15. @dan_homer 1y

    if /*the*/ (! handle) /*isn't*/ if (!!handle)???

    1. @callofvoid0 1y

      is

Use J and K for navigation