Counting Lines of Code on Windows
A simple four-step process.
Join the DZone community and get the full member experience.
Join For FreeLines of Code (LoC) isn't the greatest of metrics (and definitely not a sign of productivity) but sometimes it can be interesting to know.
Last week, after giving a demonstration of the Rapid XAML Toolkit someone asked me just how much code I'd written.
I didn't have a way to quantify this so I said I didn't know. "What counts as 'quite a lot'?"
Later I was thinking about the question and it made me wonder "What even is a quick way to count LOC in Windows?"
I didn't know.
Then I remembered that it's something I used to do regularly in Linux with one command. This was probably prompted as I gave a talk about Windows Subsystem for Linux (WSL) earlier that day.
WSL makes it easy to do things on Windows that are easy on Linux.
So, to count the lines of code in a project on Windows.
- Open the folder, with the code in, in Windows Explorer.
- Open WSL there (Shift+Right click and select 'Open Linux shell here', or type 'wsl' in the address bar.)
- Type `find . -name '*.cs' | xargs wc -l` (assuming you're using C#)
- Look at the number
Wow, that's 33463 lines of code in RXT. Much more than I would have guessed. Ok, so it includes blank lines and lines that only include curly braces but it's still quite big.
I wonder how many lines it will be by the time we release the preview...
Published at DZone with permission of Matt Lacey, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments