Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'widely': 0.05; 'subject:Python': 0.06; 'c++,': 0.07; 'nicely': 0.07; 'callback': 0.09; 'components,': 0.09; 'etc).': 0.09; 'pointers': 0.09; 'typed': 0.09; 'used.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'gui': 0.12; "wouldn't": 0.14; '(void': 0.16; '*),': 0.16; '23,': 0.16; 'c++.': 0.16; 'editor,': 0.16; 'filters,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inability': 0.16; 'objects.': 0.16; 'openoffice': 0.16; 'run-time.': 0.16; 'ui,': 0.16; 'way;': 0.16; 'sat,': 0.16; 'appropriate': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'widget': 0.19; '(the': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'example.': 0.24; 'tend': 0.24; 'java': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'references': 0.26; 'pass': 0.26; 'certain': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'michael': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'argue': 0.31; 'easy,': 0.31; 'markup': 0.31; 'probably': 0.32; 'quite': 0.32; 'maybe': 0.34; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'agree': 0.35; 'something': 0.35; 'editor': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'c++': 0.36; 'scheme': 0.36; 'done': 0.36; 'level': 0.37; 'implement': 0.38; 'represent': 0.38; 'whatever': 0.38; 'issue': 0.38; 'pm,': 0.38; 'that,': 0.38; 'aspects': 0.39; 'either': 0.39; 'even': 0.60; 'most': 0.60; 'entire': 0.61; 'offer': 0.62; 'high': 0.63; 'such': 0.63; 'today': 0.64; 'believe': 0.68; 'boost': 0.70; 'products': 0.71; 'safe': 0.72; 'sweet': 0.74; '(probably': 0.84; "it'd": 0.84; 'nice,': 0.84; 'slots.': 0.84; 'spreadsheet': 0.84; 'niche': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=5dkLH+tb2CZsV0KtznE0P2srXTyNpn8ECaBOW6fRWOY=; b=ub/Wx44LhTLm8RhlS8uX/xyuyfEBr19k3+QSZPby5SKyh9peN86W1JFSkFlrkhFKgd LNUGiQbPmm2ysp6s33/Kp7itZfo21ssDVHng6yX8OHfxbarSUUYO17R+nJFMDDhO2TtR ZBkkTrKDrHdVaZHIS+MNLXfKS/A/9mNoPO67GjOZF5bo82yS4y/C6WOJ0+8pX3y3EUeV r3lq8qLYpPnNOnfFLQ28cr4qt0bwbixM4oSZxI69fkne5k6uurgj6T0s/q+FDU49SlPO PlBlgwOlZRGpMQnsR8uQIHo5H/GXV686+WYf6HAeYbmKLIGhMAPhrxJ/WhdS4pqS4lPh 2wPw== MIME-Version: 1.0 X-Received: by 10.42.236.146 with SMTP id kk18mr11763853icb.35.1408744177290; Fri, 22 Aug 2014 14:49:37 -0700 (PDT) In-Reply-To: <53F7B870.2010909@gmail.com> References: <87fvgoj2i8.fsf@elektro.pacujo.net> <87siko9tlq.fsf@elektro.pacujo.net> <53F7B870.2010909@gmail.com> Date: Sat, 23 Aug 2014 07:49:37 +1000 Subject: Re: Python vs C++ From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408744179 news.xs4all.nl 2910 [2001:888:2000:d::a6]:50792 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76826 On Sat, Aug 23, 2014 at 7:38 AM, Michael Torrie 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