Can a low-level programmer learn OOP?
nagle at animats.com
Fri Jul 13 18:54:16 CEST 2007
Chris Carlen wrote:
> From what I've read of OOP, I don't get it. I have also found some
> articles profoundly critical of OOP. I tend to relate to these articles.
> However, those articles were no more objective than the descriptions of
> OOP I've read in making a case. Ie., what objective
> data/studies/research indicates that a particular problem can be solved
> more quickly by the programmer, or that the solution is more efficient
> in execution time/memory usage when implemented via OOP vs. procedural
> The problem for me is that I've programmed extensively in C and .asm on
> PC DOS way back in 1988. Then didn't program for nearly 10 years during
> which time OOP was popularized. Starting in 1999 I got back into
> programming, but the high-level-ness of PC programming and the
> completely foreign language of OOP repelled me. My work was in analog
> and digital electronics hardware design, so naturally I started working
> with microcontrollers in .asm and C. Most of my work involves low-level
> signal conditioning and real-time control algorithms, so C is about as
> high-level as one can go without seriously loosing efficiency. The
> close-to-the-machine-ness of C is ideal here. This is a realm that I
> truly enjoy and am comfortable with.
> Hence, being a hardware designer rather than a computer scientist, I am
> conditioned to think like a machine. I think this is the main reason
> why OOP has always repelled me.
I've written extensively in C++, including hard real-time programming
in C++ under QNX for a DARPA Grand Challenge vehicle. I have an Atmel
AVR with a cable plugged into the JTAG port sitting on my desk right now.
Even that little thing can be programmed in C++.
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.
If it has state and functions, it probably should be an object.
The instances of the object can be static in C++; dynamic memory
allocation isn't required in C++, as it is in Python.
Python is a relatively easy language, easier than C++, Java,
or even Perl. It's quite forgiving. The main implementation,
CPython, is about 60x slower than C, though, so if you're trying
to implement, say, a rapidly changing digital oscilloscope display,
the result may be sluggish.
More information about the Python-list