|
|
|
|
|
by uecker
12 days ago
|
|
You can build types around structures and access them via wrappers. This works perfectly fine for many abstractions. Sure, one can break those abstractions, but not accidentally, and this is true also in other languages. Update: In fact, you can also build quite reliable abstractions around incomplete structure types. Those abstractions are better than what C++ adds, where the abstractions in the header are all very fragile. |
|
For example: suppose you need a container to hold ints. But it also needs to be able to hold other types. In C++ this is trivial, as in virtually all modern languages. In C this is impossible.
You can have a generic memory backed storage + accessors. But if you rely on void pointer functions, you have to remember every time to cast and pinky promise to only store one type. It’s very, very easy to make a mistake, and you will.
Most abstractions that we take for granted in modern languages are straight up not possible in C, or at least they are extremely incomplete. Part of that is because you can’t get C to do anything automatically. Every function call must be manual.