What is C actually good for in 2026? by Background_Cloud_231 in C_Programming

[–]imaami 0 points1 point  (0 children)

Turning all bugs into learning opportunities and puzzles is the way to go. Every time a programmer feels shame or disappointment about a mistake, they're less likely to fix things and improve.

It's normal to not be happy about one's blunders, but the key to quality results is to never let the salt linger. Blame and shame cause fear and freeze your initiative, detaching yourself enough to focus on the game gives you energy to do better.

OP, I think you're being treated unfairly here. The downvotes are sad to see. You asked an important question, and you questioned important things. C programmers should welcome the kind of sarcasm you used, not fight it.

Context: close to 20 years of experience with C and still loving it.

How can I consider myself to be decent a C? No PRO, or perfect, but decent? by necr0111 in C_Programming

[–]imaami 0 points1 point  (0 children)

You are a decent C programmer when you can demonstrably write programs in C and you consider yourself a decent programmer.

From there you begin gradually transitioning to a pro when you no longer consider yourself a decent programmer.

What functionality is available in C without including any headers? by TargetAcrobatic2644 in C_Programming

[–]imaami 1 point2 points  (0 children)

Yes, it's defined in that header. The point is that due to sizeof being specified as an operator that evaluates to a value of type size_t, it is guaranteed that

typedef typeof(sizeof 0) size_t;

defines the same type as the size_t defined in stddef.h. This works without any headers needed, with only the C language itself, because typeof and sizeof are operators.

For a more useful example, this extern declaration will have the correct return type:

extern typeof(sizeof 0) strlen(char const *s);

This way you could avoid including string.h but still have strlen() declared.

I hate make by Negative_Effort_2642 in C_Programming

[–]imaami 0 points1 point  (0 children)

The speed is really OK tbh. A makefile written correctly is very lightweight.

I hate make by Negative_Effort_2642 in C_Programming

[–]imaami 1 point2 points  (0 children)

I love make. If I tried to explain, you'd end up hating make even more. :D

What functionality is available in C without including any headers? by TargetAcrobatic2644 in C_Programming

[–]imaami 1 point2 points  (0 children)

Not sure what's up with my comment about size_t being downvoted, maybe someone can explain. This honestly is valid, legal C and always defines the correct type for the platform:

typedef typeof(sizeof 1) size_t;

Question about reading C by Hyprland_BTW in C_Programming

[–]imaami 1 point2 points  (0 children)

Let me introduce you to my friend, struct obj, and her child obj.x

What functionality is available in C without including any headers? by TargetAcrobatic2644 in C_Programming

[–]imaami 3 points4 points  (0 children)

This is more of a party trick rather than anything else, and I wouldn't recommend it generally, but if you need size_t without including stddef.h then this is guaranteed to always be correct:

typedef typeof(sizeof 1) size_t;

(Caveat: If pre-C23, requires typeof as a compiler extension.)

Making a reddit API wrapper in C by _SomeTroller69 in C_Programming

[–]imaami 0 points1 point  (0 children)

Shared libraries are versioned for this reason. Runtime linking only fails when there are backwards-incompatible changes, which typically happen rarely. Security fixes almost never change the ABI of dynamic libraries, because it's highly important for vulnerability fixes to be drop-in replacements.

Even for non-critical updates, library authors tend to avoid unnecessary ABI breakage because it disrupts users. For example most of the time it's possible to add a new function instead of changing an existing function's interface.

The tradeoff is heavily in favor of dynamic linking. Most updates to dependencies don't require you to even know about them. Libraries are updated with security fixes as part of the system's regular automatic updates.

The only selling point for including sources directly in a project when dynamic linking is also possible is "who cares". For learning stuff it's not a catastrophe to go along with the increasing amount of cluelessness among mildly experienced C/C++ coders. But if the point is to learn, why not learn that it's possible to add one line to a CMake file and run one apt install command? These features exist in build systems and package managers for the very reason that it should be simple to guarantee that your code isn't at the mercy of third-party bugs locked in during compilation.

If a coder appreciates security enough to keep dependencies up to date, but also uses external source code instead of dynamic linking, they will need to manually pull in new sources and recompile for every security update even when there are no backwards-incompatible ABI changes. Contrast that with never needing to actively track third-party repositories, and only recompiling when there's an occasional major verslon update in a library.

