LOC in Python and C++ in large projects

  • Thread starter Adriaan Renting
  • Start date
A

Adriaan Renting

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):
self.close()

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 said:
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
lines.

Thomas
 
M

Mike Meyer

Adriaan Renting said:
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
important.

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

<mike
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top