0

Background

I am currently working for a quite large (relative to what I have done before) hobby project. I would like to compare the size of this project to other open-sourced projects but I cannot figure out how I should do that in a good and meaningful way.

Problems with using line count

I usually see project size being measured in line of code.

I do not consider that to be a good way to measure code size because then projects that have code that is styled like this:

int function(int argument_one, int argument_two) {
    int var1, var2, var3;
    code;
    code;
    if (test(var2, var3))
        code;
    else
        code;
    return var1;
}

will appear about 40 % smaller than projects with code that is styled like this:

int function(int argument_one, int argument_two)
{
    int var1;
    int var2;
    int var3;

    code;
    code;

    if (test(var2, var3))
    {
        code;
    }
    else
    {
        code;
    }

    return var1;
}

Other ways

Some other ways I have heard of are:

  • Character count

  • Comment count

  • Word count

  • Compilation time

But all of these has disadvantages. Comment count would make messy code with lots of comments appear longer. Compilation time is dependent on how fast the computer is and how the code is compiled. Word and character count are also highly dependent on how the code is styled.

Question

I am wondering if there are any more reliable ways to measure project size than the ones listed here.

What are more reliable ways to measure code size? Has there been attempts to come up with a universal way to measure code size? Are there any tools available that measures code size in a more meaningful way than simply counting lines/words/chars?

closed as primarily opinion-based by Scant Roger, GlenH7, user40980 Nov 23 '15 at 17:19

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • I'm sure there were attempts at measuring project size. But I'm not sure if they came up with something that isn't function of LoC. – Euphoric Nov 23 '15 at 10:40
  • 1
    There's no universal way to measure code size because there's no universal way to code, ask to code something to 1000 programmers, you'll end up with 1000 different solutions (with different sizes). However, if you want to approximate project's size I see 2 prerequisites: same language, same coding conventions (spacing, naming, etc.). Are these conditions matched in your case ? – Spotted Nov 23 '15 at 10:43
  • For what purpose do you wish to measure the size of your project against others? – David Arno Nov 23 '15 at 10:46
  • @DavidArno I just wish to boost my ego by comparing what I have done to other projects :) – wefwefa3 Nov 23 '15 at 10:49
  • 1
    @ryvnf, one measure I use of how good a developer is is how many lines of code they manage to delete in a day. The bigger a project, the more it's likely to contain noise, duplicated code and, ultimately, the more bugs it's likely to contain. So to boost your ego, you want to be measuring how small your project is against equivalents (without gaming, by making your code unreadable in the quest for smallness :) – David Arno Nov 23 '15 at 10:53
2

Cyclomatic complexity algorithms are what you want to look into.

There are a few tools that calculate this info.

0

Just use LoC.

Exclude blank lines and comments. If you're worried about differences in coding style, then you can use a tool like clang-format to try to standardize coding style.

Yeah, LoC has all kinds of limitations as a measure of project size or complexity - but so does anything else you could come up with, and LoC has the advantage of being easy to implement and easy and intuitive to understand. And, for all its limitations, it can at least give a rough comparison between different projects. Quoting Wikipedia:

Many useful comparisons involve only the order of magnitude of lines of code in a project. Using lines of code to compare a 10,000 line project to a 100,000 line project is far more useful than when comparing a 20,000 line project with a 21,000 line project. While it is debatable exactly how to measure lines of code, discrepancies of an order of magnitude can be clear indicators of software complexity or man hours.

Not the answer you're looking for? Browse other questions tagged or ask your own question.