JDE
JDE

Reputation: 294

Why some large projects compile to small assemblies?

For instance, the last release of the famous library HtmlAgilityPack source is something like 110 000 lines of C#, and the assembly is 132 KB.

https://www.openhub.net/p/htmlagilitypack

My project is about 6500 lines and compiles to 300 KB assembly.

I haven't looked extensively at the source, but it is clearly not 100K loc usable classes. So what is that enormous amount of code doing?

Upvotes: 7

Views: 185

Answers (2)

D Stanley
D Stanley

Reputation: 152624

In addition to differences such as debug vs release mode, etc., I suspect that comparing your 6,500 lines to the "110,000" lines in their source is misleading.

Lines of code is a quirky metric. If you look at the breakdown by language, you see that there are only about 55 KLOC in C# for all projects (only one of which is the actual Agility Pack assembly), much of which is (I suspect) braces and other "whitespace" that does not directly get represented in the binaries. Also, just browsing through it, it does not use a lot of automatically-implemented properties, which use less lines of code for the same functionality. For example:

internal int _lineposition;

public int LinePosition
{
    get
    {
        return this._lineposition;
    }
    internal set
    {
        this._lineposition = value;
    }
}

versus

public int LinePosition {get; internal set;}

12 lines of code versus 1 for the same amount of compiled code.

All that to say that there are a lot of caveats to using lines of code as a metric for the "size" of a program.

Upvotes: 3

xbrain
xbrain

Reputation: 1

It may come from debug information in your code. It depends too if you make systems library calls (reduce size) or use a lot of your own written libraries.

Upvotes: -2

Related Questions