• ☂️-@lemmy.ml
    link
    fedilink
    arrow-up
    13
    arrow-down
    1
    ·
    edit-2
    11 hours ago

    actually, be exactly like bill. boss wants slop, boss gets slop.

    boss wants incomprehensible buggy code? that’s right, boss gets incomprehensible buggy code.

    • psud@aussie.zone
      link
      fedilink
      English
      arrow-up
      1
      ·
      6 minutes ago

      Sorry, you were hired as a prompt engineer, your prompt wasn’t good enough to make perfect code, so you are fired

  • tiredofsametab@fedia.io
    link
    fedilink
    arrow-up
    3
    ·
    10 hours ago

    I recently got moved to another team after my company restructured. Several repos have zero documentation. Most of those don’t even have comments on the functions. LinkXxxx(some args) like Xxxx to /what?!/ It’s also an over-engineered mess with multiple layers of abstraction. I can’t wait to finish figuring out what everything does and re-write (and document it) like a sane person. This code presumably had no AI involvement which I’d argue is even worse since real humans made these shit decisions. Don’t get me starting on their testing (and mostly lack thereof)…

    Worker suggested using AI to write some documentation. Another coworker did. I immediately spotted a bunch of hallucinated shit. Good times. I want to know in my head what a thing does, how it works, and how it fits into the architecture. I can’t do that if an AI is just deciding stuff; it’s like a quiz back in school where I would memorize shit for about one week before 99% of it left my brain forever.

  • 🌞 Alexander Daychilde 🌞@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    12 hours ago

    Woever made this image should learn the difference between line spacing and paragraph spacing…

    This is an example
    of line spacing which
    clearly shows it’s together

    And now this is a new
    bit that is separate from
    the above bit

    Readability is important.

  • MoonRaven@feddit.nl
    link
    fedilink
    arrow-up
    37
    ·
    19 hours ago

    I’ve seen the comments AI adds and yeah… No… It’s often pointing out the obvious or even in some cases just misleading.

    • Enkrod@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      11 hours ago

      I told my boss I wouldn’t use AI to help write code and sign off on the commits with my name. He told me to use it to write the documentation… it was bad. Essential concepts were not mentioned and obvious shit was explained five times in slightly different phrasing. I am now writing our documentation as an obsidian vault myself again.

      I only have it compile a change log from the commit messages of commits and merges on the main and development branch. I know our commits are well written (because I established the standards for them in our repo myself) and that’s concrete and rigid enough that it can’t fuck it up enough to matter.

      But honestly there are build tools that could do that for me, I don’t need to buy tokens for that.

      • NotAnonymousAtAal@feddit.org
        link
        fedilink
        arrow-up
        11
        ·
        17 hours ago

        Not just beginners unfortunately. One of things I have to almost always teach to new colleagues, even experienced ones, is to put at least some minimal effort into making the code itself readable instead of relying on comments as crutches. Just basic things like picking proper names for variables and functions.

    • Kindness is Punk@lemmy.ca
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      18 hours ago

      Agreed it’s why if I’m asking for llm assistance I will generally start with a design for a component and ask it to follow that and comment accordingly usually leads to much better results than blanket asking it to do something for you

  • Thorry@feddit.org
    link
    fedilink
    arrow-up
    34
    arrow-down
    2
    ·
    edit-2
    21 hours ago

    Asking an LLM to add comments is actually pretty much the worst thing you can do. Comments aren’t meant to be documentation and LLMs have a habit of writing documentation in the comments. Documentation is supposed to be in the documentation, not in the code. LLMs are often trained on things like tutorials, where super obvious statements are commented to allow people to learn and follow along. In actual code you absolutely do not do this, obvious statements should be obvious by themselves. At best it’s extra work to read and maintain the comments for obvious statements, at worst they are incorrect and misleading. I’ve worked on systems where the comments and the code weren’t in line with each other and it was a continual guess if the comment is the way it was supposed to work, or if the code is correct and the comment wrong.

    So when do you actually add comments? That’s actually very hard, something people argue about all the time and a bit of an art form to get right. For example if I have some sort of complex calculation, but it’s based on a well known algorithm, I might comment the name of that algorithm. That way I can recognize it myself right away and someone that doesn’t know it can look it up right away. Another good indicator for comments are magic numbers. It’s often smart to put these in constants, so you can at least name them, but a small little comment to indicate why it’s there and the source can be nice. Or when there is a calculation and there’s a +1 for example in there somewhere, one might ask why the +1, then a little comment is nice to explain why.

    Comments should also serve like a spidey sense for developers. Whenever you are writing comments or have the urge to add some comments somewhere, it might be an indicator the code is messy and needs to be refactored. Comments should be short and to the point, whenever you start writing sentences, either start writing documentation or look at the code why it’s required to explain so much and how to fix that.

    Another good use for comments is to warn away instincts for future devs. For example in a system I worked on there is a large amount of code that seems like it’s duplicate. So a new dev might look at it and see a good place to start refactoring and remove the duplicated code. However the duplication was intentional for performance reasons, so a little comment saying the dupe is intentional is a good idea.

    I’ve also seen comments used to describe function signatures, although most modern languages have official ways of doing that these days. These also might border on documentation, so I’d be careful with that.

    LLMs also have a habit of writing down responses to prompts in the comments. For example the LLM might have written some code, you say: Hey that’s wrong, we shouldn’t set x to y, we should set it to z. And the LLM writes a comment like // X now set to Z as requested. These kinds of comments make no sense to people reading the code in the future.

    Keep in mind comments are there to make it easier for the next guy to work on the code, and often that next guy is you. So getting it right is important and hard, but very much worth while. What I like to do is write code one day and then go back and read it the next day or a few days later. And not the commit, with the diff and the description, the actual files beginning to end. When I think something is weird or stands out, I’ll go back and edit the code and perhaps add comments.

    IMHO LLMs are terrible at writing code, it’s often full of mistakes and oversights, but one of the worst parts is the comments. I can tell code was AI generated right away by the comments and those comments being present are a good indicator the “dev” didn’t bother to actually read and correct the code.

    • jtrek@startrek.website
      link
      fedilink
      arrow-up
      25
      ·
      19 hours ago

      There’s also the class of comments that explain strange business decisions.

      # Product guy said to return January 1st if the user doesn't have a birthday on record

      Kind of arbitrary but someone with decision making power decreed it.

      • baines@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        10
        ·
        edit-2
        16 hours ago

        this is among the most important comment types that exist imo

        it may not seem like it but 20 years and 5million lines later when shit behaves odd because of some non standard code practice this type of comment is a life saver

      • Skullgrid@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        19 hours ago

        Kind of arbitrary but someone with decision making power decreed it.

        Here, under protest is this code. Every time the user doesn’t have a birthday, we return January 1st. Do we really mean that?

    • Dumhuvud@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      10 hours ago

      Comments aren’t meant to be documentation

      Documentation is supposed to be in the documentation, not in the code.

      Some tooling generates documentation from comments. Like rustdoc or LDoc.

      I’ll be honest, I mostly skimmed through your comment. Sorry if it’s something you touch upon later on.

    • NotAnonymousAtAal@feddit.org
      link
      fedilink
      arrow-up
      5
      ·
      17 hours ago

      Excellent comment and I fully agree with almost everything. Just one tiny nitpick:

      For example if I have some sort of complex calculation, but it’s based on a well known algorithm, I might comment the name of that algorithm.

      Unless you really need this complex calculation to be inline (e.g. for performance reasons) it would be better to move it into a function or method and include the algorithm in the name instead of adding a comment.

      • Thorry@feddit.org
        link
        fedilink
        arrow-up
        2
        ·
        15 hours ago

        Very good! Your spidey senses are working perfectly. Hey I want to comment this calculation, why don’t I move it into a function so the name can explain what it does. Good call!

        Sometimes the algorithm is inlined for performance, sometimes it’s a class with a bunch of functions that as a whole is primarily based on an algorithm, so comments might make sense in those cases. Most of the times it’s a library, so the name of the library kinda gives it away and hopefully has good documentation as well.

      • baines@lemmy.cafe
        link
        fedilink
        English
        arrow-up
        2
        ·
        16 hours ago

        i want it in a function

        fully include the pre implementation long hand in comments and the book / expert reference

        the number of times i’ve found longer algos not doing as advertised is scary

        improperly used statistical algos given the data sets and hand waving results are so common

        gee i wonder why testing shows no improvement

    • stingpie@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      15 hours ago

      I disagree that comments are an indication of messy code. The purpose of comments are to 1) translate low level concepts into higher ones for improved readability and 2) to maintain information in the design process that can’t be represented by the code itself.

      Obviously I don’t have to comment mathematical operations, but it makes sense to comment the algebra of how I derived an equation and it’s use in the code. Now, I could refactor that section of code into a function in order to give it a name, but that would make it more difficult to read as the programmer would then have to find the definition of that function somewhere else in the file. It is objectively more spaghetti-like to pull out single-use code into a function rather than just label the block of code with a comment.

  • slazer2au@lemmy.world
    link
    fedilink
    English
    arrow-up
    23
    ·
    21 hours ago

    Bill doesn’t understand liability clauses in contracts when he sells his vibe coded shit as a SaaS platform and gets popped because AI forgot about SQL injection.

  • ikidd@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    2
    ·
    15 hours ago

    The code is the comment anyway. The only thing you should comment is things that are way the hell out in left field about why that bit of code exists when it shouldn’t.

  • kibiz0r@midwest.social
    link
    fedilink
    English
    arrow-up
    19
    ·
    21 hours ago

    “Did you just have Claude ship all this code?”

    “Yep”

    “You shouldn’t ship code you don’t understand…”

    “Good point. Claude, go understand this code for me!”

    • sekki@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      21 hours ago

      If Claude understand code, Claude ship code just fine. If Claude understand but you don’t, you no ship code, let Claude do!

    • CluckN@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      15 hours ago

      Got pulled into a meeting where a web dev contractor we hired stated, “I can’t promise these changes, it depends on how we can get CoPilot to do them”. I don’t think my bosses care because they want their bosses to know that they are, “working with AI”.

  • jaybone@lemmy.zip
    link
    fedilink
    English
    arrow-up
    16
    ·
    21 hours ago

    A lot of big companies are basically forcing you to be Bill. They try to track AI usage, and make sure everyone is using it. Because they invested so much in AI, they need to force it, to make it a self fulfilling prophecy. It’s truly one of the dumbest things to behold.

    • sobchak@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      4 hours ago

      If the company also trains AI, I’m guessing they’re also forcing use to gather training data. I.e. tracking feedback, corrections, etc.

    • kindnesskills@literature.cafe
      link
      fedilink
      arrow-up
      5
      ·
      19 hours ago

      Nightmarish. Can you make the AI write up new documentation every time you want to push a change, so it looks like you’re using it frequently but you still get to write the code yourself?

      I would love letting LLM deal with documentation. It’s the bane of my existence.

      • Enkrod@feddit.org
        link
        fedilink
        arrow-up
        1
        ·
        11 hours ago

        Tried that, result was shitty documentation and as someone who reads other peoples documentation for a living I will NOT subject other people or my future self to that.

  • chicken@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    11 hours ago

    I hate most of the companies paying people to write code though, isn’t it a good thing if their code is shit that no one can understand and doomed to collapse under its own weight?

  • 7U5K3N@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    17
    arrow-down
    6
    ·
    22 hours ago

    Well… Heck. I recently vibe coded an app for a specificish use case. I didn’t even think about commenting my code. It was the first time I’ve ever done such a thing…

    I’ll go and comment it all.

    Thanks for the reminder OP