C as an object oriented language?
It is certainly possible to write object oriented programs in C, but it is not by virtue of innate support in the language.
Very few of use here will agree on anything in this thread, but for what it is worth, Turing completeness is irrelevant; I too can write a given program more quickly in C++ than in plain C; and I agree whole heartedly that the use of C++ is a net negative on the overall productivity of any large project. In my industry, peer review is essential along with a combination of exhaustive test cases for deterministic algorithms and formal methods for provably correct code. All of these attempts to improve the quality of code can easily be undermined by the existence of language features that allow non-obvious side effects to result from seemingly simple line of code such as
A = B; // watch out for overloaded operators; this may not be a simple assignment
Or worse
If(a == b) // this is a particularly evil kind of overloaded operator that can have side effects on a, b or both
And even
Return false; // this can cause automatic object destruction that can result in the execution of lengthy sequences of code or even blocking on lock objects
I wont even attempt to cite an example of the consequences of multiple inheritance ? especially when the same base class exists more than once in the inherence tree.
The fact that these things are never used by reasonable programmers (or at least not by me) does not obviate the need to check for them when reviewing code.
Again, the more modern G3 OO languages (Java and C# are the notable examples) dispense with the worse of both ? but they are all unfit for the purpose as they require runtimes that cannot function in the Windows kernel (although it might be possible in the future)
Sent from Mailhttps: for Windows 10
From: Tim Robertsmailto:xxxxx
Sent: October 20, 2016 3:04 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: Re: [ntdev] Pros n Cons of using Classes (CPP) at Kernel Level
xxxxx@hotmail.com wrote:
> Concerning Turing-completeness, your statement is just a classical example of red herring.
>
> The concept of Turing-completeness applies to computability of a function - if some function X can be computed in some Turing-complete language A (or C), it means that this function can be computed in any other Turing-complete language. However, this is not what we speak about here, right
It most certainly is. You accused me of thinking “there is … nothing
in C++ that cannot be done in C,” as if that were a bad thing. That is
exactly Turing completeness. Now, maybe that’s not what you meant to
accuse me of, but that is exactly what you said.
> C++ is positioned, described and advertised as an object-oriented language, while C is supposed to be procedural.
You’re making your own definitions so you can strike them down. Both of
these are procedural languages, and both of them are object-oriented.
C++ emphasizes objects more than C, and that’s why it is a better choice
for programs that focus on data, which is most programs.
> However, in actuality, all the advantages that OOP offers result from your way of thinking about the problem in question, rather than from a language that you use. If you have any doubts about it, take a brief look at Linux/xBSD/Solaris kernels - you will see that, in actuality, you can easily write OO programs in plain C, and do it just fine.
Of course it’s possible to write OO programs in plain C, but I dispute
your addition of the word “easily”. My work involves almost as much
Linux as it does Windows, so I have spent a great deal of time wading
through the Linux kernel. When one does so, what becomes obvious is
how painful it is to handle lists and queues and strings. Yes, they
absolutely have facilities for managing their data structures, and
drivers use them extensively, but they are wordy, finicky, and
error-prone. C++ simply lets me express those concepts in a way that is
less prone to mistakes.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
—
NTDEV is sponsored by OSR
Visit the list online at: http:
MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at http:
To unsubscribe, visit the List Server section of OSR Online at http:</http:></http:></http:></mailto:xxxxx></mailto:xxxxx></https:>