473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

LOC in Python and C++ in large projects

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
1 2569
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
by: Bicho Verde | last post by:
I have now free time and money to do what I want :-) I have some basic skills in programming (C, Pascal, Macromedia Actionscript) but don't know exactly what to do in the world of programming. And...
23
by: assaf__ | last post by:
Hello, I am beginning to work on a fairly large project and I'm considering to use python for most of the coding, but I need to make sure first that it is reliable enough. I need to make sure...
42
by: Fred Ma | last post by:
Hello, This is not a troll posting, and I've refrained from asking because I've seen similar threads get all nitter-nattery. But I really want to make a decision on how best to invest my time....
9
by: limor | last post by:
Hi, I am considering using Python in a new testing tool application we intend to build for out product. I must get references before starting develope in this language , since although lots of...
7
by: Ixokai | last post by:
Hello all. :) I've been a long time Python fan, and have fairly recently (with the support of a coworker who surprised me by mentioning my pet language one day) convinced my company to begin the...
36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
10
by: TokiDoki | last post by:
Hello there, I have been programming python for a little while, now. But as I am beginning to do more complex stuff, I am running into small organization problems. It is possible that what I...
267
by: Xah Lee | last post by:
Python, Lambda, and Guido van Rossum Xah Lee, 2006-05-05 In this post, i'd like to deconstruct one of Guido's recent blog about lambda in Python. In Guido's blog written in 2006-02-10 at...
162
by: Sh4wn | last post by:
Hi, first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when you...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.