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.
97
u/Humble_Anxiety_9534 Oct 19 '26 •
large projects in C? what about linux?!
66
u/ArtOfBBQ Oct 18 '26
I also was told a lot of complete bullshit when I started programming and it cost me years of progress
50
u/DDDDarky Oct 18 '26
There are no limitations in what you can/can't do in either of these languages, there are certain (dis)advantages, for example with C you get smaller stdlib size, with C++ you get powerful rich language features.
22
u/IdealBlueMan Oct 18 '26
Handling complex C projects is a whole art form. There are a lot of writeups about various approaches.
Typically, you’d create a directory structure with a shallow tree for each of the chunks of source code, and one or more directories for headers.
You’d generally have one place for executable files.
Each module would typically have its own makefile, and a top-level makefile to build the overall project.
16
u/jacobissimus Oct 18 '26
Outside of systems programming or things where you have to be able to visualize the resulting binary shape—there’s the portability. All languages know the C abi, so if you want to provide something to connect to a FFI that’s a ton easier, or if you want to target arbitrary architectures.
13
u/LordRybec Oct 19 '26
I don't find C++ easier to use than C. I find the supposed quality of life improvements to make the code harder to follow and especially more difficult to debug. When working with code written by someone else, I find that C code is generally written to a higher standard of quality and is easier to read than C++ code.
Now, this doesn't mean everyone has the same experience that I do. I know people who prefer C, some of who prefer C++, and some who don't like either. The reality is that "better" is somewhat subjective. I'd hate to do say, a scientific calculator in C++. Neither language is significantly better when it comes to string parsing. I see no benefits in using objects for such an application. I've actually written a graphing calculator in Python, and when I was much younger I wrote various types of graphing applications in QBasic for fun. The QBasic examples graphed specific functions and only took numerical inputs, but the Python one took full math expressions. Python has excellent text parsing capabilities built in. That part would be a lot more complex in C or C++. The supposed quality of life improvements in C++ wouldn't make any difference, aside from having to write a lot more code with very limited benefits if I wanted to use them. I don't know that I'd particularly want to do a graphing calculator in C, but I'd certainly prefer C over C++ for it.
Honestly, a lot of it is personal preference. C does have some distinct advantages, but they won't matter most of the time. Most of the features of C++ that people seem to like cost significant extra memory and processing time, and some can cost a lot of CPU time, causing the CPU to wait for cache/memory interactions. In general, C performs significantly better. But, unless you are writing code for embedded systems or ultra high performance applications, it won't matter. C++ objects maintain pointers to function tables, and those pointers cost extra memory. The typical object may use between 1% to 10% more memory than a similar struct due to the this. The way memory is organized within objects tends to cause cache memory to load entire objects even when only one or two member variables are being used, which increases cache misses, which costs a lot of CPU time waiting for memory to be loaded into cache. The use of function tables means that calling methods of objects costs at least two pointer lookups from memory, where calling a normal function that takes a struct would have the function call hard coded with no pointer lookups. Operator overloading makes function calls look like basic math operations, so you may not realize just looking at the code exactly how much it is actually doing. But again, if your program isn't already using a lot of memory and CPU time, these aren't going to make much difference. Modern CPUs are fast, modern systems have a lot of memory, and as long as you aren't being blatantly wasteful or completely careless, you program will work fine and won't even use enough resources to impact other processes on the same system. Maybe you find the C++ syntactic sugar additions to be more to your liking than I find to them to mine. If so, then maybe you'll like C++ better.
That said, if you are programming embedded systems, the increased costs of C++ can add up quite fast. You may not have to worry about the cache coherency issues (most embedded microcontrollers don't have cache in the first place), but having to do extra pointer lookups and maintaining function tables make a much bigger difference on a 8MHz to maybe 125MHz or so processor with anywhere from 500b to maybe 8MB of RAM. When working within resource constraints like that, the difference between C and C++ can be quite noticeable. It does still depend on what you are doing, but it's something you do need to consider. If nothing else, it can be the difference between managing the project on a 25¢ microcontroller and a microcontroller that costs a dollar or two. The price difference might not matter for a hobby project (though, what you happen to have lying around might matter), but for a professional project that you intend on selling copies of, it can be a huge difference. So sure, a lot of embedded stuff can be done in C++, but there are often good reasons not to even on systems where it can.
Anyhow, my personal preference is C, and I don't find the "quality of life" features of C++ (or even more recent C standards) to actually improve my quality of life, but your mileage may vary. If you want to learn C++, go ahead. It's unlikely to hurt. But go into with some introspection. C++ advocates will tell you that C++ features are a huge improvement. Don't blindly believe them. Pay attention to how they actually impact your workflow and judge them by the results you get out of them. In this field its easy to get sucked into the "newer is better" thing, but in my experience newer is often less stable, more experimental, and often different just for the sake of being different. There's a reason C is still being used even in new applications despite its advanced age. It's a very strong and powerful language, which has withstood the test of time extremely well. It's not perfect, but if it didn't have significant advantages, it wouldn't still be being used for new work almost constantly.
9
u/SwordsAndElectrons Oct 18 '26
That depends on what you mean by embedded.
A x86-based kiosk? Sure.
Modern 32-bit microcontroller? Probably, yeah.
Ancient 8-bit microcontroller? Probably not.
Even though an x86 PC isn't what most of us mean when we say that, all of those can be termed "embedded."
9
u/Snarwin Oct 19 '26
Even if you intend to eventually use C++, learning and understanding C will make you a better C++ programmer (and, many would say, a better programmer in general).
The main difference between C and C++ is that there are many features in C++ that allow the compiler to do things for you automatically that, in C, you would have to do yourself, by hand. If you use these features well, they can save you a lot of time, but if you use them poorly, they can make your code difficult to understand and debug. Even for experienced C++ programmers, it is often the case that what you think the compiler is doing is different from what it is actually doing.
The best way to understand what the C++ compiler is doing for you is to practice doing the same thing yourself, by hand--in other words, to take a program that uses a C++ feature like classes, or
std::vector, and rewrite it in C. And in order to do this, you will need to have a good foundational understanding of C to start with.3
u/tastygames_official Oct 18 '26 edited Oct 19 '26
even though they are very similar, they are almost worlds apart, simply because of the (trap) doors C++ opens up with OOP. With C you really can only do imperative programming (of course there is a way to get into true OOP but basically at that point you're better off going with C++), but there is literally absolutely nothing you can't create with imperative that you can in OOP. In fact, I dare say the opposite might be true, as OOP limits you into how things can and cannot be done, so you have to break out of OOP in order to do some things.
Anyway, I love C because it's simple and the logic flows in the code just like it does on the processor (more or less). With OOP, you tend to abstract away the actual computer programming and instead end up focusing on hierarchies and structures and propagation and making all sorts of flowcharts just to be able to figure out where the program logic is. But with imperative, it's literally all right there: line by line.
I recommend learning both, but probably C first. Or if C++, don't start learning classes and OOP until a while later. I've seen programmers with decades of experience simply not be able to do the simplest tasks in imperative programming because they never learned it and can only think in the OOP way, meaning they only think about structures and controlling flow of data rather than the underlying functionality that those complex structures are actually doing. But the opposite is not true at all - imperative programmers have no problem learning and working with OOP. It's frustrating as hell because it's needlessly complex and takes much more effort to read, write and understand, and infinitely more time to debug, but it's very doable.
Do yourself a favor and dive deep into C - maybe even an older standard like C99 or even C90. Figure out how to do everything with that before moving on to "quality of life "improvements"" and "shortcuts" that later standards and higher-level languages offer.
But if after a month of working with C every day you really don't like it and find it too rudimentary, there is no problem with abandoning it and moving on to higher-level languages. Not every programmer needs to be a computer engineer or understand what's happening to the memory or on the CPU every tick. But at least learning about it and getting experience in it will always be a good thing.
8
u/trist007 Oct 19 '26
just use C, it's simpler, not many features. Use less dependencies and write your own. you learn more and can probably compile in 20 years
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.
4
u/InevitablyCyclic Oct 19 '26
On your last point, yes embedded is possible in c++. But embedded covers a huge range, from an 8 bit micro with a few k of memory to a full Linux system with masses of memory and an SSD.
Arduino is c++, that shows that even the low end can be c++ if you want to and aren't at the point of counting every single bytes and clock cycle. But for microcontrollers you tend then to use a very limited subset of the c++ features. Most (if possible all) memory allocation and object creation is done on startup and forget about using exceptions. It's more c with objects than desktop c++.
1
u/Bona_Fide3 Oct 22 '26
Why bother learning to code? It is useless.
3
u/Cats_and_Shit Oct 19 '26
In terms of a final executable, there is little to no difference in what you can produce between the two languages.
However if you're talking about libraries then there absolutely is. You can reasonably create complex, reusable data structures with C++ templates that can't reasonably be created in C; and you can write abstract code using things like OOP features and operator overloading that you couldn't in C.
How much any of this matters depends a lot on what you are building. In practice it seems like UI libraries benefit a lot from this kind of thing, but for most other's it's a wash if actually helps or not.
6
u/UltimatePeace05 Oct 18 '26
In my, and many in the handmade community's opinion, C++ is just C with templates. Modern C++ features are horrible and full of traps. The standard template library is, I guess, better than C's stdlib, but not by much... Which is kind of impressive, since C's standard library is horrible.
The advance of C++ is just that you can define a Dynamic_Array, Slice and Map template structs and then you don't have to deal with weird macros and codegen... everything else is, imo, extra... (if those 3 were actually in C, I would say that C++ has no significant advantages)
But I also use C over C++, so take my absolute hate speech here with a grain of salt...
2
u/thecratedigger_25 Oct 19 '26
I code C++ like it is C but I encapsulate them in namespaces and use the more modern features to make the code more compact. Preferably C++20.
Keeps the code organized and simple than just doing oop. C makes it easier to learn C++ and get into data oriented design.
2
u/Classic-Rate-5104 Oct 19 '26
Start learning the basics in C, for example structs, pointers, arrays etcetera. C++ is too overwhelming to start with
1
u/randomguy4q5b3ty Oct 21 '26
I'm sorry, but what exactly are your goals?
1
u/Plus-Dust Oct 22 '26
You can use both for big projects or small, embedded/kernel or application development (e.g. GTK is C native). Personally I use C++ and just opt into the features you want--you can write C++ with no double-colons in sight that's almost like C with more features, so I don't see a ton of downside in choosing C++. There are a few edge case instances where C has alone gotten envy-producing syntax that C++ hasn't, but not much ime.
1
u/d954mas Oct 22 '26
C is awesome. Simple, eady to understand. C++ in big projects is much harder then c
1
u/NoSpite4410 Oct 22 '26
C is writing hardware commands. Every C statement touches hardware.
Keep that in mind, because then you can do anything, and everything in C makes sense.
C is for creating binary interfaces. Data is binary bytes to C, and that is all it is.
All the data-centric stuff is built on top of the binary interface.
OK there are numbers and math and some help for strings, but it is still just bytes and memory and instructions on how to move them around and change their values.
C++ is primarily for creating object interfaces (in binary mode). Instead of passing bytes, you are passing objects and converting them into data and treat them like little mini-programs each that can do its thing and consume and produce other objects and data.
C++ is all that plus an object layer, and a type systems that understands objects.
The C++ compiler does auto-generation of all the basic object creation, assignment, destruction, and ownership functions for you, unless you make your own, and does
some auto-initialization that C does not.
The C runtime is the leanest and fastest around, so it leaves most things up to the coder to implement.
The C++ runtime is a lot fatter, but about the same speed for most stuff, because it uses the same compiler and libc for I/O.
C structs are just passive transparent aggregate consecutive contiguous regions of memory.
A C++ class is mostly just a C struct with a bunch of function pointers in a virtual table in the runtime that it chooses based on the object model ( binds functions to class types).
This is important, because C libraries pass structs to C++ code all the time in system libraries, and they are binary compatible.
1
u/Antique_War_9814 Oct 23 '26
You are confusing language with platform portability. Posix ect...
1
u/m_yasinhan Oct 24 '26
it is not called limitations. They are design differences, and what makes C a minimal and beautiful language.
1
u/Low_Lawyer_5684 Oct 24 '26
It is nearly impossible to learn C++ without learning C first. If you are fluent in C, then you can learn C++ as a "better" version of C.
1
u/noobyscientific Oct 19 '26
Limitations with a language, that literally talks to the memory and processor, literally don't exit. C can do anything, and I mean literally anything.
Thing you probably interpeted as "limitations" are likely things that would be harder to do in C than C++.
You can use any language for your idea, but C++ might be the way to go.
1
u/TheTomato2 Oct 20 '26
The problems with C++ become apparent when you become an expert, you ask yourself "why would you design it like this, I would rather just go back and use C like a caveman."
However most of the things you seem to think matter don't really matter. Classes and OOP don't really matter. You can do whatever you want either way. What does matter, poorly designed or not, is C++ has meta programming built into the language and you can use it for generics. With C you have do some stupid macro or typless stuff to even come close to emulate it.
Everything else is done leagues better in other languages than C++. There no "limitations", language features about convenience and time and possibly security and nothing else. Your "language" is just a translation layer for a, compiler to spit out assembly, there isn't like a "limitation" there in these lower level languages.
1
u/QuirkyImage Oct 20 '26 edited Oct 20 '26
You can do anything in C there are ways to implement features of C++ but sometimes I think the beauty of C is not having to use them in the first place. You cannot get much more complex than the Linux Kernel. But I would still choose what I consider the best language for the job for example there are areas of network based software where I would jump straight into GO.
0
u/timrprobocom Oct 18 '26
It's not a technological limitation. Anything possible in one can be done in the other. Remember, the C++ compiler used to be a front end that generated C code to be compiled.
It's concepts. C++ allows you to express more complicated concepts in a more natural way. That's very soft and fuzzy, but it makes for better programs with less programmer effort
0
u/olorochi Oct 19 '26
C++ has a lot of features, some of which cannot be reproduced exactly in C. However, these tend to come with pitfalls.
OOP is the classic example, and is quite easy to reproduce in C. The most challenging part is polymorphism, which can be achieved in C by manually creating vtables.
QoL features like RAII (automatic calls to constructors and destructors) tend not to be reproducible, but they don't affect the resulting binary, only the way the code is written. In my opinion, at least in the case of RAII, C is actually less error-prone than C++. Debugging a missing call to a custom deconstruction function or just free is far easier than fixing a badly written C++ deconstructor that fails in edge cases because it's copy constructor actually has move semantics (look into the history of std::auto_ptr). Another (far less controversial) example of this are templates. Whilst it isn't particularly difficult to reproduce basic template functionality in C, it does require a lot of copy-pasted code or particularly nasty macros.
Exceptions can be reproduced, though with difficulty, at a syntactic level, but C is not powerful enough to allow a resulting binary identical to what modern C++ compilers typically generate. Creating basic try, catch, throw and finally macros using the functionality from setjmp.h is not too difficult, but can easily cause memory leaks or dead file descriptors if the jump skips stack frames that contains ressources to deallocate. C++ compilers usually address this issue by embedding the information the program needs to find the relevant deconstructors of a stack frame in a dedicated section of the executable, which C compilers have no knowledge of. One solution would be to catch and throw again in every scope that must do clean-up, but littering code with catches is generally bad practice.
Another area where C falls short of C++ is reflection and compile time execution. The C++ standard library provides some functions that typically rely on compiler hooks for their implementation such as is_enum or is_class. As of C++26 there even is a proper reflection operator yielding compile time values: ^^. C++ programs can also branch and call some functions at compile time. Meanwhile C23's constexpr is just a way to create simple constants that could be used as an array size for example. These features are all just QoL, but allow for far more concise code in some cases.
-1
u/rubidus-api Oct 19 '26
I'd like to share a somewhat related experience of my own.
I'm an amateur programmer, and recently I've been experimenting with creating a simple systems programming language with the help of AI. There's no practical goal behind it. I was just curious about what AI could do, and I thought it would be fun. Along the way, I've been reminded of just how difficult it is to define the rules and constraints for even the most basic data types.
When designing integer types, the obvious approach is to define them by their bit widths. So I introduced unsigned types like
u8,u16, etc., and signed types likei8,i16, etc. So far, so good.Then came the question of how these types should interact in arithmetic expressions.
Having learned from C just how troublesome implicit conversions and differing integer ranges can be, I decided to introduce two keywords,
narrowandwiden, for explicit conversions. Arithmetic would only be allowed between operands of the same type, and everything else would be rejected. Still manageable.Then I needed types for sizes, indices, and pointer differences. In C, we have
size_tfor object sizes andptrdiff_tfor pointer differences. But what should their widths be?I wanted my language to support everything from 8-bit microcontrollers to 64-bit and potentially wider architectures. Simply using
u64everywhere wasn't an option. So I ended up introducingusizeandidiff, with implementation-defined widths.And then I ran into another problem.
Suppose
usizeis 16 bits on one platform and 64 bits on another. What happens when you need to perform arithmetic involvingusizeandu32? Should you usenarroworwiden?The answer depends on the target architecture. A conversion that can preserve every possible value on one platform might lose information on another.
So I needed yet another keyword,
cast, for conversions that don't fit neatly into either category. Actually, the AI had already introduced that keyword for something else. But even with it, deciding exactly what should happen in each situation is far from straightforward.And that's where I am now.
There are still plenty of unresolved questions. Different architectures have different natural integer widths and different performance characteristics. Is it really a good idea to use explicitly sized types like
u8throughu64for everything? Should I introduce architecture-dependent integer types like C'sint? And if I do, how should all the arithmetic and conversion rules work?I haven't even started on pointers yet.
Different pointer types may have different representations and sizes, and architectures like CHERI can have pointers that are wider than the native integer word. The compiler should ideally be able to generate efficient code for all these cases.
I've been having AI research how existing languages handle these issues, and I've spent quite a bit of time thinking about the trade-offs. But making these decisions is surprisingly difficult.
And I have this uncomfortable feeling that, after working through all these problems, I'll eventually end up creating yet another language that makes almost exactly the same compromises as C.
Anyway, that's my recent experience. Now, here's how I think it relates to your question.
C isn't a particularly large or complicated language, at least compared to C++. But it runs on an enormous variety of platforms, and its specification contains a surprisingly intricate set of rules and compromises intended to balance portability, efficiency, and implementation freedom.
Sometimes those rules interact in unexpected ways, as anyone who has encountered bugs involving strict aliasing or undefined behavior can probably appreciate.
The C++ standard is roughly two thousand pages long. Can programmers and compiler implementers really keep all that complexity under control, especially when building something like an operating system that needs to work across many architectures with very different characteristics?
And what about massive projects whose source code must be maintained for decades? How easily can they accommodate a language that evolves as rapidly as C++?
I don't think C++ is a convincing replacement for C in all those environments. Personally, I'm not particularly fond of C++ anyway, so I'll admit there's some bias here. :)
What about newer languages like Zig and Rust?
They're already doing impressive work, and I expect them to continue taking over areas traditionally dominated by C. But I don't think we're quite at the point where they can replace C across its entire range of applications.
This isn't necessarily about raw execution speed. Rust and Zig can generate very efficient machine code. It's more about the maturity of their toolchains, the breadth of architectures and environments they support, their long-term stability, and how much control they give programmers over the resulting binaries and their dependencies.
C has had decades to develop its compilers, ABIs, libraries, and platform support. Replacing that entire ecosystem is a much bigger challenge than simply generating fast machine code.
I suspect newer languages will eventually catch up in more of these areas, just as C compilers themselves matured through decades of optimization and refinement. But for now, I think C still has some time left.
So here's my conclusion.
C occupies a rather awkward, subtle, and strangely well-balanced position that's difficult to explain in a few sentences.
Its portability rules, undefined behavior, minimal abstractions, integer types, memory model, and close relationship with hardware can all seem rather clumsy. Some of its compromises look almost arbitrary, and some are genuinely unpleasant.
But when you start facing the same design problems yourself, you begin to understand why those compromises were made, even if you don't necessarily agree with them.
It's not that C is an ideal language. Far from it.
It's that C has settled into a peculiar position where almost every apparent flaw is connected to some other constraint or trade-off. Fixing one problem often means introducing another.
And there it remains, somewhat awkwardly, but remarkably firmly.
Not because it's perfect, but because finding a replacement that preserves everything people value about it turns out to be much harder than it looks.
-4
u/I_Messed_Up_2020 Oct 19 '26
As the century progresses I think knowing C++ will give one a more diverse employment landscape.
Here is the view from an AI perspective provided by AI.
Frontier AI models (like GPT-4, Claude, or DeepSeek) are not written in just a single programming language. Instead, building and running them requires a multi-layered software stack where different languages handle different parts of the pipeline:
1. Python (The Orchestrator & Research Language)
2. C++ (The High-Performance Engine)
3. CUDA & Triton (The Hardware Accelerators)
Summary
If you look at a frontier AI lab's codebase, you will see a blend: Python on the surface to glue experiments and training scripts together, driven by C++, CUDA, and Triton underneath to handle the blistering computational demands of matrix multiplication at scale.