Python vs C++

Chris Angelico rosuav at gmail.com
Fri Aug 22 17:49:37 EDT 2014


On Sat, Aug 23, 2014 at 7:38 AM, Michael Torrie <torriem at gmail.com> wrote:
> On 08/22/2014 02:06 PM, Marko Rauhamaa wrote:
>> I tend to think the opposite: C++ barely has a niche left. I definitely
>> wouldn't want to use C++ very far from its (very narrow) sweet spot.
>
> I agree that it's niche is narrowing.  But it's still pretty wide and
> widely used.  Many adobe products are C++, for example.  OpenOffice and
> LibreOffice is C++.  You could argue that's because they are old
> projects and were started in C++. But honestly if you were
> reimplementing OpenOffice today what would you choose?  Python would be
> appropriate for certain aspects of OO, such as parts of the UI, macros,
> filters, etc. ...

Frankly, I wouldn't write OO in anything, because I think the entire
concept of a WYSIWYG editor is flawed. Much better to use markup and
compile it. But if I were to write something like that, probably what
I'd do would be to write a GUI widget in whatever lowish-level
language is appropriate (probably C, with most GUI toolkits), and then
use a high level language (probably Python or Pike) to build the
application. I'm not familiar with all of OO/LO's components, but I
believe that model will probably work for all of them (the document
editor, obviously; the presentation editor might be done a bit
differently, but it'd still work this way; the spreadsheet quite
possibly doesn't even need a custom widget; etc).

>> My disillusionment with C++ came from the language's inability to
>> represent callbacks. C can do it (void *), C# can do it (delegates),
>> Java can do it (anonymous inner classes), Python can do it (methods),
>> Scheme can do it (closures).
>
> C++ can do it quite well, actually.  Maybe not quite as nicely as
> Python.  But boost and libsigc++ both offer nice, type-safe ways to
> implement signals and slots.  You can pass references to a callback
> around in an easy, safe way.

My main issue with callbacks in either C or C++ is that functions
aren't first-class objects. You can pass function pointers around (and
you don't need (void *) to do it, you can use typed function pointers
just fine), but you can't actually construct a function at run-time.

ChrisA



More information about the Python-list mailing list