• Aceticon@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    8 months ago

    Maybe it’s C that’s a good first language, though I would admit that the basic ouputting of values to stdout is more intutive in C++.

    • ebc@lemmy.ca
      link
      fedilink
      arrow-up
      9
      ·
      8 months ago

      this std::cout << "hello world" bullshit is in no way intuitive. You’re using the bit-shift operator to output stuff to the console? WTF? Why 2 colons? What is cout? And then these guys go on to complain about JS being weird…

      No, C is where it’s at: printf("hello world"); is just a function call, like all the other things you do in C.

      • Aceticon@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        edit-2
        8 months ago

        For non-programmers (who most definitelly don’t know that >> and << are bit shift operators) shoving something into something else is more intuitive than “calling a function with parameters”.

        Also don’t get me started on the unintuitiveness of first passing a string were text is mixed with funny codes sgnaling the places were values are going to be placed, with the values passed afterwards, as opposed to just “shove some text into stdout, then shove a value into stdout, then shove some more text into it”.

        Absolutelly, once you are used to it, the “template” style of printf makes sense (plus is naturally well-suited for reuse), but when first exposed to it people don’t really have any real life parallels of stituations were one first makes the final picture but leaving some holes in it and later fills-in the holes with actual values - because in real life one typically does it all at once, at most by incremental composition such as in C++, not by templating - so that style is not intuitive.

        • ebc@lemmy.ca
          link
          fedilink
          arrow-up
          1
          ·
          8 months ago

          shove some text into stdout

          That’s not what this operator does normally, and if you try to “shove” something into anything else (an int into a variable? a function into an object?) you’ll get surprises… Basically it’s “special” and nothing else in the language behaves like it. Learning hello world in C++ teaches you absolutely nothing useful about the language, because it doesn’t generalize.

          C, in contrast, has many instances of complex functions like printf (another commenter mentioned variable arguments), and learning to call a function is something very useful that generalizes well to the rest of the language. You also learn early enough that each different function has its own “user manual” of how to use it, but it’s still just a function call.

      • Sonotsugipaa@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        4
        ·
        8 months ago

        C is no beginner heaven either, printf is its own can of “why can this function have any number of arguments and why does the compiler have to complain about the formatting every 25 milliseconds” worms