Comparison of the amount of code of popular frameworks
Hello, Habr. Every year the number of frameworks increases, forks appear, some become fashionable, and some go out of fashion. Of course, different frameworks provide the developer with different opportunities, which primarily depend on the developers, their ideas, the chosen architecture, the availability of documentation ... and of course the size of the framework. We’ll talk about this parameter today - I’ll ask everyone interested under cat.
Let's look at the question from the point of view of a beginner. Here he has already learned the basics, writes something on the "native" php. Gradually comes to such a concept as a "framework". And now he is already interested in this issue, googled which frameworks are the most popular, which have documentation in Russian, and which have a community. However, there is still such a parameter as complexity or entry threshold. And if he asks for advice on the forum, then he will most likely be advised by Codeigniter or Kohana (less often Yii) than Zend Framework or Symfony. And this is quite logical and normal.
Is a large framework good or bad? Which is better: good performance or excellent architecture and features? We will leave these questions for the following articles, and today we look at the smallest and largest and most voluminous frameworks. And we will count the number of lines and the number of files.
On the network you can find information about the number of lines of a particular framework. But this information seemed unreliable and quite outdated to me (I consider 1-2 years a big gap in the industry), so I decided to get this data myself by counting. This raises the question: what exactly are we going to consider? Reflecting on this issue, I came to the conclusion that the following parameters should be calculated:
For this purpose, a small php script was written that recursively received all the files in the folder, opened them and counted the number of lines. Also along the way we save the number of files.
The experiment was attended by popular frameworks (if I forgot your favorite - write, add) and several CMS / CMF for clarity. When measuring, we used the latest versions from developer sites.
As a result, I received the following data:
And if you find the approximate number of lines per file (when calculating, the data was “only php files without third-party components”):
So, let's analyze the data. The largest (by the number of files) in the standard delivery is the Symfony framework, and the largest - Yii. The most concise (least files) is Codeigniter.
According to the average number of lines in a file, the frameworks were divided into 2 groups: 110-160 lines in a file (Kohana, Zend, Symfony, FuelPHP) and 300-500 lines in a file (Codeigniter, Yii, CakePHP), but there aren’t any average ones. Most likely this is due to architecture and you should not take these values very seriously.
As for the CMS / CMF, the results are very expected and may contain a large error, because they contain a fairly large number of elements related to the frontend.
In conclusion, I would like to note that the results were quite predictable. However, it is not necessary to focus much attention on such a parameter as the size of the framework. The programmer, knowing all the pros and cons of each option, must choose a tool for a specific task and use its advantages.
UPD: In the comments they suggested to compare the number of characters without comments. I conducted such a test: only php files, without comments, transfers, the number of characters is considered (utf-8 is taken into account).
Let's look at the question from the point of view of a beginner. Here he has already learned the basics, writes something on the "native" php. Gradually comes to such a concept as a "framework". And now he is already interested in this issue, googled which frameworks are the most popular, which have documentation in Russian, and which have a community. However, there is still such a parameter as complexity or entry threshold. And if he asks for advice on the forum, then he will most likely be advised by Codeigniter or Kohana (less often Yii) than Zend Framework or Symfony. And this is quite logical and normal.
Is a large framework good or bad? Which is better: good performance or excellent architecture and features? We will leave these questions for the following articles, and today we look at the smallest and largest and most voluminous frameworks. And we will count the number of lines and the number of files.
On the network you can find information about the number of lines of a particular framework. But this information seemed unreliable and quite outdated to me (I consider 1-2 years a big gap in the industry), so I decided to get this data myself by counting. This raises the question: what exactly are we going to consider? Reflecting on this issue, I came to the conclusion that the following parameters should be calculated:
- The number of lines and files in the whole framework
- The number of php files and lines in them throughout the framework
- The number of php files and lines in them throughout the framework excluding third-party components
For this purpose, a small php script was written that recursively received all the files in the folder, opened them and counted the number of lines. Also along the way we save the number of files.
The experiment was attended by popular frameworks (if I forgot your favorite - write, add) and several CMS / CMF for clarity. When measuring, we used the latest versions from developer sites.
As a result, I received the following data:
Object of study | Completely | Only php files | Only php files (without third-party modules) |
---|---|---|---|
Kohana 3.3.0 | |||
files | 1283 | 862 | 471 |
lines | 183228 | 119023 | 56874 |
Codeigniter 2.1.3 | |||
files | 352 | 147 | 147 |
lines | 88724 | 51525 | 51525 |
Yii 1.1.13 | |||
files | 2005 | 1621 | 1571 |
lines | 653970 | 614712 | 573114 |
Zend Framework 2.1.3 | |||
files | 2070 | 1963 | 1963 |
lines | 276248 | 272957 | 272957 |
Symfony 2.2.0 | |||
files | 5718 | 3583 | 2247 |
lines | 498788 | 418988 | 253408 |
CakePHP 2.3.0 | |||
files | 1012 | 654 | 654 |
lines | 251125 | 238350 | 238350 |
FuelPHP 1.5.2 | |||
files | 700 | 473 | 455 |
lines | 166730 | 96074 | 73118 |
Drupal 7.2.0 | |||
files | 1056 | 269 | 269 |
lines | 314574 | 150999 | 150999 |
Joomla 3.0.3 | |||
files | 4753 | 1651 | 1651 |
lines | 517145 | 303996 | 303996 |
Wordpress 3.5.1 | |||
files | 1085 | 447 | 447 |
lines | 312529 | 192473 | 192473 |
And if you find the approximate number of lines per file (when calculating, the data was “only php files without third-party components”):
Object of study | Lines / file (average) |
---|---|
Kohana 3.3.0 | 120.7515924 |
Codeigniter 2.1.3 | 350,5102041 |
Yii 1.1.13 | 364,8084023 |
Zend Framework 2.1.3 | 139,0509424 |
Symfony 2.2.0 | 112,776146 |
CakePHP 2.3.0 | 364,4495413 |
FuelPHP 1.5.2 | 160.6989011 |
Drupal 7.2.0 | 561.3345725 |
Joomla 3.0.3 | 184,128407 |
Wordpress 3.5.1 | 430,5883669 |
So, let's analyze the data. The largest (by the number of files) in the standard delivery is the Symfony framework, and the largest - Yii. The most concise (least files) is Codeigniter.
According to the average number of lines in a file, the frameworks were divided into 2 groups: 110-160 lines in a file (Kohana, Zend, Symfony, FuelPHP) and 300-500 lines in a file (Codeigniter, Yii, CakePHP), but there aren’t any average ones. Most likely this is due to architecture and you should not take these values very seriously.
As for the CMS / CMF, the results are very expected and may contain a large error, because they contain a fairly large number of elements related to the frontend.
In conclusion, I would like to note that the results were quite predictable. However, it is not necessary to focus much attention on such a parameter as the size of the framework. The programmer, knowing all the pros and cons of each option, must choose a tool for a specific task and use its advantages.
UPD: In the comments they suggested to compare the number of characters without comments. I conducted such a test: only php files, without comments, transfers, the number of characters is considered (utf-8 is taken into account).
Object of study | Symbols (no comments, hyphenation, third-party libraries) |
---|---|
Yii 1.1.13 | 13248904 |
Symfony 2.2.0 | 5769403 |
CakePHP 2.3.0 | 5365166 |
Zend Framework 2.1.3 | 5334742 |
Zend Framework 2.1.3 (without Res / lang) | 4924887 |
Yii 1.1.13 (without i18n data and messages) | 1811665 |
FuelPHP 1.5.2 | 1209799 |
Kohana 3.3.0 | 841022 |
Codeigniter 2.1.3 | 616417 |