Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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; 'utf-8': 0.07; 'string': 0.09; 'callback': 0.09; 'pointers': 0.09; 'promising': 0.09; 'runtime': 0.09; 'slow.': 0.09; 'used.': 0.09; 'runs': 0.10; 'python': 0.11; 'language,': 0.12; 'template': 0.14; "wouldn't": 0.14; '(void': 0.16; '*),': 0.16; 'boost.': 0.16; 'c++.': 0.16; 'compiler.': 0.16; 'event-driven': 0.16; 'filters,': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'inability': 0.16; 'macros': 0.16; 'objects.': 0.16; 'openoffice': 0.16; 'think.': 0.16; 'ui,': 0.16; 'weird': 0.16; 'appropriate': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'app': 0.19; 'basically': 0.19; 'examples': 0.20; 'fit': 0.20; 'written': 0.21; 'seems': 0.21; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'certainly': 0.24; 'example.': 0.24; 'tend': 0.24; 'unicode': 0.24; 'java': 0.24; "i've": 0.25; 'references': 0.26; 'pass': 0.26; 'supported': 0.26; 'certain': 0.27; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'thus': 0.29; "doesn't": 0.30; 'code': 0.31; 'that.': 0.31; 'argue': 0.31; 'easy,': 0.31; 'safely': 0.31; 'file': 0.32; 'quite': 0.32; 'actual': 0.34; 'moment': 0.34; 'maybe': 0.34; "i'd": 0.34; 'could': 0.34; "can't": 0.35; 'agree': 0.35; 'except': 0.35; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'c++': 0.36; 'scheme': 0.36; 'templates': 0.36; 'done': 0.36; 'doing': 0.36; 'next': 0.36; "didn't": 0.36; 'method': 0.36; 'possible': 0.36; 'should': 0.36; 'error.': 0.37; 'virtual': 0.37; 'too': 0.37; 'implement': 0.38; 'represent': 0.38; 'message-id:@gmail.com': 0.38; 'apple': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'pm,': 0.38; 'rather': 0.38; 'aspects': 0.39; 'bad': 0.39; 'realize': 0.39; 'supporting': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'offer': 0.62; 'show': 0.63; 'name': 0.63; 'such': 0.63; 'today': 0.64; 'became': 0.64; 'great': 0.65; 'relatively': 0.65; 'details': 0.65; 'promise': 0.68; 'home': 0.69; 'boost': 0.70; 'products': 0.71; 'safe': 0.72; 'sweet': 0.74; 'belief': 0.84; 'darn': 0.84; 'dispatching': 0.84; 'lived': 0.84; 'nice,': 0.84; 'partially': 0.84; 'slots.': 0.84; "they'd": 0.84; 'niche': 0.91 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Fri, 22 Aug 2014 15:38:56 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Python vs C++ References: <87fvgoj2i8.fsf@elektro.pacujo.net> <87siko9tlq.fsf@elektro.pacujo.net> In-Reply-To: <87siko9tlq.fsf@elektro.pacujo.net> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408743547 news.xs4all.nl 2877 [2001:888:2000:d::a6]:47451 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76825 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. I certainly wouldn't want to use Java (contrary to popular belief OO is not written in Java; it's definitely C++). Go is quite young but promising except that unicode is all UTF-8 byte strings, so string operations are going to be a bit slow. C# never lived up to its promise as the next app development language, even on Windows. So at this moment I'd still do it in C++ I think. Apple chose to use C++ to build clang and llvm in, rather than C. > 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. > Qt needs callbacks ("signals" IIRC). It doesn't use C++ to express them. > It uses a fricking metacompiler for them. This is only partially true. The actual, original, .cpp files with Qt macros in them compile directly on the C++ compiler. moc runs on the .h file to generate some supporting code to help with event dispatching. There's no such thing as Qt C++. It's all standard C++, with macros to help when defining things such as signals. Macros were chosen instead of templates because at the time, not all C++ compilers supported templates. Now if it was done all over again, they'd do something like libsigc++, or boost. > And Stroustrup's thick book didn't even seem to be aware of callbacks as > a paradigm and thus didn't show any examples of dealing with them. Too > bad Stroustrup wasn't aware of C#'s delegates; C++ should have defined > function pointers as delegates. Maybe the language doesn't need to implement them as keywords because it's already possible to do safely with templates. libsigc++ is a great implementation that works really well (and it's quite fast at dispatching events). libsigc++ has an advantage over Qt in that the signals are actual type-safe template objects. Qt's signals are actually strings under the hood, and I've had weird name clash issues in the past when I didn't realize that. Can't remember the circumstances or the details now. Basically something that should have been caught at compile time became a runtime error. Doing event-driven programming with Gtkmm and libsigc++ is actually pretty darn nice and is right at home in C++. > There is one big advantage C++ has over C: virtual method dispatching. > However, I have been able to come up with C idioms that make practical > method dispatching relatively painless. Seems like Vala might fit this niche pretty well.