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

Show parent comment

1

u/tastygames_official Oct 18 '26

it's perhaps complicated to explain to a beginner, but basically a typical C functional programming snippet might look like this:

/* some function that modifies the cart */
update_cart_total(&cart);

/* check prices or something */
for(i=0; i<cart_size; i++) {
  if(cart->item[i].price <= 0) {
    cart->item[i].price = 0;
  }
}

So you just chug along and do one thing after the other and jump into functions whenever they are needed. But for OOP (which C++ tends to be, even though you technically don't have to write OOP) is more like this:

InputParams input_params = InputParamFactor::get_instance()->retrieve_input_params(user_context);
Cart cart = CartFactory::get_instance()->retrieve_cart_by_input_params(input_params);
cart.update();
CartIterator price_check = CartIterator::new({...bunch of data abstracting out the price check iterator logic instead of just programming it...})
CartIteratorHandle h_price_check = cart.add_iterator(price_check);
CartIteratorFactory::get_instance()->perform_iteration(h_price_check);

so you can kinda tell what's going on, but there's a lot of boilerplate stuff to make it all work within common modern paradigms and design patterns, so it just ends up making the code really hard to read. Notice how many extra functions you have to call and variables you have to create just to save yourself from writing out the logic by hand. The whole idea with these OOP design patterns is to have the structure do all the work so you only ever just pass around some configuration settings and everything just "magically" gets done. But the worst part is when you look into one of the functions to see what's actually happening it just looks like this:

void CartIterator::run(IteratorItem *item) {
  IteratorSettings settings = IteratorSettingsFactory::get_settings_for_iterator(item);
  return item->run(settings);
}

so it's a neverending chase to track down where the code is actually being executed as every function is written small and only ever does one thing so it can be unit-tested but this means you never have a full understanding of what's going on without looking through tens (if not hundreds) of functions and files just to track down what's going on.

Maybe I'm biased, but when I entered into software development as a career (after maybe like 10 years of doing it "just for fun"), I quickly was forced into doing everything the OOP way for a lot of stuff and it just really got to me over the years (decades, really), so I'm so super happy to be back in functional programming land where everything is right there in one place and the logic follows top to bottom rathe than having to look through an entire project just to find its entry point.

4

u/frasnian Oct 19 '26

Your contrived "c++" example is an abomination. No working professional would write code like that.

This is how you tell me that you don't actually know C++ and have never really used C++ professionally without actually saying that you don't actually know C++ and have never really used C++ professionally.

3

u/LordRybec Oct 19 '26

Lol! Yeah, I've seen professional C++ code just like that, from those with 5 to 10 years or more of experience. In fact, I've seen worse and then rewrote it in C myself to eliminate the temptation for someone "maintaining" the code in the future to turn it back into that kind of abomination. This is part of the reason I prefer C. There are a lot of bad C++ programmers out there who would write much better code in C because C doesn't leave room for writing code that terrible!

2

u/tastygames_official Oct 19 '26

I once rewrote a core API endpoint for a client that was causing some problems. They were using some framework and had all this "magic" dependency injection stuff going on and the guy who made it was super proud about how clever it was and easily extensible it was (it wasn't - it was only extensible if you had to do add another use case that already uses the same exact data format).

Anyway, it was very slow so I was brought in to consult, and for shits and giggles I rewrote the most complex use case as just a single, straight-shot program with no OOP, no framework - just literally data in -> process -> data out. I didn't even to any kind of optimization (paralellization, caching, more performant data structures) and got a 175x speed boost. I asked if this would be a direction they would like to go in, and the guy who made the system (CTO or head of tech or whatever) told me "that's not really programming!" He was as just as old as I was, and had a degree in something software-related, but seriously thought that unless you use some kind of hyper-abstraction paradigm it's "not really programming". Absolutely blew my mind.

Since then I've encountered more and more "software architechts" who seem to think that you need it to be complex and abstract in order to be "real". My guess is that it has to do with how they were taught - probably skipped the basics and went right to learning the frameworks/paradigms. The worst part? companies (and customers) seem to not care about performance or simplicity anymore. Sofware is continuously rolled out now so anything that doesn't work today can be fixed tomorrow and people are just OK with it.

3

u/LordRybec Oct 19 '26

Like people who think Python isn't a "real programming language". I mean, Basic was widely considered a real programming language, and it was interpreted as well. And modern Python generally isn't even interpreted. It's compiled to bytecode and then run through a sort of emulator. It's basically the exact same model Java uses, except that Python isn't so egotistical that it calls the emulator a "virtual machine", despite no such machine actually existing.

Yeah, anyone can write massive piles of code to do a simple thing. A real programmer can do the same thing in very little code. But too many people take far to long to understand that, and some never figure it out.

2

u/tastygames_official Oct 19 '26

perfect take on python/java ;-)

1

u/tastygames_official Oct 19 '26

it's a generic OOP, not necesssarily C++. But yes - most of my time in the last 30 years or so has been with Java, PHP, TypeScript, C# were the most recent and worst offenders. My last foray was a C++ project (godot) before calling it quits and moving over to C forever. But these design patterns hold true no matter what language. It usually gets that way when it's some sort of framework or platform that everyone uses and it's just awful because it's so generic and abstracted to hell.

Don't take offense - all languages have their merits but I'm just staunchly against OOP at this point in my life because it's always going to get abstracted to hell for the sake of "looking nice" rather than being functional or performant.

Object-Oriented Programming is Bad
"Clean" Code, Horrible Performance
Abstraction Bad? | Clean Code : Horrible Performance
The purest coding style, where bugs are near impossible