• Nalivai@lemmy.world
      link
      fedilink
      arrow-up
      6
      ·
      4 days ago

      The first picture isn’t what people write, even though it’s technically compilable, it’s not what C is.
      The second is a normal syntax, pretty simple to understand if you write enough code.
      C is very simple language at it’s core, and it allows for it to be used in a very complicated systems.

      • iopq@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        20 hours ago

        Nobody is arguing C is complex. The argument is that it’s not the optimal syntax.

        For example, case statements needing breaks can cause logical issues with incorrect merges.

        How about this

        https://en.wikipedia.org/wiki/Unreachable_code#goto_fail_bug

        The if statement not requiring brackets caused this bug. Rust fixes these issues with pattern matching and mandatory curly braces in if body statements

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

          Yeah, it’s not optimal, I don’t think anyone argues that it is. It has a bunch of ways to shot yourself in the foot, no questions about that, people were writing books about that for decades. Not like there is an optimal language that doesn’t allow you to make some stupid mistakes.
          But also, a lot of that non-optimality is what gives it advantage. Well, that and enormous amount of legacy code and expertise.
          Sometimes you need to pass around raw pointers without caring about memory ownership, and for that situation it’s optimal. I’m glad you have your mandatory curly brackets, but sometimes I just want my microcontroller to blink an LED and for that I’m in turn glad that I can be as quick and dirty as my filthy mind allows me.
          And for serious projects we’re all MISRA compliant anyway, and it mandates curly brackets for ifs and proper cases for switch.

          • iopq@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            9 hours ago

            Let’s not get too abstract. Just because Rust made its own mistakes doesn’t mean it didn’t fix the mistakes I pointed out

            Serious projects have huge memory safety issues that don’t exist in Rust. More than half of security CVEs are due to the nature of C. Rust just has fewer bugs like Heartbleed because it doesn’t let you do a buffer overrun

            • Nalivai@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              4 hours ago

              that don’t exist in Rust

              That’s because serious projects basically don’t exist in Rust. Yet, probably, Rust seem to be a good language that people like, so those are to follow, but for now they’re rare.
              Or don’t, if we discover that Rust has some other issue that only happens when the project grows old enough.
              Personally, I’m sticking to the devil I know, the one that has almost 60 years of accumulated knowledge and best practices.

    • db2@lemmy.world
      link
      fedilink
      arrow-up
      5
      arrow-down
      12
      ·
      4 days ago

      Were you trying to post examples of it being easy or do you actually find those hard?

      • esa@discuss.tchncs.de
        link
        fedilink
        arrow-up
        7
        ·
        4 days ago

        I find the C type syntax turgid. It’s fine for the most basic types, but the name-in-the-middle style doesn’t scale at all, and it’s not hard to understand why later languages separate name and type, no matter which side of the name the type goes on.

        I find Rust easier to read in that regard, even though picking <> for generics was likely done to be familiar for C++/Java types rather than easy to parse. (See also: the bastion of the turbofish)

      • iopq@lemmy.world
        link
        fedilink
        arrow-up
        5
        arrow-down
        3
        ·
        4 days ago

        This is why you don’t write C, after a while this looks normal and sane