An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl for a search/string-processing program

Автор: Lutz Prechelt

Дата: 10 марта 2000

Скачать текст книги в формате pdf.

Abstract

     80 implementations of the same set of requirements, created by 74 different programmers in various languages, are compared for several properties, such as run time, memory consumption, source text length, comment density, program structure, reliability, and the amount of effort required for writing them. The results indicate that, for the given programming problem, “scripting languages” (Perl, Python, Rexx, Tcl) are more productive than conventional languages. In terms of run time and memory consumption, they often turn out better than Java and not much worse than C or C++. In general, the differences between languages tend to be smaller than the typical differences due to different programmers within the same language.

 

Contents

1 On language comparisons 3

2 Origin of the programs 3

2.1 Non-script group: C, C++, Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2 Script group: Perl, Python, Rexx, Tcl . . . . . . . . . . . . . . . . .  . . . . . . . . . . . . . 4

3 Validity: Are these programs comparable? 4

3.1 Programmer capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

3.2 Work time reporting accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 5

3.3 Different task and differentwork conditions . . . . . . . . . . . . . . . . . . . . . .  . . 5

3.4 Handling a misunderstood requirement . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3.5 Other issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.6 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4 The programming problem: phonecode 7

4.1 Theprocedure description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

4.2 Taskrequirements description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4.3 Thehint . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5 Results 12

5.1 Plots and statistical methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

5.2 Number ofprograms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.3 Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.3.1 Total: z1000 data set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.3.2 Initialization phase only: z0 data set . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

5.3.3 Search phase only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5.4 Memory consumption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5.5 Program length and amount of commenting . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5.6 Program reliability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5.7 Worktime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.7.1 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.7.2 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5.7.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5.8 Programstructure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

5.9 Testing tworules of thumb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

5.10 Programmer self-rating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

6 Conclusions 28

A Rawdata 29

B Specification ambiguities 31

Bibliography 33