r/C_Programming • • 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.

51 Upvotes

114 comments sorted by

View all comments

8

u/Retropolis_1950 Oct 19 '26

IMNHO if you can't do it in "C" it can't be done.The entire trick with large projects involving multiple contributors has almost ZERO to do with the language in use. Defining the project structure and interfaces, as well as the protocols for source control and documentation are the elements of success or failure. Any thought that those definitions will be self driving should be banished immediately. Nothing happens unless someone puts their hand to it and you will need gatekeepers and moderators.

3

u/Maqi-X Oct 20 '26

This is not entirely true. There are many things you would do in other languages but wouldn't do in C because of the features it has and the features it lacks.

4

u/Retropolis_1950 Oct 20 '26

The choice of language based on features, Python for example, is a real thing. But, at the end of the day, that is a matter of convenience more than capability. Which is why I said what I said.

1

u/flatfinger Oct 19 '26

Many commercial C implementations intended for low-level programming are designed around the idea that actions which are not defined by the language will be processed in a manner characteristic of the environment, which will be documented if the environment happens to document it. The C Standard acknowledges this idea when it suggests that actions where it waives jurisdictions may be treated "in a documented manner characteristic of the environment", but fails to recognize an important aspect: implementations will often have no way of knowing which corner cases will and are will not be documented by the environment. Many people seem to think the Standard uses the term "implementation-defined behavior" for actions that many implementations should be expected to process in a manner characteristic of the environment, but that category is limited to actions that all implementations are required to define and document.

On many platforms, the only thing a programmer would need to do that isn't accommodated by standard C syntax would be to force a particular function or object to be placed at a particular address. While non-standard syntax may make some actions more convenient than they would otherwise be, and on some platforms the use of non-standard syntax might be unavoidable, many commercial compilers can do everything that needs to be done--with the one exception noted above--without any toolset-specific syntax.

Unfortunately, the C Standard has yet to recognize a distinction between implementations that behave in a manner consistent with commercial low-level C implementations, and those that treat the Standard's failure to mandate a corner case behavior as implying that the corner case isn't part of "real" C.

1

u/Retropolis_1950 Oct 19 '26

Which language(s) do you use that automatically detects those corner cases?

1

u/flatfinger Oct 19 '26

The language doesn't "detect" them. The design intention of C was that the semantics of p->foo +=5; would be, essentially, "Tell the execution environment to take the address in p, add the offset of foo to it, convert the value 5 to the type of p->foo, and either perform an operation that adds that to the storage at the indicated address (if the platform can do that in one operation), or read the contents of that storage, add five, and write it back." If p happened to hold an address of a structure of *p's type, the effect of that operation would be to add 5 to the value of member foo of that structure, but the implementation would instruct the execution environment to perform the address calculations and accesses in a manner that was agnostic with regard to any significance that address might have. If the execution environment specifies that it has a region of battery-backed RAM from address 0xC0001040 to 0xC000107F, p holds 0xC0001040, p->foo is a uint32 at offset 0x3C, then the above code would add 5 to a 32-bit value stored in addresses 0xC000107C to 0xC000107F inclusive.

1

u/Retropolis_1950 Oct 19 '26

I fail to see how your explanation is a corner case.

1

u/flatfinger Oct 19 '26

You wouoldn't view the possibility that the code might happen to access memory that the hardware might happen to have mapped to a region of battery-backed storage as an obscure corner case?

1

u/Retropolis_1950 Oct 19 '26

I would assume battery backed memory still needs to be managed and is read/write. If it's supposed to be write protected I wouldn't rely on the compiler to enforce that. Dealing with pointers, a real strong point of 'C', is fraught with potential harm. Almost all of which live in the runtime and not compile space. In critical environments pointers are verboten or at least should behave by MISRA conventions.

1

u/flatfinger Oct 19 '26

I would expect a low-level compiler to process actions which access objects through a pointer to be processed as imperatives telling the execution environment to perform the indicated accesses to the indicated addresses in a manner that was generally agnostic with regard to how the execution environment would respond. The compiler should generally neither know nor care about what information the programmer might have about the environment.

1

u/Retropolis_1950 Oct 19 '26

Your responses delve into the philosophical without clarifying your original assessment re: corner-cases. When you say "I would expect" it implies you haven't investigated the behavior of your chosen tools. To digress, I have looked at the code produced to see how the optimizer deals with a coding style and sometimes rewritten code to get a cleaner output. That said, modern tools are so good that is almost never needed but there are still coding paradigms that will produce better outcomes.

1

u/flatfinger Oct 19 '26

Some compilers require the use of toolset-specific syntax to achieve such semantics. Some compilers are not intended to be suitable for low-level programming tasks. If an implementation claims to be suitable for low-level programming tasks without documenting anything special a programmer must do to achieve the necessary semantics, I would treat those facts together as implying either that the implementation will support such semantics by default, or that it is lying about being suitable for low-level programming.

1

u/PyroNine9 Oct 20 '26

There is no corner case there. C (or C++) will emit machine instructions that will cause the processor to perform the specified transactions with memory. Neither knows if it's real memory battery backed or otherwise, or a register that will have side effects. That's for the programmer to deal with.

Other languages (Python for example) will not intrinsically let you assign a variable to be stored into a particular physical or virtual address (though you can implement Python functions in C that will handle it).