r/C_Programming • • Oct 17 '26

Discussion My opinion about C development

when wanting to code real software in c; i feel that you need to learn way to much tools like (c)make, clang/gcc etc.

that's why i decided to NOT use any tools and libraries INCLUDING GLIBC and other standard c libraries!

fuck the world; im making my own printf, strlen and more! AND THE ONLY THING IM GONNA USE IS CLANG WITH C17!

0 Upvotes

36 comments sorted by

3

u/JGhostThing Oct 17 '26

If you use clean makefile's, you don't need to use most of the rest of the tooling.

And yes, you can rewrite libc if you really want to, but this is a huge investment of time. The rest of the libraries would be another huge investment.

Rather than do things like this, I prefer to be paid for my time. I don't want to use a buggy library in production code. And yes, I'm pretty sure that your libraries will be buggy. This is pretty much what happens if a single person write a library without quality assurance.

1

u/wak6817-2 Oct 17 '26

im making a project rn; i only needed to make strlen and printf; it works well! but thanks

5

u/catladywitch Oct 17 '26 edited Oct 17 '26

What

edit: in case you're serious, you'll lose portability and end up with a more unsafe and less performant version of everything, also yes, c doesn't have the friendliest toolchain compared to some other languages, but giving make or cmake up is just shooting yourself in the foot isn't it? I mean, even if you write your own stdlib at the very least you're going to need to link it

0

u/wak6817-2 Oct 17 '26

im not that serieus; i just thought it was cool to share my opinion and nuke my karma on reddit 🥲

-3

u/wak6817-2 Oct 17 '26

yes you read that right; fuck printf

2

u/number_1_steve Oct 17 '26

I love that idea for learning. Doing that, you learn so much about hardware, kernels, interfaces, C, and on and on. I vibe-coded (which I generally hate, I did it mostly to check it out) a Linux, x64 based libc implementation. It has tests, fuzzing, and docs. I’m happy to share if you want.

2

u/wak6817-2 Oct 17 '26

mmhhh; to bad im on a aarch64 machine... but you can share it!

2

u/sciencekm Oct 17 '26

Plenty of the exercises in the K&R books are about implementing the std functions. So I think this is a good way to get proficient with C.

0

u/wak6817-2 Oct 18 '26

lol; i actually use the c book for learning these things

3

u/Ecelleon Oct 17 '26

If you like reinventing the wheel, sure. You could also dig through how these functions work if you don't trust someone handing you abstraction.

1

u/wak6817-2 Oct 17 '26

finally; this was kind of where i was going for because i dont like how much 'bloat' glibc and other standard c libraries bring! i really think how python handles this with from ... import ...

2

u/orange_oki Oct 17 '26 edited Oct 17 '26

The 'bloat' comes from performance optimizations and you will have a really hard time doing better.

C is good for libraries, because it has no exceptions, oop and garbage collector. C++ for example does not guarantee that your variables and function names will appear in the assembled output (generated library), except you use extern "C".

That way the libraries are compatible to almost any other programming language.

If you don't do libraries, or try to understand basic programming algorithms make your life easy and go with a high level language.

Here is the memcpy code for:

while(len-->0){*dest++=*src++}

https://github.com/bminor/glibc/blob/master/sysdeps/aarch64/memcpy.S

And for X86, depending on the CPU instruction set, all the files starting with memmove:

https://github.com/bminor/glibc/tree/master/sysdeps/x86_64/multiarch

1

u/mikeblas Oct 17 '26

Bloat comes from performance optimization? How do you figure that?

1

u/orange_oki Oct 17 '26 edited Oct 17 '26

Loop unrolling, specific implementations for different sizes, prefetch to access hot L1/L2 cache areas and alignment issues.

https://db.in.tum.de/teaching/ss22/c++praktikum/slides/lecture-10.1.pdf

Guess it's something like that:

https://www.felixcloutier.com/x86/movs:movsb:movsw:movsd:movsq

Copy byte for byte with duffs device or CPU instruction until aligned to 16-byte.

Loop until done:
If size >= 512
 copy with AVX if available 
