source code size metric: Python and modern C++

Pavel Vozenilek pavel_vozenilek at yahoo.co.uk
Mon Dec 2 17:17:22 EST 2002


Neal Norwitz <neal at metaslash.com> wrote in message news:<pan.2002.12.02.03.44.36.314421.12688 at metaslash.com>...
> On Sun, 01 Dec 2002 21:09:28 -0500, Pavel Vozenilek wrote:
>
[snip] 
> http://www.metaslash.com/brochure/recall.html
> 
> This is a real world example of an open source project.
> Short answer for the lazy:
> 
>                Main Code  Support Code   Example's Code
> C++               4988         3105          2573
> Python and IDL    1858            0           659
> 
> In sum (2517 for Python vs. 10666 for C++), that's a factor of over 4.
>
Thanks for the link - it contains the information I was interested.


Looking over the code example, I think the C++ version is
unnecessarily verbose (but didn't try with real compiler though):

1) Boost contains lambda-like library that could replace whole struct
Compare with 'inline function', like in Python. (The library is quite
new - available for some 1/2 year on Boost.)
2) The class CleanupUpdates may not be needed at all if the code is
restructured (if some form of smart pointer is used to managed
lifetime - maybe, please).
3) The "push.erase()" can be replaced with single line, like it is in
Python.
4) Author says he didn't use 'map' intentionally, as he found it
compled to read and use. According to him it code size can be "made
much smaller using more advanced data structures".

/Pavel



More information about the Python-list mailing list