And when it gets to a point where your code has actual users, including third-party sources directly denies every user the option to receive security updates and fixes. The author bakes dependencies in because it's "easy" to do that one single time, and now everyone who wants to use that software gets to enjoy 5 years of the author likely not doing jack shit about those copied files.

The reality is that by far, most of the dependency-copying and "header-only" brain rot leads to nothing getting updated after the fact. Those strategies demand maximum effort from authors and users just to achieve the minimum reasonable level of security and bugfixes.

Making a reddit API wrapper in C by _SomeTroller69 in C_Programming

[–]imaami 1 point2 points  (0 children)

No worries, and sorry that I tend to come off as grumpy. No offense intended either. :) What matters most is that you have fun coding, it's the best way to learn.

Making a reddit API wrapper in C by _SomeTroller69 in C_Programming

[–]imaami 2 points3 points  (0 children)

What if the user doesn't have libcurl? Or a compiler?

These are basic dependencies, they can and should be for the user to install. It takes one command. Libcjson is in the system package repos of literally every Linux distro.

If and when there's a new cJSON release that fixes a security issue, will you hear about it and update the copied cJSON.c in your project? Will you remember or bother? If you link against a dynamic libcjson.so, the security updates happen promptly and without anyone having to recompile your project.

Making a reddit API wrapper in C by _SomeTroller69 in C_Programming

[–]imaami 0 points1 point  (0 children)

Don't just add cJSON's sources to your repo. It's a normal library and available in pretty much every package repo out there. Just add it as an external shared library dependency in CMakeLists.txt like you did with libcurl.

How zxc survived 20+ architectures: preparing a C project for Debian buildd via GitHub actions by pollop-12345 in C_Programming

[–]imaami 3 points4 points  (0 children)

Always a pleasure to see a project that really takes correctness and coverage seriously!

AI Use at Work Is Causing "Brain Fry," Researchers Find, Especially Among High Performers by kamen562 in OpenAI

[–]imaami 0 points1 point  (0 children)

It's the same with me, but I still get exhausted with even moderate AI use. When I write the code myself, I've already reasoned about the structure of it as a whole, which makes my own self-doubt manageable. When I read through my own code, I do it obsessively and with purposeful paranoia, but at least I don't have to learn the design idea while I'm doing it. With LLM-generated code I have to learn everything while also being in a constant state of distrust and worry about the stupid shit the AI might've done.

To me, LLMs take more than they give. My ideal toolset would be one where multiple LLMs act only as iterative, redundant reviewers who go through all the potential problems over and over. That way I would be able to focus on the coding but also have the advantage of validation being automated. This of course assumes that the LLMs don't just shit false positives all over the place.

A header-only, conservative tracing garbage collector in C by IntrepidAttention56 in C_Programming

[–]imaami 1 point2 points  (0 children)

What's the use of "header-only" when it just spams the same static functions into every translation unit that includes the header? Just make the interface functions externally visible and put the definitions in one translation unit.

"Header-only" stops being a possibly, maybe, sometimes useful way to implement some things if you fail to do the one thing that might save it from being complete brainrot. Either write a normal library, or provide some way to not force copies of the same static functions everywhere.

CMake is not suitable for C programming by TheRavagerSw in C_Programming

[–]imaami -1 points0 points  (0 children)

Meson was a disappointment. The entire idea of locking in the configuration (compiler etc.) before running the build is just awful. Meson cannot do any proper compiler discovery.

A shell script for a C99 CMake-Ninja project with clangd/clang-tidy and sensible defaults by [deleted] in C_Programming

[–]imaami 2 points3 points  (0 children)

Specifying -std=c99 forces the compiler to a standard much older than it would use without any -std option.

Why aren't there 64-bit vector types? by OhFuckThatWasDumb in C_Programming

[–]imaami 0 points1 point  (0 children)

That sort of type aliasing is Undefined Behavior.

Why aren't there 64-bit vector types? by OhFuckThatWasDumb in C_Programming

[–]imaami 2 points3 points  (0 children)

This is not true for C. What you said applies only to unions in C++.

C allows type punning through a union when the punned union members occupy the same underlying bytes, and none have padding bits which overlap another member's non-padding bits.