Appreciating C: Benefits of crudeness

classic Classic list List threaded Threaded
1 message Options
DFP
Reply | Threaded
Open this post in threaded view
|

Appreciating C: Benefits of crudeness

DFP
When programming, I keep gravitating towards C. It is still a mystery to me as to why precisely, but I would like to highlight one thing: it solves problems simply.

People complain about headers, and they can be a pain to manage; Sequential struct declarations can be a pain to lay out. I noticed that alternatives are more complicated in some ways. If you get rid of headers and allow non-sequential dependencies, the compiler has to resolve a dependency graph. Which I do not think is a trivial task, and seems to have structural implications. The benefit gained from convenience of non-sequential dependencies seems small, relative to the complexity introduced by having to solve a dependency graph.

Same thing with macros. I have seen people complain about how clunky they are, and how it is practically another language on top of C. However I think it is in fact more versatile than more embedded 'template' systems in some cases, while again being straightforward to implement. I can (ab)use macros to replace functions like 'malloc()' across the whole program to print out more information (like file name and line number), or even to introduce a layer of memory allocation tracking. And I can whip that up in a few hours to solve some specific problem I am having. Because they are so simple to be open-ended like that.

Other languages can have things that sound good in theory, but in fact can be way more restrictive, getting in the way of solving problems. C being crude like that, might in fact be a good match to the crude nature of some problems. Instead of being too idealistic and clashing with messy reality. But even besides that, "it might be wasteful expending 50% more effort to get a 90% solved problem to 100%." It may be a local maximum.