r/C_Programming • u/Rogaev • Aug 09 '26
Question Is it worth while to use libc?
I've been wondering this for quite some time now.
For Linux development, is it worth creating basic read/write functions in asm, and writing everything else in C?
Does most open source software use functions from the standard C library? What are the benefits of both approaches?
Edit: I would be using Arm64 assembly.
Thank you in advance.
0
Upvotes
12
u/alkatori Aug 09 '26
Why would you avoid using libc?
8
u/AmbitiousSolution394 Aug 09 '26
> is it worth creating basic read/write functions in asm
In libc, write() and read() acts as a wrappers around OS syscalls. I'm not sure that writing something in asm would improve something there.
> Does most open source software use functions from the standard C library?
Yes, its hard to write C program without using LIBC.
2
u/silvertank00 Aug 09 '26
you forgot one thing: which asm? arm, x86, avr? If you want it to be cross platform, use libc
3
u/ForgedIronMadeIt Aug 09 '26
Honestly, if you cannot identify a really strong reason to do it, then you shouldn't. The standard libraries are there for a reason and are pretty much always well written and tested.
Your reason could be "I want to learn how to do it" which is fine but there's better things to spend your time on otherwise.
2
u/sciencekm Aug 09 '26
I can think of only three reasons why you would not use libc:
For everything else, you should be using libc.
2
u/Confused-Armpit Aug 09 '26
There is functionally no benefit in not using libc, unless you are working on embedded systems with massive memory constraints, where each byte might matter, or maybe you want to learn more about ELF/PE files and write your own implementations of things handled by libc.
But in other cases, your libc is probably both better implemented better than whatever you will craft up (since it has had dozens of years to mature and improve), and also it'll just be a massive time sink that won't give any reasonable improvements.
1
u/EpochVanquisher Aug 09 '26
There is not much benefit in making read/write functions in assembly and there are a lot of drawbacks (your code is less portable, there are more likely to be bugs in it).
Most software uses functions from at least the standard library, and often other libraries as well. I think almost any programmer would think that it’s absurd to write your own read/write functions in assembly, outside of stuff like demoscene sizecoding projects.
0
u/TheAncientGeek Aug 09 '26
It's worth doing if you have a specific reason like efficiency or safety.