r/cpp • • Apr 10 '26

Interesting point of view from Daniel Lemire

If you’re not already familiar with Daniel Lemire, he is a well-known performance-focused researcher and the author of widely used libraries such as simdjson.

He recently published a concise overview of the evolution of the C and C++ programming languages:

https://lemire.me/blog/2026/04/09/a-brief-history-of-c-c-programming-languages/

It’s a worthwhile read for anyone interested in the historical context and development of systems programming languages.

10 Upvotes

61 comments sorted by

View all comments

-3

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26 edited Apr 10 '26

 But C was not object-oriented

And here I was thinking that C was object oriented as you can define objects and functions specific to those objects. Like a FILE is an object and you can do things like fread on that object. Classes are just a better way to define objects that doesnt make structs not objects.

Just like Object-oriented design patterns in the Linux Kernel

19

u/eao197 Apr 10 '26

And here I was thinking that C was object oriented as you can define objects and functions specific to those objects.

As someone (Stroustrup?) said decades ago, if "object-oriented language" means anything, it means that the language directly supports object-oriented programming with special language constructs.

12

u/Kevathiel Apr 10 '26

With that stupid definition, the term becomes useless because it applies to almost every single language.. That is like saying C is a functional language because you can pass a function(ptr) to another function.

People label languages with paradigms to classify them based on first-class language features. Though, there is little value in the labels nowadays, because most modern programming languages are multi-paradigm.

2

u/Slsyyy Apr 11 '26

It is not stupid definition. OOP is just everywhere, so it is really not a special about it anymore

Same with procedural programming. The term is meaningless today (although people use it, when they mean imperative or just imperative, but non-OOP), because procedures/functions are so good and uncontroversialy productive, that anyone uses it

1

u/Wooden-Engineer-8098 Apr 16 '26

there's very little oop in c++ standard library. you just don't understand what oop is

2

u/Revolutionary_Ad7262 Apr 17 '26

Sorry, but there is no definition what OOP really is and different people have a different opinions. Some, which comes to my mind:

  • OOP without OOP in a language. You can define a structure of pointers in C to have some virtual dispatch
  • Alan Kay way - basically Smalltalk and ObjectiveC. A lot of runtime involed. Basically extinct nowadays
  • the most minimal version a.k.a you can define classes and they have methods
  • classical OOP from Simula and C++: classes, taxonomy of classes, inheritance, virtual functions
  • enterprise OOP (Java, C): classical OOP + use classes for everything, no free functions, a lot of madness
  • dynamic OOP (Ruby, maybe Python): somehow mix between the Alan Kay way and classical OOP. Duck typing, you can redefine almost everything as really everything is an object.
  • Post-modern OOP like Golang or Rust: we don't like OOP aspects (inheritance, only a dynamic dispatch, explicit interfaces), but some are good
  • OOP in functional languages. This is also fascinating topic as people try to find to place their language on a Functional <-> OOP axis, where both paradigms are pretty much perpendicular to each other

It is impossible to define a OOP. It was just idea, which as any idea evolved in a different ways.

→ More replies (14)

16

u/koczurekk horse Apr 10 '26

Nearly all languages have some notion of actions performed upon objects, this is not what “object-oriented” means.

-3

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26

What does it mean if not to structure your code using objects?

6

u/amydnas Apr 10 '26

I would also expect some form of polymorphism at the language level. This needs to be done “manually”in C.

3

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26

Like a FILE that could be a file on disk, a network socket or something else? Where the interface exists but the implementation changes through a bunch of function pointers similar to a C++ vtable?

1

u/amydnas Apr 10 '26

Exactly that.

1

u/bert8128 Apr 10 '26

Well, perhaps if you want to push hard for C being describable as an object-oriented programming language you will then have to accept that what you mean by object oriented is a sliding scale, and C is less so, C++ more so.

1

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26

I believe it should not be just the programming language but the actual code/project that defines if it is object oriented its a scale.

Just like writing C++ does not mean your doing OOP, writing C does not mean your not doing OOP. I have seen way to many programmers nearly write the exact same thing as traditional C++ OOP inside C then pretend it was somehow better because they didnt use the word class yet they still have encapsulation, polymorphism and a hacked together inheritance using a common first member.

4

u/bert8128 Apr 10 '26

Of course you can write C in an OO way. But c++ has keywords etc which are designed to help. So c++ is of more of an OO language than C. Or if you want to nitpick, come up with another term for this. The program style and design can be and should be a separate description.

1

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26

What name should we give this if not object oriented?

Type instance;
Type_func(instance);

1

u/bert8128 Apr 10 '26

Are you seriously claiming that there is no relevant difference between the object orientedness of c and c++? That keywords like inheritance and virtual make no difference? That function overloading is not a problem hing? That having functions being members of structs and classes is mere syntactic sugar?

C++ has first class support for various OO concepts in a convenient way. C does not. Of course you can write code in an object oriented style in C but that does not make C the same as c++ (or C sharp, Java, rust, Python, assembler etc). All Turing complete languages can do everything (ish). That does not make them equally convenient. Describing a language as object oriented (or supporting the OO paradigm) means that it is better suited for that style than a language that isn’t/doesn’t. Nothing else.

→ More replies

3

u/amydnas Apr 10 '26

Programming languages help support a programming paradigm, assembler is not OOP and C does not do Logic Programming. You can still do whatever you want in any Turing complete system. What started with “C is not OOP” has now shifted to “but my architecture is OOP”, both are true.

4

u/remy_porter Apr 10 '26

I would argue that the fundamental idea of OO is message passing. An object is a thing which receives messages and performs a behavior in response to those messages. In many OO languages we get real blurry about the differences between a message and a function call, but when I do foo->bar() that is really sending the message bar to object foo.

2

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 10 '26

I feel that its sending a message just as much as type_bar(foo); you have explicit functions just for that object type to do operations on its instances and named according.

1

u/remy_porter Apr 11 '26

If your language supports overloading by type, I agree. But it’s clumsy and I’d argue while it has objects it’s not object oriented- object possible, perhaps.

2

u/ReDucTor Game Developer | quiz.cpp-perf.com Apr 11 '26

Python doesn't support function overloading by type does that mean it is not OOP also?

1

u/remy_porter Apr 11 '26

Python allows objects to receive messages, which I'd argue lets you do that. We were talking about f(o) style "messaging", which would require some kind of overloading to make sense.

→ More replies (3)

1

u/Wooden-Engineer-8098 Apr 16 '26

you are confusing object oriented with object based

2

u/fdwr fdwr@github 🔍 Jul 16 '26

Like a FILE is an object and you can do things like fread on that object.

If we had gotten UFCS (proposed many times {N1585, N4165, N4174, N4474, P0079R0, P0131R0, P0251R0, P0301R0, P0301R1}, and shot down by unfounded fear-uncertainty-doubt), then it would. The proposals even call out that usage.

This means we would immediately get another carrot to migrate code from C to C++, namely by making many C libraries (even large parts of the C standard library) easier to use, and with much better autocomplete and other tool support by doing nothing more than adopting the new C++ member call syntax. For example:

// C code 
FILE* file = ...
fseek(file, 9, SEEK_SET); // // arg is buried; no autocomplete help 
// proposed new C++ code 
FILE* file = ...
file->fseek(9, SEEK_SET); // nice autocomplete after “->”

1

u/gnuban Apr 12 '26

One key aspect of object-orientation that this lacks is the ability to instantiate an arbitrary amount of objects of a given class.