• bigfondue@lemmy.world
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      2 days ago

      If you had a question about C, you would just consult K&R, and I don’t mean the book

      • ylph@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        2 days ago

        I worked at Bell Labs in the 90s, on wireless stuff, but we were still using the “in house” cfront compiler at the time, and would e-mail the compiler group, which included Bjarne Stroustrup, with issues sometimes. I learned C++ from his book before I joined Bell Labs, so that was a bit of a holy shit moment for sure for me then.

        Kernighan, Ritchie and Thompson all still worked at Bell Labs as well at the time, but the company was huge then, and they were all in a different location from my team, so I never had any opportunities to meet them.

        • bigfondue@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          2 days ago

          Have you read Unix: A History and a Memoir? I only started it, but the first chapter or two is just Kernighan talking about Bell Labs.

    • xthexder@l.sw0.com
      link
      fedilink
      English
      arrow-up
      26
      ·
      2 days ago

      Hello World in 1974: echo.c

      main(argc, argv)
      int argc;
      char *argv[];
      {
      	int i;
      
      	argc--;
      	for(i=1; i<=argc; i++)
      		printf("%s%c", argv[i], i==argc? '\n': ' ');
      }
      
        • xthexder@l.sw0.com
          link
          fedilink
          English
          arrow-up
          10
          ·
          2 days ago

          I think it’s actually quite elegant. No matter what it has to skip over argument 0 which will be the executable name echo.
          If the subtraction was removed and the loop changed to <, it would then need to do an addition or subtraction inside the loop to check if it’s the last argument.

          • palordrolap@fedia.io
            link
            fedilink
            arrow-up
            5
            ·
            2 days ago

            The real question might be whether the compiler was smart enough to change var++ and var-- into ++var and --var when the initial values aren’t needed.

            As compiler optimisations go, it’s a fairly obvious one, but it was 1974 and putting checks like that in the compiler would increase its size and slow it down when both space and time were at a premium.

    • bigfondue@lemmy.world
      link
      fedilink
      English
      arrow-up
      33
      ·
      edit-2
      3 days ago

      It’s actually really easy when you get to make everything up as you go along. Like the transistor, and C, and Unix. That place was something else. The modern world was born in NJ