Can a low-level programmer learn OOP?
horpner at yahoo.com
Fri Jul 13 21:29:27 CEST 2007
On 2007-07-13, Chris Carlen <crcarleRemoveThis at BOGUSsandia.gov> wrote:
> John Nagle wrote:
>> You can sometimes get better performance in C++ than in C,
>> because C++ has "inline". Inline expansion happens before
>> optimization, so you can have abstractions that cost nothing.
> That's interesting. But why is this any different than using
> preprocessor macros in C?
This is OT, however: inline functions have a few benefits over
1. They are type-safe.
2. They never evaluate their arguments more than once.
3. They don't require protective parentheses to avoid precedence errors.
4. In C++, they have the additional benefit of being defined in a
namespace, rather than applying globally to a file.
As an experienced C programmer you're probably used to coping
with the problems of preprocessor macros, and may even take
advantage of their untyped nature occasionally. Even C++
programmers still use the advisedly.
> I will keep an open mind however, that until I work with it for
> some time there is still the possibility that I will have some
> light go on about OOP. So don't worry, I'm not rejecting your
In my opinion OOP is usefully thought of as a type of design
rather than a means of implementation. You can implement an OO
design in a procedural langauge just fine, but presumably an OO
programming language facilitates the implementation of an OO
design better than does a procedural language.
Going back to the stack machine question, and using it as an
example: Assume you design your program as a state machine.
Wouldn't it be easier to implement in a (hypothetical)
state-machine-based programming language than in a procedural
one? I think John was insinuating that a state-machine is more
like an object than it is like a procedure.
More information about the Python-list