8 ms·
3542 files 540,000 lines of Go code 65,000 lines of comments So on average only 170 lines per file, including 17 lines of comments. Are this normal ratios ?
by Gys 10y ago
3542 files
540,000 lines of Go code
65,000 lines of comments
So on average only 170 lines per file, including 17 lines of comments.
Are this normal ratios ?
- fishywang 10y agoThis sounds normal in go. In go a minimal import (package) is a while directory, not a single file, so it's normal to split packages into smaller files, each file implements a smaller set of features.
- adtac 10y agoI think so? Assuming a regular function (a method should do one thing and one thing only) is about ~20 lines, we're looking at ~6 functions (170 lines - 17 comments - about 15 lines of newlines, imports and so on = 130-odd). Six functions sounds very reasonable to me.
- butabah 10y agoUsing cloc against the Go source code, I found that it has 934025 loc with 3080 files. This averages to about 300 loc per file. There are 149688 lines of comments, which averages to about 50 per file. I'd say those ratios are very similar.
- michaelmcmillan 10y agoI try to keep my files under 100 loc, but I mostly build CRUD applications.
- sulam 10y agoThe comment ratio is going to vary heavily depending on the problem the project is trying to solve. If it was a library, I would expect the ratio of comments to go up to 30% or more. The LOC per file average seems slightly high for my taste but okay.