Else If size >= 256
copy with AVX if available
Else If size >= 128
copy with SSE/SSE2 if available
else
 Byte by byte

🤷

1

u/mikeblas Oct 18 '26

Maybe unrolling loops or adding modalities for big-step functions adds some code, but it's only a fraction of the code that appears when features are added, backward-compatibility is maintained, robustness is enhanced, layers are added, compatibility is enhanced, and so on ...

1

u/WittyStick Oct 17 '26 edited Oct 17 '26

If you want really fast memcpy et al, check out: https://github.com/amd/aocl-libmem

Will pick the most appropriate versions for your CPU.

2

u/Ecelleon Oct 17 '26

It's not bloat. If you were trying to cram a program into a small microcontroller like the ATTiny85, where every byte is precious, then you could argue that not using a library is valid because it reduces overall program size because you don't actually need every feature in said library. However, the amount of space that using standard libraries would add, doesn't mean anything.

Honestly, the most important part of a library is that it offers standardization. Everybody knows what to expect when you use standard libraries. You also get to take advantage of leveraging solutions that others have already figured out. You shouldn't go through the effort of building a chop saw when it already exists.

1

u/Top-Employ5163 Oct 17 '26

What's wrong with printf?

1

u/wak6817-2 Oct 17 '26

nothing; just nothing

2

u/limitless_grow Oct 19 '26

A lot of the format options are compiler specific and the output depends on the locale and format enhancements aren't easy. That's indeed somewhat nasty once you need reliable and portable output. However a complete wrapper of that requires months of development time and most wrappers are quite incomplete and buggy hobby projects. This one is quite complete but locale independend and allows a formatted output of own data types using %v and has some other nice enhancements ( klux21/callback_printf ). The license doesn't allow to use that for weapons but to use that for commercial closed source software. 🤔

1

u/DDDDarky Oct 17 '26

when wanting to code real software in c; i feel that you need to learn way to much tools like (c)make, clang/gcc etc.

You think this is too much to learn? Oh boy wait till you get to real software.

0

u/wak6817-2 Oct 17 '26

bro; i learned web dev with fucking tutorial hell! ofc this is kind of a joke; when im gonna make BIG software or contribute to it, i'll ofcourse use Make etc

3

u/DDDDarky Oct 17 '26

Yeye webdev 🙄, gl

1

u/wak6817-2 Oct 17 '26

thats why i stopped doing it :)

1

u/Shattered-Spears Oct 17 '26

How do you tackle something like that? Do you "borrow" from other libs to make your own? In other words, how could one write a library? Are there any books dealing with such thing?

0

u/wak6817-2 Oct 18 '26

you need to think logicly; things like printf just prints chars; and putchar() is standard in c so just write a loop to putchar(i) while string is not '\0'

1

u/Still_Explorer Oct 25 '26

For me the case was somewhat opposite, I didn't want to learn CMake and didn't learn it. I just copied lines from dozens of other cmake scripts and brute forced it until it worked. Now also I am not sure I know CMake but I know about how 20 or something commands work and I use them.

And somehow this goes for all sorts of programming or even third party libraries. You don't need to be an expert in 3D physics - you just use Box3D. You don't need to be an expert in databases - you just use SQLite. You don't need to be an expert in networking - you just use libhttp.

In terms of educational purposes, learning is free and unlimited, someone can learn everything and anything within 90 years. But the real catch in everything at some point is to define exactly where your area of expertise is and be concerned only with problems related to that area, for better worse then, using libraries made by other experts (who have mastered their respective areas) is essential.

Is like if someone is dropped in the middle of the ocean, and see a life jacket and a box containing a satellite phone and say "F this S man I am throwing it away! I can make my own open source satellite phone with Raspberry once I get home".

Problem is not about making your own thing, but problem is not using something that works when you need it the most.

0

u/mivanchev Oct 17 '26

Don't forget to use AI!

0

u/[deleted] Oct 17 '26

[removed] — view removed comment

1

u/C_Programming-ModTeam Oct 21 '26

Your comment does not add value and has been removed.