A group of Greek scientists led by
Diomidis Spinellis conducted an interesting study of the sensitivity of ten popular programming languages to errors and typos when typing a program. The damage from
such errors can sometimes be many millions, and the ability of the language to detect them as early as possible is very important for developing reliable programs. For testing, we used several examples from the
Rosetta Code project, a wiki where the implementations of many tasks and algorithms in different languages are collected. Based on the statistics on the popularity of languages, as well as some practical considerations (availability of a free compiler and examples on the Rosetta Code), the following languages and compilers were chosen:
Tongue | compiler / environment |
C | gcc 4.4.5 |
C ++ | g ++ 4.4.5 |
C # | mono 2.6.7, CLI v2.0 |
Haskell | ghc 6.12.1 |
Java | OpenJDK 1.6.0_18 |
Javascript | spidermonkey 1.8.0 |
Php | PHP 5.3.3-7 |
Perl | perl 5.10.1 |
Python | python 2.6.6 |
Ruby | ruby 1.8.7 |
The Perl script introduced errors into the source code of test problems that mimic natural errors when typing programs — randomly replacing some characters, keywords and identifiers with others, increasing or decreasing the number of literals by one. A total of 136 test task implementations were tested, on the basis of which 280,000 programs containing errors were generated. 32% of them passed the compilation or syntax check without errors and warnings. 23% were successfully completed, while 6.5% gave the correct result, and 16% gave an incorrect result.
Thus, it can be said that every sixth senseless error or typo in the program code can be detected only with proper test coverage and code inspection - the compiler and the execution environment will not be able to catch it. Naturally, different languages have manifested themselves in different ways.
Static and / or strong typing languages, which is quite expected, performed best - C #, Java, C and C ++ showed very similar results - about 10% not noticed by the compiler, the best result (8%) for C ++. Haskell proved itself a little worse - about 15%. Dynamic languages have much more variation. PHP became the absolute anti-leader - in 36% of cases the interpreter launched an incorrect program without objection. It is followed by Perl with a noticeable margin of 22%, and Ruby (16%) and Python (15%) behave more strictly than others.
')
Source of