Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76783

Re: Python vs C++

From Christian Gollwitzer <auriocus@gmx.de>
Newsgroups comp.lang.python, comp.lang.c++
Subject Re: Python vs C++
Followup-To comp.lang.python
Date 2014-08-22 10:05 +0200
Organization A noiseless patient Spider
Message-ID <lt6tk2$118$1@dont-email.me> (permalink)
References <mailman.13248.1408625664.18130.python-list@python.org>

Cross-posted to 2 groups.

Followups directed to: comp.lang.python

Show all headers | View raw


Am 21.08.14 14:54, schrieb David Palao:
> I consider myself a python programmer, although C++ was one of the
> first languages I learned (not really deeply and long time ago).
>
> Now I decided to retake C++, to broaden my view of the business.
> However, as I progress in learning C++, I cannot take out of my head
> one question
>
>   Why to use C++ instead of python?

You are asking in the wrong group; ask this in comp.lang.c++ Here most 
of the programmers know Python well and maybe some C++

> It is not ranting against C++. I was/am looking for small-medium
> projects to exercise my C++ skills. But I'm interested in a "genuine"
> C++ project: some task where C++ is really THE language (and where
> python is actually a bad ab initio choice).

The truth is, that both languages have a fairly large overlap. C++ spans 
a very wide gap, from tight low-level loops and direct memory access 
"close to the metal" up to composing a GUI application from ready-made 
building blocks. There is a variety of programming paradigmata, like 
functional (so-so), object oriented (quite good), generic (very good), 
imperative (shiny = the C subset). Graphically

C++:
metal |----------------------------------|

Python:
metal         |------------------------------------|


If your application lives within the overlap region, and a lot of them 
do, the choice is a matter of taste. I'm not even convinced that the 
development time is significantly lower in Python within this overlap. 
It becomes different at both ends: The more you go to the higher level, 
the more will Python outperform C++ in terms of development costs, but 
conversely C++ will win if you go closer to the metal. Then, as a Python 
programmer, you will find yourself rewriting parts of the application in 
Cython, trying PyPy, numpy, finally embedding C...

A few arguments outside of "what I can do with it" have already been given:

* For deployment, it is nice to compile and link a self-contained small 
binary. Try that with matplotlib - pyinstaller gets me a 100MB 
executable containing OS libraries, while the linker in C++ is able to 
only link what is needed.

* Access to the hardware: C structs, raw pointers, unboxed datatypes are 
needed in a painless and efficient way if you want to write, say,  a 
middle-level device driver

* performance is not only speed, but also memory usage. In most cases a 
C++ program will consume less memory

* static type checking can find bugs at compile-time. C++ is easier to 
compile (though on of the harder languages for compiler implementers), 
and therefore many tools exist for static analysis.

> The usual argument in favour of C++ (when comparing to python) is
> performance. But I'm convinced that, in general, the right approach is
> "python-profiling-(extension/numpy/Cython/...)".

Well, that's Ousterhouts dichotomy.

	Christian

	Christian

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python vs C++ David Palao <dpalao.python@gmail.com> - 2014-08-21 14:54 +0200
  Re: Python vs C++ wxjmfauth@gmail.com - 2014-08-21 07:08 -0700
  Re: Python vs C++ Rustom Mody <rustompmody@gmail.com> - 2014-08-21 07:10 -0700
  Re: Python vs C++ Grant Edwards <invalid@invalid.invalid> - 2014-08-21 14:59 +0000
    Re: Python vs C++ Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-08-21 23:12 -0400
  Re: Python vs C++ Christian Gollwitzer <auriocus@gmx.de> - 2014-08-22 10:05 +0200
    Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-22 18:50 +1000
      Re: Python vs C++ Marko Rauhamaa <marko@pacujo.net> - 2014-08-22 12:29 +0300
        Re: Python vs C++ "Neil D. Cerutti" <neilc@norwich.edu> - 2014-08-22 08:51 -0400
        Re: Python vs C++ Skip Montanaro <skip@pobox.com> - 2014-08-22 07:58 -0500
          Re: Python vs C++ Marko Rauhamaa <marko@pacujo.net> - 2014-08-22 20:16 +0300
            Re: Python vs C++ mm0fmf <none@mailinator.com> - 2014-08-23 17:47 +0100
              Re: Python vs C++ Marko Rauhamaa <marko@pacujo.net> - 2014-08-23 19:54 +0300
        Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-22 23:00 +1000
        Re: Python vs C++ Christian Gollwitzer <auriocus@gmx.de> - 2014-08-22 21:25 +0200
          Re: Python vs C++ Stefan Behnel <stefan_ml@behnel.de> - 2014-08-22 21:58 +0200
          Re: Python vs C++ Marko Rauhamaa <marko@pacujo.net> - 2014-08-22 23:06 +0300
            Re: Python vs C++ Michael Torrie <torriem@gmail.com> - 2014-08-22 15:38 -0600
              Re: Python vs C++ wxjmfauth@gmail.com - 2014-08-23 03:00 -0700
            Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-23 07:49 +1000
              Re: Python vs C++ Rustom Mody <rustompmody@gmail.com> - 2014-08-23 05:38 -0700
                Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-23 23:00 +1000
                Re: Python vs C++ Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-23 08:02 -0600
                Re: Python vs C++ Rustom Mody <rustompmody@gmail.com> - 2014-08-23 07:21 -0700
                Re: Python vs C++ Terry Reedy <tjreedy@udel.edu> - 2014-08-23 16:51 -0400
                Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-24 00:21 +1000
                Re: Python vs C++ Terry Reedy <tjreedy@udel.edu> - 2014-08-23 15:09 -0400
                Re: Python vs C++ Joseph Martinot-Lagarde <joseph.martinot-lagarde@m4x.org> - 2014-08-24 14:54 +0200
                Re: Python vs C++ "Neil D. Cerutti" <neilc@norwich.edu> - 2014-08-25 09:01 -0400
            Re: Python vs C++ Michael Torrie <torriem@gmail.com> - 2014-08-22 15:56 -0600
            Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-23 08:00 +1000
              Re: Python vs C++ Marko Rauhamaa <marko@pacujo.net> - 2014-08-23 10:27 +0300
            Re: Python vs C++ dieter <dieter@handshake.de> - 2014-08-23 07:56 +0200
            Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-23 16:11 +1000
              Re: Python vs C++ Paul Rudin <paul.nospam@rudin.co.uk> - 2014-08-23 08:36 +0100
                Re: Python vs C++ Chris Angelico <rosuav@gmail.com> - 2014-08-23 18:04 +1000
          Re: Python vs C++ dieter <dieter@handshake.de> - 2014-08-23 07:48 +0200

csiph-web