By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,100 Members | 2,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,100 IT Pros & Developers. It's quick & easy.

LOC in Python and C++ in large projects

P: n/a
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 <th*****@python.net> 07/01/05 11:36 AM >>>
Thomas Heller <th*****@python.net> writes:
"Adriaan Renting" <re*****@astron.nl> 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++

over 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 or 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
lines.

Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Adriaan Renting" <re*****@astron.nl> 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
important.

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

<mike

--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.