cross-posted from: https://lemmy.world/post/31184706

C is one of the top languages in terms of speed, memory and energy

https://www.threads.com/@engineerscodex/post/C9_R-uhvGbv?hl=en

top 50 comments

sorted by: hot top controversial new old
[–] 56 points 1 year ago (1 child)

Machine energy, definitely not programmer energy ;)

  • source
  • hideshow 2 child comments
  • [–] 28 points 1 year ago (8 children)

    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.

  • source
  • parent
  • hideshow 9 child comments
  • [–] 10 points 1 year ago (4 children)

    I understand your point but come on, basic stuff has been implemented in a thousand libraries. There you go, a macro implementation

  • source
  • parent
  • hideshow 5 child comments
  • load more comments (3 replies)
  • load more comments (7 replies)
  • [–] 37 points 1 year ago

    This doesn't account for all the comfort food the programmer will have to consume in order to keep themselves sane

  • source
  • [–] 34 points 1 year ago (6 children)

    For those who don't want to open threads, it's a link to a paper on energy efficiency of programming languages.

  • source
  • hideshow 7 child comments
  • [–] 41 points 1 year ago (24 children)
  • [–] 5 points 1 year ago (1 child)

    I would be interested in how things like MATLAB and octave compare to R and python. But I guess it doesn't matter as much because the relative time of those being run in a data analysis or research context is probably relatively low compared to production code.

  • source
  • parent
  • hideshow 2 child comments
  • load more comments (17 replies)
  • load more comments (5 replies)
    [–] 20 points 1 year ago (1 child)

    and in most cases that's not good enough to justify choosing c

  • source
  • hideshow 2 child comments
  • [–] 16 points 1 year ago (1 child)

    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.

  • source
  • hideshow 2 child comments
  • [–] 10 points 1 year ago* (last edited 1 year ago) (5 children)

    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?

  • source
  • hideshow 5 child comments
  • load more comments (5 replies)
    [–] 9 points 1 year 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.

  • source
  • [–] 9 points 1 year ago
    [–] 8 points 1 year ago (1 child)

    Your link links to facebook that links to https://haslab.github.io/SAFER/scp21.pdf

    Written in 2021 and not including julia is weird imo. I'm not saying it's faster but one should include it in a comparison.

  • source
  • hideshow 2 child comments
  • [+] 6 points 1 year ago
    [–] 4 points 1 year ago (1 child)

    True but it's also a cock to write in

  • source
  • hideshow 2 child comments
  • load more comments
    view more: next ›