Hi Anirudh,
There are many factors why the actual size of the browser is small compared to the source code.
- Comments (Chromium has around 20-30% of the source commented. We comment everything, from JavaScript, to C++)
- Test Data (There is "alot" of test data, layout tests, unit tests, browser tests, etc, and test binary/ascii data itself,)
- Tools (Some tools are bundled up together like python, git, coverity, valgrind, etc)
- Cross-Platform (We support ChromeOS, Mac, Windows, and Linux, you just compile what you use)
- Repository Database (If you checked out using SVN, I believe size almost doubles or triples, you can Google why. If you cloned with Git, it is marginally smaller, but it is still heavy) I might be wrong though.
- Optimizations (The compiler optimizes code, not enough experience in that part.)
So lets look at an example for Windows, if you look at the core browser code in src/chrome, you will notice the following:
- The size of the folder is ~1.1 GB (my early clone)
- The test data is around ~900MB
- The Linux, Mac, and ChromeOS files take around ~100MB
- Comments around ~30%.
That leaves around ~100MB (excluding compiler optimizations), I don't know how well it compresses, images, files, etc. So from 1.1GB till 100MB by just removing the stuff that interferes. I didn't include the repo, because the .git folder is outside the src/chrome folder.
I hope that helped answer your question a little. Take a look at this superb widget made by Evan Martin, it is a treemap that shows how many bytes do our various bits of code contribute to the final executable.
http://neugierig.org/software/chromium/bloat/
There might be a many more reasons, but with my little experience in the language, that is what I could come up with. Any else can contribute more :)
Kind regards,
Mohamed Mansour