• arendjr@programming.dev
      link
      fedilink
      arrow-up
      21
      arrow-down
      2
      ·
      7 months ago

      I would argue that because C is so hard to program in, even the claim to machine efficiency is arguable. Yes, if you have infinite time for implementation, then C is among the most efficient, but then the same applies to C++, Rust and Zig too, because with infinite time any artificial hurdle can be cleared by the programmer.

      In practice however, programmers have limited time. That means they need to use the tools of the language to save themselves time. Languages with higher levels of abstraction make it easier, not harder, to reach high performance, assuming the abstractions don’t provide too much overhead. C++, Rust and Zig all apply in this domain.

      An example is the situation where you need a hash map or B-Tree map to implement efficient lookups. The languages with higher abstraction give you reusable, high performance options. The C programmer will need to either roll his own, which may not be an option if time Is limited, or choose a lower-performance alternative.

        • arendjr@programming.dev
          link
          fedilink
          arrow-up
          4
          ·
          7 months ago

          I’m not saying you can’t, but it’s a lot more work to use such solutions, to say nothing about their quality compared to std solutions in other languages.

          And it’s also just one example. If we bring multi-threading into it, we’re opening another can of worms where C doesn’t particularly shine.

        • arendjr@programming.dev
          link
          fedilink
          arrow-up
          5
          arrow-down
          1
          ·
          7 months ago

          Well, let’s be real: many C programs don’t want to rely on Glib, and licensing (as the other reply mentioned) is only one reason. Glib is not exactly known for high performance, and is significantly slower than the alternatives supported by the other languages I mentioned.

            • arendjr@programming.dev
              link
              fedilink
              arrow-up
              7
              arrow-down
              1
              ·
              7 months ago

              Which one should I pick then, that is both as fast as the std solutions in the other languages and as reusable for arbitrary use cases?

              Because it sounds like your initial pick made you loose the machine efficiency argument and you can’t have it both ways.

        • calcopiritus@lemmy.world
          link
          fedilink
          arrow-up
          3
          arrow-down
          2
          ·
          7 months ago

          Glib us licensed under LGPL. So unless your project is happy with that, it’s as if it didn’t exist. That’s one of the problems of having a small standard library.

          • atzanteol@sh.itjust.works
            link
            fedilink
            English
            arrow-up
            5
            ·
            7 months ago

            It’s one of the more permissive licenses - who the hell is going to have a problem with lgpl? You can ship it with proprietary applications.

          • aubeynarf@lemmynsfw.com
            link
            fedilink
            arrow-up
            3
            ·
            7 months ago

            It’s a single counterexample. there are many, many such libraries for C and the programmer does not have to roll their own.

  • frezik@midwest.social
    link
    fedilink
    arrow-up
    12
    arrow-down
    1
    ·
    7 months ago

    For raw computation, yes. Most programs aren’t raw computation. They run in and out of memory a lot, or are tapping their feet while waiting 2ms for the SSD to get back to them. When we do have raw computation, it tends to be passed off to a C library, anyway, or else something that runs on a GPU.

    We’re not going to significantly reduce datacenter energy use just by rewriting everything in C.

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    10
    ·
    edit-2
    7 months ago

    Ah this ancient nonsense. Typescript and JavaScript get different results!

    It’s all based on

    https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game

    Microbenchmarks which are heavily gamed. Though in fairness the overall results are fairly reasonable.

    Still I don’t think this “energy efficiency” result is worth talking about. Faster languages are more energy efficient. Who new?

    Edit: this also has some hilarious visualisation WTFs - using dendograms for performance figures (figures 4-6)! Why on earth do figures 7-12 include line graphs?

    • Dumhuvud@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      7 months ago

      Typescript and JavaScript get different results!

      It does make sense, if you skim through the research paper (page 11). They aren’t using performance.now() or whatever the state-of-the-art in JS currently is. Their measurements include invocation of the interpreter. And parsing TS involves bigger overhead than parsing JS.

      I assume (didn’t read the whole paper, honestly DGAF) they don’t do that with compiled languages, because there’s no way the gap between compiling C and Rust or C++ is that small.

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        7 months ago

        Their measurements include invocation of the interpreter. And parsing TS involves bigger overhead than parsing JS.

        But TS is compiled to JS so it’s the same interpreter in both cases. If they’re including the time for tsc in their benchmark then that’s an even bigger WTF.

  • kersplomp@programming.dev
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    7 months ago

    I just learned about Zig, an effort to make a better C compatible language. It’s been really good so far, I definitely recommend checking it out! It’s early stages for the community, but the core language is pretty developed and is a breath of fresh air compared to C.

    • lustyargonian@lemm.ee
      link
      fedilink
      arrow-up
      4
      ·
      7 months ago

      What if we make a new language that extends it and makes it fun to write? What if we call it c+=1?