Is there a "C with classes" language that is not C++?

1.4k Views Asked by At

I'm looking for some kind of C dialect that is as minimalistic as C but has built-in classes support. So I can (and encouraged to) use macros, pointers to arrays and manual memory management but also create classes, add fields and member functions to them etc. This question appeared when I tried to implement some kind of OOP in C and typedef struct and function pointers do something similar to what I want, but "member functions" require to manually pass a pointer to the object as a parameter to them, and that's not what I want to do. I know that I can just write on C++ as on "C with classes" and I would, however C++ encourages a different programming style and I'm curious if there is something that is exactly what I want.

I was searching for "C with classes" but I've only seen C++ in results, so I expect that the answer is "just use C++" and I'm OK with that, but I'm just curious.

1

There are 1 best solutions below

3
Useless On

C++ encourages a different programming style

You can write C++ in whatever style you like. Just choose not to use the features (and libraries) that don't suit your C-with-classes aesthetic.

"C with classes" was originally compiled to C by Cfront, but that's extremely dead AFAIK.

I doubt there's much demand for a resurrected Cfront when simply choosing a subset of C++, and using a current C++ compiler, already does everything you actually require.


FWIW I have written object-oriented C in the past, and manually passing this isn't that much of a burden. Even in Python you have to declare the self parameter explicitly, and nobody seems upset about that. Having to pass it in explicitly as well isn't so bad.