LOC in Python and C++ in large projects

Discussion in 'Python' started by Adriaan Renting, Jul 1, 2005.

  1. I think the point you want to make is that Python needs vastly less
    lines of code as a similar application written in C++. I think Python
    might on average be 50-60% of comparable C++ code, but not the 1-2% you
    seem to want to claim. LOC is a somewhat arbitrairy measurement, but it
    gives an idea of what I'm talking about.

    Your single example compares a simple use in Python with a much more
    elaborate framework in one of the worst C++ IDE's I know. I can easily
    give you a counter example:
    If I create a simple form in Eric3 it will generate about 500-600 lines
    of Python too.
    When using this in actual code the difference between a piece of C++ and
    Python would however be mostly cosmetic:
    void MyForm::exitFile()
    { close();
    ------------ vs. ----------------
    def exitFile(self):

    Your example is very good at demonstrating why Python is very useful for
    simple and small projects. Simple programs are simpler in Python.
    All programming languages can be used to write horrible unreadable and
    inefficient code. Therefore I think it's better to compare best cases as
    it is to compare worst cases.

    In the large projects I've worked on most of the code has nothing to do
    with external libraries or IDE generated code, but only with other parts
    of the project and most of the advantages Python has in small simple
    projects are uninportant.
    I think C++ gives a little more tools to keep large projects manageable,
    mostly because you can find a lot more communication failures between
    programmers at compile time.

    I think the choice of a programming language is not very important in
    determining the overal succes of a project. C++ and Python are however
    my two favorite languages.

    I think it would be interesting if any readers with more experience as I
    have would comment on how Python behaves in large projects, and how much
    less lines they need compared to C++ or Java.
    I have worked on several C++ projects with a few million lines of code,
    I would appreciate experience with comparable projects. (can you do it
    in 10.000 Lines of Python?)

    >>> Thomas Heller <> 07/01/05 11:36 AM >>>

    Thomas Heller <> writes:

    > "Adriaan Renting" <> writes:
    >> I'm not a very experienced Python programmer yet, so I might be
    >> mistaken, but there are a few things that would make me prefer C++

    >> Python for large (over 500.000 LOC) projects.
    >> - namespaces
    >> - templates
    >> - strong type checking
    >> - data hiding
    >> - more available libraries and more advanced developement tools.
    >> I'm talking about managing the code, not the programmers, the project

    >> schedules or what have you. Those are independent from the chosen
    >> programming language.

    > Just a single datapoint: Implementing a trivial COM object in Python
    > requires, let's guess, about 10 or 20 lines of source code.
    > When I do the same in MSVC6, the wizard creates 10 files, with nearly
    > 400 lines of code. Sure, I didn't have to write these code lines, but
    > I'm required to understand and manage them as well.

    Sorry, I forgot to include the .dsw and .dsp files in the above figure.
    Including them brings the LOC count up to 750 for the C++ project -
    although, to be fair, on the Python side a setup.py script for py2exe
    would also have to be written. In simple cases, this is another 10

    Adriaan Renting, Jul 1, 2005
    1. Advertisements

  2. Adriaan Renting

    Mike Meyer Guest

    "Adriaan Renting" <> writes:
    > I think the choice of a programming language is not very important in
    > determining the overal succes of a project. C++ and Python are however
    > my two favorite languages.

    Well, getting done on time is a crucial part of success, and it takes
    less time to write fewer LOC. So choice of language can be very

    For an excellent essay on this, see <URL:
    http://www.paulgraham.com/icad.html >.


    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
    Mike Meyer, Jul 1, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. fpgawizz

    not able to write to addr loc x0

    fpgawizz, Apr 2, 2005, in forum: VHDL
    Apr 2, 2005
  3. El Durango

    Eclipse question regarding LOC.

    El Durango, Jul 19, 2004, in forum: Java
    Jul 20, 2004
  4. sumit chawla
    Thomas Matthews
    Jul 13, 2004
  5. Beyond LOC

    , Jan 15, 2007, in forum: C++
    Ian Collins
    Jan 16, 2007
  6. Replies:
  7. Java coder

    Simple/pojo loc parser for java

    Java coder, Sep 6, 2010, in forum: Java
    John B. Matthews
    Sep 6, 2010
  8. CM