Appreciating C: Benefits of crudeness

classic Classic list List threaded Threaded
4 messages 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.
Reply | Threaded
Open this post in threaded view
|

Re: Appreciating C: Benefits of crudeness

Peter
Doing math calculations in game and graphics programming C is still the way
DFP
Reply | Threaded
Open this post in threaded view
|

Re: Appreciating C: Benefits of crudeness

DFP
From what I have seen, most engine and graphics programming happens in C++, not C. Godot Engine, Unreal Engine, Unity. Even Dwarf Fortress seems to be written in C++. Do you mean C would be better, but it is not used? Or do you have some engines and games in mind that in fact use C? Or, perhaps, you just meant 'C or C++'?

My point in the original post was that C specifically is noteworthy, and C++, while it brings various improvements, is also quite unrestrained. And thus, perhaps introduces more complexities than improvements. I have observed various codebases, including Unreal Engine and Godot Engine, taking quite a minimalist approach to utilizing C++ specific features, and maybe entirely avoiding the standard library.
Reply | Threaded
Open this post in threaded view
|

Re: Appreciating C: Benefits of crudeness

Peter
Yeah C/C++. Game engines require object oriented language. In lower level programming for graphics though, the functional features in C for math is enough