C++ version of the C Python API?

Robert Dailey rcdailey at gmail.com
Mon Oct 22 10:47:42 EDT 2007


On 10/22/07, Nicholas Bastin <nick.bastin at gmail.com> wrote:
>
> Object-oriented programming is a design choice, not a language
> feature.  You can write straight procedural code in C++, and you can
> write object oriented code in C.  Sure, C++ has some language features
> which facilitate object-oriented programming, but it doesn't magically
> make your code object-oriented.  You can certainly write basic
> object-oriented code in C and hide most of the implementation in
> preprocessor macros if you so desire.

Well, perhaps what I meant was I personally would not turn to C for
OOP. As I said before, I've seen OOP attemps using C and it was VERY
unattractive (this coming from a C++ programmer of course). It just
doesn't make sense to me why you'd choose an OOP approach in a
language that makes it messy over a language that had OOP in mind when
it was designed. There are far better languages (which, as you said,
have features to facilitate OOP) that I would choose long before I
chose C, such as C++.

Yes, I agree you can do OOP in any language as it is just a concept,
however there are other entities that can greatly affect which
language you choose to intake such a responsibility. For example, I'd
choose Python OOP over C++ OOP because to me Python code is cleaner
and has less syntax redundancy. You get to read the important stuff
more quickly. A lot of people would disagree in that whitespace does
not make code more readable than operator delimiters, however this is
just my opinion. In addition, I'd choose Python OOP over C++ OOP for
quick applications that didn't require a great amount of performance
(such as a level editor for a game). For the game itself, I'd choose
C++ OOP because it is way more flexible and allows me to optimize the
game for speed as best as I can, whereas with python you can only
optimize only to a certain point (as with any language), which still
may not be fast enough. In any case, it's really not fair to compare
speed between an interpreted language vs a compiled language.

Given what I've learned and things I've come to like, I doubt I'd do
any sort of programming ever again that didn't involve some sort of
object oriented design. That's just my preference. This preference, in
turn, is what motivated my original question. The CPython API
interface itself seems modularized, NOT object oriented (only from
what I saw). Boost.Python, as so many have already noted, is a wrapper
over that interface introducing C++ which provides the OOP I am
looking for.



More information about the Python-list mailing list