I wanted to know how many lines of code Drupal core has actually and I investigated it some days ago.
The returned numbers below mean lines of code respectively.
$ # Download Drupal $ drush dl drupal-7.51 $ # Include all the .module, .inc and .php files. $ find drupal-7.51 * | ag '\.(module|inc|php)$' | xargs cat | wc -l 422884 $ # Include above files but exclude test-related ones. $ find drupal-7.51 * | ag '\.(module|inc|php)$' | ag -v 'test' | xargs cat | wc -l 330026 $ # Include all JS files. $ find . * | ag '\.(js)$' | xargs cat | wc -l 18554 $ # Include all JS files except for test-related ones. $ find . * | ag '\.(js)$' | ag -v 'test' | xargs cat | wc -l 18254
This is mere a simple calculation but is enough to grasp sizes roughly. If I ignore test-related files, there are 330 thousands lines of PHP code. That is, for example, If I read 1,000 lines a day, it takes almost 1 years. I see.
Of course, I was interested in the case of D8.
$ # Download Drupal $ drush dl drupal-8.2.2 $ # Include all the php files. Following files are excluded. $ # - Files in Compser packages $ # - Test-related files $ # - Transliteration-related files $ # - (Of course, Twig template is not included because extension '.twig' is not specified.) $ find drupal-8.2.2/core * | ag '\.(module|inc|php)$' | ag -v 'vendor' | ag -v 'test' | ag -v 'Transliteration' | xargs cat | wc -l 917282 $ find core * | ag '\.(js)$' | ag -v 'vendor' | ag -v 'test' | ag -v 'Transliteration' | xargs cat | wc -l 52874
Hmm. It seems that there're more than 900 thousands lines of code even without the
vendor/ directory... It will take 900 days if I read 1,000 lines a day. Really? Surely Drupal 8 took a big jump from D7 but isn't it too large? (It's 3 times larger than D7.) I assume I missed something important to exclude from the count...
Anyway. I just wanted to know the rough volume and it's OK for now. Developers in 21st century (including me) are pretty lucky to see such a huge and sophisticated codebase for free :)
(FYI, if you are not used to
ag is just a replacement of