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

2

u/LordRybec Oct 19 '26

You should learn Haskell. That should help you separate "functional" from structured procedural programming. Having functions does not make a language "functional". In programming terms, "functional" refers to functions in terms of math not in terms of subroutines. Programming borrowed the term "function" from math and then blindly applied it to subroutines due to largely superficial similarities. What you view as "functions" are not actually functions. They are programming subroutines that we've incorrectly applied the term "function" to. In a programming context, when you say "function" we all understand what you mean. But when you say "functional", that means (even in programming terms) languages modeled after actual mathematical functions rather than just programming subroutines. Languages like C and C++ are not even remotely "functional" languages and do not use "functional programming". What they use is called "structured programming", which is a subset of imperative programming.

"Procedural programming" technically includes structured programming and functional programming, so it's not a useful distinction here. Structured programming includes subroutines, functions (by the mathematical definition), loops, etc..., which both structured imperative languages and functional languages both have. So C is procedural but so is Haskell, Lisp, and other functional languages. The correct term here is imperative. C is imperative, Haskell is functional. Both are procedural. (Technically functional languages are also structured, but we don't generally called them that. The term "structured" was originally used in programming to distinguish between functionless languages like assembly (which also doesn't even have formal loops) and some versions of Basic and languages like C that have functions and formal loops, all of which are imperative.)

Anyhow, if you say "functional" in terms of programming languages, that term means languages like Haskell, Lisp, and others. It does not mean languages that have subroutines which we've collectively applied the term "function" to, even though they are rarely actually true functions. So if you insist on using the term incorrectly, expect to continue being corrected and misunderstood.

I'm not trying to be rude here, but when people within a community insist on continually using well established terminology incorrectly, it hurts all of us.

1

u/tastygames_official Oct 19 '26

yeah, I know the difference, but I just like the play on words. Like how a knife is "functional" as it "serves a function", so is it in my mind with "functional programming": you write commands and procedures to serve a singular function (change some data, save it to disk, send it across the internet, change the color of an object on screen, etc). But I know that in computer science they mean something else.

I just prefer logical steps instead of "magic" stuff that happens due to structure. I actually like wikipedia's example on imperative vs. functional: https://en.wikipedia.org/wiki/Functional_programming#Imperative_vs._functional_programming

# imperative
int[] numList = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int result = 0;
for (int i: numList) {
    if (i % 2 == 0) {
        result += i * 10;
    }
}

# functional
import java.util.Arrays;

int[] numList = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int result = Arrays.stream(numList)
    .filter(n -> n % 2 == 0)
    .map(n -> n * 10)
    .reduce(0, Integer::sum);

so I can see how somebody who is not a programmer will like the functional one more since it reads like a human thinks: "ok, so we we take our list of numbers, then filter them by whether they are even or odd, then multiple each of those by 10, then sum them". But this is too high-level for my taste as you don't know exactly what's happening each step of the way. While this is fine for a simple example like this, in real life when we need good performance and scalability, knowing exactly how each of thse steps of the process work is CRITICAL. And if, for example, we need to modify one of the steps in this process, it becomes a Herculean task as each function is built on top of another function in another class and implementing another interface and so you really have no other choice than to go to imperative programming to get your custom code to run. Either that or stick with the hierarchical logic of functional programming and extend the logic tree to create a superset of commands that now can be controlled via a flag or maybe it's a whole new implementation or something. It drives me absolutely insane when I know EXACTLY what needs to be done but have to fight with some kind of hierarchical abstraction to get it to do what I want. It's like knowing that the fish has to go into the frying pan but all you have are ways to put it in the oven. The burner is right there, as is the pan, so just use them. But instead you have to define a new class that can either be a stovetop or an oven and then a baking tray or a pan, and then make sure they all have implementations of the cook() and check_doneness() functions that are inherently way different but because we need this hierarchy, we must shoehorn our log into this structure. And god forbid we want to bake the fish in the oven and finish in the pan for crispiness - now we have to abstract the cooking process to include a "Listable" interface or something with each node being a step in the process that can be be potentialy infinite even though our use case is simply one or the other.

Anyway, this is giving me anxiety. Time to go back to "functional" (imperative ;-) ) programming in C. Have a nice day!

2

u/LordRybec Oct 19 '26

Ah, I see. Then maybe just make it more clear that it's a joke, so that people don't get confused!

As far as the rest goes, I generally agree. I really like Haskell, but I never use it, and part of the reason is not knowing what is going on under the hood. Most of my programming is low level stuff. Either it's full on microcontrollers, or I'm going super low level number manipulation. This is really easy to write and to follow in C. I can do complex pointer manipulation stuff to work with 8 or 16 or 32 bit partitions of 64 or 128 bit values, and it's still fairly easy to see what is happening. I don't even know if I can do stuff like that in Haskell. And in microcontroller programming, things like order of operations are really important, and I spend a lot of time manipulating registers and such. Order of operations isn't guaranteed in functional languages. I actually think I can do register related memory accesses in Haskell, with unsafe memory accesses, but it's basically imperative at that point anyway, and Haskell does not make that stuff easy. I wrote an Asteroid clone in Haskell, for my undergrad senior project (my idea, as I figured if I could do a real-time game in Haskell, I could do pretty much anything), and it actually wasn't too bad, but it certainly wasn't even remotely well optimized. I'm not sure I'd do a game in Haskell again, due to the optimization thing, but what I do for my daily drive/job just doesn't work in functional at all. Functional is like asking the system for the outcome you want, and then the compiler does its best to do it. That only works if the compiler understands the underlying hardware well enough to know how to achieve that outcome. With imperative you are giving it the steps you think will achieve what you want. That means bugs are more likely, but it also means you have 100% of the power available within the system/OS you are coding for.

So as much as I like functional, only imperative (and especially low level like C) can do what I need the way I need.

2

u/tastygames_official Oct 19 '26

I think I'll just go back and edit my comment to say "imperative" instead of "functional"