r/C_Programming • u/Ok_Reserve996 • Oct 18 '26
C limitations
Hi all,
I am currently learning c++. Its okay. Not sexy but also not as bad as some say.
The reason I am learning c++ is that I have read that C has limitations as soon as a project gets more complicated. For example, if you make a scientific calculator with many features like graphs etc.
Trading engines/tools are also not recommended to programm in C.
Since I have not learned C and have only read from some old forum posts etc, I cannot confirm/deny these facts.
I am aware that "everything" is possible and that C++ comes with QoL improvements especially with Classes. But I assume that doesn't mean that someone has to use C only for kernel work. Embedded is also possible with C++ right?
I would appreciate your thoughts and opinions.
The goal of this post is to understand how and if C could fit me more with my goals and what real advantages or disadvantages C has.
View all comments
Show parent comment
1
u/LordRybec Oct 19 '26
Operator overloading is a two edged sword. If it is being used with types where it makes solid and obvious sense, it can be really good for making code more compact and readable. A lot of C++ programmers think it is slick to use operator overloading where it doesn't make obvious sense, and that creates two major problems. While still makes code compact it reduces readability substantially. A common problem with operator overloading, regardless of whether it makes sense or not, is that just looking at the code doesn't tell the reader what's actually happening. The operator implicitly calls a function, and unless you are already aware of that, the syntax doesn't indicate that it's doing that. That can be an absolutely massive problem for debugging. As people like to mention a lot, bugs often manifest sometime after the code where the bug actually is, so the crash or bad behavior is unlikely to happen within the overloading function. Tracking down a bug in a + operator for a particular type is always going to be a challenge, because + doesn't look like a function you need to look into, and which + function you need to look into isn't obvious from the like it is called in either.
Ideally a good implementation of operator overloading would include some syntax identifying that this is an overloaded operator, not a native one, and preferably also identifying what type that operator belongs to. But once you have all of that, the syntax is more complicated than just writing an
add_widget_woozle(int x)function.That said, platform based function overloading isn't a terrible idea. Currently we use #define filters, but if there was say, some set of function attributes, where you can specify the platform and OS, and then the compiler would ignore the function if it isn't for the target platform, that would be really handy. That would allow for making a series of functions with the same name but filtered for platform by the function attributes, where each function is for a different platform. Of course, each function would have to be fully exclusive of all others in terms of attributes used, to avoid a situation where there's a platform that two or more are valid for. That would, and should, cause a compile error for multiple function definitions. But such syntax would simplify the code and improve readability, by eliminating the need (at least at the function level) for long
#ifdefblocks where it's easy to miss the#endif(or worse, where you have nested#ifdefs inside such that the#endifs are confusing).---
Honestly, your idea isn't bad, but I'd generally hesitate to use operator overloading instead of a well named function, just to keep debugging easier. If my code is calling a function, it should look like it is calling a function. If you skipped the operator overloading and allowed for optionally specifying a platform/OS for each function though, function overloading for portability would be pretty awesome! (And let C++ add the same thing, that works with operator overloading, if it wants to.)