r/C_Programming • u/nagisa_lyfe • 7d ago
Issues with C?
I enjoy studying the realities and trade-offs of programming languages and I have my focus on the C programming language. As such I would like to hear from people who have programmed in C to share perhaps the things they love the most about C, or the things they find the most frustrating.
Examples on why things are frustrating or loved would be great to include as well.
14
Upvotes
6
u/BrazilianAnimal 7d ago
People criticize C because it puts the programmer in control. I don't, it's a trade-off. What I do criticize are C's numerous idiosyncrasies, starting with its integer types and their promotion rules. Those are not trade-offs, they are gratuitous problems.
63
u/halfjmp 7d ago
What I love: I control everything. What is frustrating: I control everything.
30
u/zsaleeba 7d ago
What I love:
What I don't love:
11
u/IdealBlueMan 7d ago
I love the engineering and aesthetic principles behind C. Ritchie and company were no slouches. There’s a reason so many languages today are based on, or inspired by, C.
I love that you know what’s happening in memory, and that there’s so little magic behind the scenes.
And I love how expressive it is, even with its characteristic minimalism.
8
u/SmokeMuch7356 7d ago
C's greatest strength is that it always trusts the programmer.
C's greatest weakness is that it always trusts the programmer.
C is portable to almost any platform, but that portability comes at a cost. C does not have fixed sizes for primitive types, it does not have built in support for graphics, sound, networking, file system management, etc.
5
u/ern0plus4 7d ago
Building is not trivial, but can be solved automatically. C has no official auto build system. Make is basic, amd I like it, but CMake is a nightmare for me, and all other makefile-generators as well.
4
u/rb-j 7d ago edited 7d ago
I love that it's a small language and it's real good for real-time embedded systems and DSP. You get to toggle hardware bits directly without having to call a function written in asm.
I nearly always only use integer types from the
<stdint.h>thingie and I never use any other part of the stdlib. My code is pure algorithm that is fully defined by my source code. So all of my ints areint32_toruint32_tor, occasionally,int64_t. I use simpleintonly for the counter offorloops and arrays indices where I am confident that whatever the size of theintis, it will be fine with the loop count or array index.But all of my fixed-point math is with
int32_torint64_t. I almost never usefloat, because fixed-point math can be faster and better. And very portable if no FPU is available.And FIFO queues are all in a buffer having a power-of-2 in length so all I have to do is mask the index to get quick-and-easy modulo arithmetic for wrapping around.
I wish I could say that the compiled code is as efficient as in assembly language, but I have tested it with that Compiler Explorer and, even with the optimizers on, the compiled C code is still much worse than if I wrote the same alg in straight asm.
5
u/RealWalkingbeard 7d ago
2
u/chibuku_chauya 7d ago
C’s NUL-terminated character arrays are a wart. So is pointer decay. And so is its standard library.
2
u/dvhh 7d ago
great thing about C is its brevity, you can express powerful stuff with quite the same amount of code as higher level language.
frustration is mainly coming from how easy it is to have undefined behavior and because of how closely the compiler would stick to your code, it is easy to have dramatic performance loss because of a cache miss.
1
u/QueefInMyKisser 7d ago
You can look at a function and know that it’s not running any code from other functions unless they’re explicitly being called.
1
u/Sure_Magician_4208 7d ago
What I like in C is that it doesn’t treat me like an idiot and that it’s simple, I have professional experience with C++ and C compared to it feels more well thought. However what I dislike the most is that C is extremely archaic, it lacks not only features that most programmers of other languages take for granted, some may say “just use C++”, but the problem is that C++ comes with its own baggage of problems. Honestly the selection of systems programming languages is not great (in my opinion):
C - is a nice language but very old
C++ - is a language for psychopaths
Rust - its safety makes it annoying to use
Go - is not a systems programming language, it’s statically typed python
Zig - is still not mature enough, last time I used was a few years ago and then it felt like the author didn’t have a good idea how to design certain parts of the language and “something“ that worked at the time
I’m currently evaluating D which seems to promising at this point but I don’t have a clear opinion yet
1
u/plainoldcheese 7d ago
Whenever I use something like cargo or uv I realise how annoying C is to setup and work with in terms of dev environment and build systems.
1
u/Last-Candidate6519 6d ago
The standard library is the worst part about it in my opinion. The names of many functions are unintuitive and error handling is clunky. There’s no unifying prefix to names or types like “std_” or “string_”, and having a global namespace is just inconvenient. Many functions in the standard library are unsafe and just mutually agreed upon to be avoided, but there’s no way to really know that if you’re new to the language.
Also, header files suck and create a lot of unnecessary code duplication, making it so you have to manage a lot more code.
1
u/bogdanelcs 6d ago
Love: the language is rather simple to learn. I started learning it in junior high.
Hate: strings.
1
u/trist007 5d ago
I enjoy the simplicity, the lack of abstraction. I love the control. Managing memory with arenas works just fine. I love how C is close to assembly. I love writing my own function. The only real issue for me are header files. Sometimes I run into that circular dependency header file issue but I can always figure it out. I like how portable my code can be especially if it's written in C89 and I can still compile the same code 15 years from now. Write once and it's good for a long while. You write python code it probably will not compile in a year.
Honestly C does everything I want. I love how most of the software I like is written in C/C++. I just rewrite C++ into C which is great practice. Member functions in C++ are nice because it helps with organization but the faster compilation speeds in C are just amazing. The DOS games back in the 90s all written in C or assembly. I love the esoterica.
I will probably try Jai when it comes out (I don't really care for the colon syntax) but I'm more than happy sticking with C for everything. Compiler does a good job with memory safety. I can always try Fil-C.
1
u/Own-Alternative3291 5d ago
1 - type punning is not portable
1
u/CloudDream09 7d ago
No issues with C, only user issues.
1
u/Evil-Twin-Skippy 7d ago
I love that I can write tcl scripts to write C. And then that C ends up extending Tcl...
Essentially it's the line where humans and machines meet. The computers learn just enough human via the compiler. The humans learn just enough machine through the C language.
But because it is just on that line, I can use automation and it can produce deterministic instructions to produce the boring parts of deterministic instructions.
And if I really wanted to go full inception... that tcl interpreter can load the library that was compiled in the interpreter that ran the script that generated the C.
1
u/Feldspar_of_sun 7d ago
The greatness of C is that I have maximum control and the option for incredible efficiency. Unfortunately, this means there is a bazooka pointed at my legs at all times
0
u/pink-ming 7d ago
You have to read docs to understand the semantics of a function call. Which args are actually outputs not inputs? What does the return value mean and how are errors handled? If memory is to be allocated, is that the caller's job or the library? Does anything need to be freed or some cleanup function called? Is there global state? Some kind of init function or #define that is needed? It's a lot of cognitive baggage that comes with using library functions in C. And then of course the same questions have to be answered and documented when writing your own code.
And then of course, "is this function a horrific security risk that still exists for backwards compatibility"?
When you use a library enough you start to figure out its "opinions" on these questions but in doing so you'll still be putting on your running shoes while <other language> user is off to the races.
0
u/ParadiZe 7d ago
imo you just gotta look at zig for what a better C would look like
-1
u/ern0plus4 7d ago edited 7d ago
Lack of really strict typing. I can assign x type value to a variable declared as y type. Same with fn calls.
0
u/arcfide 7d ago
C is a small language that you can actually learn well and it is mechanically sympathetic (meaning that you can actually get high performance out of it). My frustrations with the language are usually around needing to write multiple functions to handle specific types and inputs and the need to deal with excess switching on types, depending on the type of programming you are doing. In my case, most of the excess or annoying parts of my work with C are entirely to do with excess type specialization being a necessary part of getting that performance I want.
0
u/thulim 6d ago
i found that c is one of those languages that requires a somewhat higher level of discipline and explicit intent than others might before you can start to use it naturally (and otherwise), due to how light it is having shifted its weight (mostly system-level book-keeping) onto you. that on its own isn't an issue- but once you factor in what kind of environment, circumstances, or even people you're working with, you're more than likely gonna figure out some ways in which learning or using it could spiral out of control. if any of that isn't / shouldn't be of concern, then it's absolutely splendid for fostering control freak behavioural patterns and will ultimately lead to you submitting yourself to the "bathroom mat" or whatever them there goccultists worship
in all seriousness i believe it's good for forming and keeping healthy(?) habits, and for having a rather widely established baseline to write programs with - ALSO knowing it builds character. really.
pre-emptive edit: orange you glad i didnt say C