• gingersight@programming.dev
    link
    fedilink
    English
    arrow-up
    9
    ·
    3 hours ago

    Oh, it’s only the files that have over 2k lines of code? Hell, I’ll take that over what I’m dealing with now. I’ve got multiple FUNCTIONS that are over 2k lines. >:(

    • ripcord@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      3 hours ago

      Yeah, I dont see a big problem with files over 2000 lines in some cases, as long as things remain well writrej, organized, abstractd.

      One piece of garbage that I’ll never touch again hae most functions this size. One was 50,000 lines! Hundreds.of lines of if/else, half of the functions passed the same 60 arguments because he didn’t understand classes or even dictionaries, etc etc. And was used heavily.

  • HugeNerd@lemmy.ca
    link
    fedilink
    arrow-up
    6
    arrow-down
    1
    ·
    3 hours ago

    That’s what agentic AI is for! Your OS will figure out by itself what you are doing and weave together a shambolic rococo digital house of cards that will be not just undocumented but utterly incomprehensible.

    It’s fine, just get a 5GHz CPU with 48 cores, 1TB of DDR5 HBM super RAM, and maybe a few petabytes of storage (in the cloud in a flatpack Docker that runs on a VM), so that you can finally make that button blue.

      • HugeNerd@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        1 hour ago

        Fucken right, get your agentic AI to get in touch with my agentic AI (with wire transfer deets)

  • catnip@lemmy.zip
    link
    fedilink
    arrow-up
    3
    ·
    3 hours ago

    Those are rookie numbers. We got functions with 5000+ lines and 20 levels of indentation directly in the user-interaction event handlers :)

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      3 hours ago

      Well, that’s how you do it!

      And if two widgets need to create the same effect, you just copy the 5000 lines around. That’s why copy-and-paste was invented.

      (It really shouldn’t be necessary… but in case somebody still needs it, here’s the \s)

  • explodicle@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    9
    ·
    4 hours ago

    I’ve been doing this for years at my current job. It has become a masterpiece of refactoring and comments. They weren’t even asking the right questions. I’m very proud of myself.

    So naturally, I’m about to get fired and have the whole thing redone by AI.

  • ChickenLadyLovesLife@lemmy.world
    link
    fedilink
    English
    arrow-up
    13
    ·
    5 hours ago

    There are no comments in the code

    At my last job, I was assigned to a project being run by a straight-out-of-college developer who felt that not only were comments unnecessary, they were actually a “code smell”, a sign of professional incompetence on the part of whoever added them. It’s an insane philosophy that could only appeal to people who have never had to take over an old codebase.

    • CodeBlooded@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      2 hours ago

      Or, it appeals to people that have had had to take over an old codebase where the comments were all lies.

      “Code never lies. Comments sometimes do.”

    • ipkpjersi@lemmy.ml
      link
      fedilink
      arrow-up
      7
      ·
      5 hours ago

      I kind of get the idea that code should be self-documenting, but at the same time, there’s so many crazy business rules that comments are basically a necessity if nothing else other than to explain why in the hell the crazed mess that provides the required functionality for the business rules exists.

      • jjjalljs@ttrpg.network
        link
        fedilink
        arrow-up
        1
        ·
        2 hours ago

        Yeah some comments are not useful

        # returns the value as a string
        return str(user.id)
        

        Some comments are

        # returns the user id as a string because ZenDesk's API throws errors if it gets a number.
        # See ticket RA-1037
        # See ZenDesk docs: https://etc/
        return str(user.id)
        
      • PonderingPotato@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        3
        ·
        3 hours ago

        That’s typically what people who advocate for less/no comments really mean. The code should self explain “what” it does, but if the “why” isn’t obvious (i.e. confusing business logic) nobody argues that you shouldn’t comment it. That’s how I’ve worked in every company I’ve been at (and all developers around me) from 50 person start ups to >2k people. It’s really common mentality with Ruby developers

        • JcbAzPx@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 hours ago

          Anyone complaining about commenting should be forced to code in assembly for a while.

  • iegod@lemmy.zip
    link
    fedilink
    arrow-up
    16
    ·
    6 hours ago

    I’ll get shit on for suggesting it but this is a great use case for AI: comment the code and generate some basic docs. Even if it’s wrong it’ll give you a sense of where to start looking for flows.

    • JcbAzPx@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 hours ago

      Problem is, you won’t know what the AI screwed up until someone breaks everything.

  • mcv@lemmy.zip
    link
    fedilink
    arrow-up
    2
    ·
    3 hours ago

    I can live without documentation and comments, but then you’ve got to write really well-structured, self-documenting code. Which means long variable names (or better: local constants) that describe exactly what’s in them, and function names that describe clearly what the function is for, and readable code that shows what it does.

    But perhaps expecting that kind of discipline from people who lack the discipline to write documentation, was not entirely realistic.

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

    This is the dram. Since the entire codebase is shit, you basically have to rewrite it basically in its entirety.

    Which means you can do it with an actual good design.

    And if you mess up on something, you have a working version you can consult.

  • _stranger_@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    6 hours ago

    That time I started a new job and my first task was “fix bash”…and then I discovered a multi megabyte monstrosity called “bash.sh

  • freijon@lemmings.world
    link
    fedilink
    arrow-up
    2
    ·
    4 hours ago

    A few years ago I had to port a tool from HTBasic (a proprietary BASIC dialect) to Python. The original source only runs in their proprietary IDE. Of course, no comments whatsoever and a lot of GOTO magic and matrice calculations some of which have no other purpose as to confuse the reader. The variables had only cryptic and meaningless three digit letters. My theory is that they intentionally wrote it in a way that it would be a nightmare to reverse engineer. And they succeeded.

  • JasonDJ@lemmy.zip
    link
    fedilink
    arrow-up
    4
    arrow-down
    2
    ·
    edit-2
    4 hours ago

    Fork the repo.

    Ask an LLM to rename all the variables and add comments and docstrings. Give it your style guide (assuming you have one).

    Ask another LLM to check their work.

    Done.

    Disclaimer: I’m not a programmer, I’m a network engineer who dabbles in automation and scripting. But it seems to me that grunt work like this is what LLMs are really good for.

    Also I only use short variable names inside of loops (for i in iterable…). Is that not how it should be done?

    • HereIAm@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      4 hours ago

      i and I are acceptable in small loops. But it depends a lot on the language used. If you’re in C or bash maybe it’s fine. But if you’re in a higher level language like C# you usually have built on functions for iterating over something.

      For example you have a list of movies you want to get the rating from, instead of doing

      for (i = 0; i < movies.length; i++)
          var movie = movies[i]
          ....
      

      Its often more readable to do

      movies.forEach { movie -> 
          var rating = movie.rating
          ....
      }
      

      Also if you work with tables it can be very helpful to name your iteration variables as row and column.

      It’s all about making it readable, understandable, and correct. There’s no point having comments if you forget to update them when you change the code. And you better make sure the AI comments on the 2000 lines of three letter variables is correct!

      • JasonDJ@lemmy.zip
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        2 hours ago

        Yeah I script more than anything…python, bash, powershell, etc.

        Only terrible code I inherit is the stuff I wrote >=3 months ago. I’ll keep saying that three months from now, too.

    • Gremour@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      4 hours ago

      In Go, the recommended convention for variable name length is to be proportional to their scope. It is common to use one or few letters long variables if they are local to a few lines loop or a short function.

  • adhocfungus@midwest.social
    link
    fedilink
    arrow-up
    8
    ·
    6 hours ago

    “Documenting the code base will be your first task for the next month to help show us how well you understand the codebase.”