82

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

you are viewing a single comment's thread
view the rest of the comments
[-] Darkcoffee@sh.itjust.works 54 points 2 days ago

Machine energy, definitely not programmer energy ;)

[-] arendjr@programming.dev 30 points 2 days 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.

[-] RheumatoidArthritis@mander.xyz 8 points 2 days ago

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

[-] witx@lemmy.sdf.org 1 points 22 hours ago

And how testable is that solution? Sure macros are helpful but testing and debugging them is a mess

[-] arendjr@programming.dev 5 points 2 days 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.

[-] KRAW@linux.community 1 points 2 days ago

Not sure I understand your comment on multithreading. pthreads are not very hard to use, and you have stuff like OpenMP if you want some abstraction. What about C is not ideal for multithreading?

[-] arendjr@programming.dev 5 points 2 days ago

It’s that the compiler doesn’t help you with preventing race conditions. This makes some problems so hard to solve in C that C programmers simply stay away from attempting it, because they fear the complexity involved.

It’s a variation of the same theme: Maybe a C programmer could do it too, given infinite time and skill. But in practice it’s often not feasible.

[-] Colloidal@programming.dev 1 points 2 days ago

Memory management, but that impacts stability/security instead of performance.

[-] aubeynarf@lemmynsfw.com 2 points 2 days ago

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.

What are you talking about? https://docs.gtk.org/glib/data-structures.html

[-] arendjr@programming.dev 6 points 2 days 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.

[-] aubeynarf@lemmynsfw.com 2 points 2 days ago

OK, think of all the other C collection libraries there must be out there!

[-] arendjr@programming.dev 5 points 2 days 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 2 points 2 days 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 5 points 2 days 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 3 points 2 days ago

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

this post was submitted on 11 Jun 2025
82 points (85.3% liked)

Programming

20858 readers
147 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS