Which will probably be never.

  • @[email protected]
    link
    fedilink
    9
    edit-2
    1 month ago

    C does exactly what you tell it, no more. Why waste cycles setting a variable to a zero state when a correct program will set it to whatever initial state it expects? It is not user friendly, but it is performant.

    • @marcos
      link
      71 month ago

      Except that this is wrong. C is free to do all kinds of things you didn’t ask it to, and will often initialize your variables without you writing it.

      • @[email protected]
        link
        fedilink
        English
        11 month ago

        Machine code would be a better example of what he’s talking about imo. Not an expert or anything of course.

        • @marcos
          link
          31 month ago

          Odds are that your computer doesn’t export any language where it will do exactly as you say (amd64 machine code certainly won’t execute exactly as written). And how much difference it makes varies from one language to another.

          But the specific example from the OP, of uninitialized variables, is one of those cases where the C spec famously goes completely out of line and says your code can do whatever, run with a random value, fail, initialize it, format your hard drive, make a transaction on your bank account… whatever.

          • @[email protected]
            link
            fedilink
            21 month ago

            Coding in C but if I don’t initialize a Variable the compiler formats my drive! (Not Clickbait)

    • @[email protected]
      link
      fedilink
      English
      11 month ago

      It wouldn’t be that much processing compared to the rest of the app. It would lot more efficient than running an effectively infinite loop or arithmetic on an arbitrarily large number as a result of an unsigned variables.