The C++ Programming Language in Modern Computer Science
Total Page:16
File Type:pdf, Size:1020Kb
Shayan Shajarian THE C++ PROGRAMMING LANGUAGE IN MODERN COMPUTER SCIENCE Faculty of Information Technology and Communication Sciences (ITC) Master of Science Thesis April 2020 1 ABSTRACT Shayan Shajarian: The C++ programming language in modern computer science Master of science thesis Tampere University Information Technology April 2020 This thesis has studied the C++ programming language’s usefulness in modern computer science both in suitability for developers and education by overviewing its history and main features and comparing it to its main alternatives. The research was mainly conducted with literature reviews and methods used for studying the subject where both quantitative in form of performance analysis and qualitative in the form of analysis of non-numeric attributes. This thesis has found that the C++ programming language is a very capable programming language for overall development, but the language’s popularity has shifted towards system-level programming while the language is losing popularity for higher-level applications. The C++ programming language is also quite complex, making it too difficult to learn for beginners. Despite the complexity, the C++ programming language remains a very good language in terms of education for students of computer science because the language gives a good overview of programming as a whole. Keywords: C++, computer science, software production, education of programming The originality of this thesis has been checked using the Turnitin OriginalityCheck service. 2 TIIVISTELMÄ Shayan Shajarian: The C++ programming language in modern computer science Diplomityö Tampereen yliopisto Ohjelmistotuotanto Huhtikuu 2020 Tämä diplomityö on tutkinut C++-ohjelmointikielen hyödyllisyyttä sekä modernissa ohjelmistotuotannossa, että työkaluna tietotekniikan ja ohjelmoinnin opetukseen. Tutkimus suoritettiin tutkimalla C++-ohjelmointikielen historiaa, kielen yleisiä ominaisuuksia ja vertailemalla sitä muihin ohjelmointikieliin. Tutkimuksen menetelminä käytettiin sekä kvantitatiivisia menetelmiä kuten suorituskyvyn mittauksia, että kvalitatiivisia menetelmiä, kuten laadullisten ja ei-numeeristen attribuuttien analysointia. Tutkimuksessa C++-ohjelmointikieli on todettu hyvin kykeneväksi ohjelmointikieleksi yleiseen ohjelmistotuotantoon, mutta kielen suosio on siirtynyt korkeamman abstraktiotason tehtävistä alempaan tasoon. Opetuksen kannalta, tutkimuksessa todettiin, että C++-ohjelmointikieli on liian monimutkainen ja vaikea kieli aloittelijoille. Ohjelmoinnin opiskelijoille C++-ohjelmointikielen opiskelu on kuitenkin hyvin hyödyllistä, sillä kielen kattavuus antaa opiskelijalle hyvän kokonaiskuvan ohjelmoinnista. Avainsanat: C++, tietotekniikka, ohjelmistotuotanto, ohjelmoinnin opiskelu Tämän julkaisun alkuperäisyys on tarkastettu Turnitin OriginalityCheck –ohjelmalla. 3 PREFACE Writing this thesis has been an interesting learning experience, required using many of the skills I had acquired over the years in the university, from writing in English to study- ing the field itself. The topic for the thesis was chosen out of personal interest of computer science as a whole and the C++ programming language serving as the “protagonist” for this journey. Although writing this thesis has given me a valuable insight into the field of computer science, it feels like learning more about this subject just makes one feel how expansive the field is and how little actual knowledge I have acquired thus far. Although this thesis may mark the end of my academic career, in many ways it feels like I am only beginning to learn. I would like to thank my instructors for this thesis, professors Matti Rintala and Kari Systä. With special thanks to professor Kari Systä for helping me throughout the process and providing feedback and a valuable insight into many of the topics. Tampere, 29.04.2020 Shayan Shajarian 4 CONTENTS 1. INTRODUCTION .................................................................................................. 9 2. THEORETICAL BACKGROUND......................................................................... 11 2.1 The C++ programming language........................................................ 11 2.1.1 C++ Compilation ......................................................................... 13 2.1.2 C++ Type checking ..................................................................... 16 2.1.3 Memory management in C++ ...................................................... 19 2.1.4 Memory exploits in C++ .............................................................. 20 2.1.5 The Auto keyword ....................................................................... 18 2.2 History and development ................................................................... 21 2.3 Overview of programming paradigms ................................................. 24 2.3.1 Imperative paradigm ................................................................... 24 2.3.2 Procedural paradigm ................................................................... 24 2.3.3 Object-oriented paradigm ............................................................ 25 2.3.4 Functional programming paradigm .............................................. 25 2.3.5 The programming paradigms of the C++ language ..................... 26 2.4 Software development ....................................................................... 27 2.4.1 A Brief history of software development ...................................... 27 2.4.2 Productivity in software development .......................................... 30 2.5 Education of programming ................................................................. 31 3. RESEARCH METHODOLOGY ........................................................................... 34 3.1 Quantitative methods ......................................................................... 34 3.2 Qualitative methods ........................................................................... 34 3.3 Methods for choosing a programming language ................................. 35 4. RESULTS ........................................................................................................... 37 4.1 Comparison with other programming languages ................................ 37 4.1.1 Comparison with Java ................................................................. 38 4.1.2 Comparison with C# .................................................................... 42 4.1.3 Comparison with Python ............................................................. 46 4.1.4 Comparison with Rust ................................................................. 48 4.1.5 Conclusions from the comparisons ............................................. 50 4.2 Choosing a programming language for education .............................. 52 4.2.1 Examining the criteria selected for C++ in teaching ..................... 53 4.2.2 Examining alternative programming languages ........................... 55 4.2.3 Comparing programming languages for education ...................... 57 4.3 C++ in modern software development ................................................ 59 4.3.1 What is C++ used for today ......................................................... 59 4.3.2 C++ for the waterfall model of development ................................ 62 4.3.3 C++ in agile development ........................................................... 65 4.3.4 Improving the C++ programming language ................................. 67 5. ANALYSIS .......................................................................................................... 68 5.1 Analysis of C++ in modern computer science..................................... 68 5.1.1 Analysis of C++ in education ....................................................... 68 5.1.2 Analysis of C++ in software development ................................... 69 6. CONCLUSION .................................................................................................... 71 5 REFERENCES....................................................................................................... 74 6 LIST OF FIGURES Figure 1. Layers of abstraction in software programming languages [12] .................... 12 Figure 2. The C++ compilation process [15] ................................................................ 14 Figure 3. Memory architecture of a C++ program [47] ................................................. 19 Figure 4. Tiobe Index [39] ........................................................................................... 37 Figure 5. Compilation of Java [41] .............................................................................. 38 Figure 6. Compilation process of Java [42] ................................................................. 39 Figure 7. C# Compilation [52] ..................................................................................... 44 Figure 8. Waterfall Model [79] ..................................................................................... 62 7 LIST OF TABLES Table 1. Productivity levels [98] .................................................................................. 31 Table 2. C++ and Java performance test [45] ............................................................. 41 Table 3. C++ and C# performance test [53] ................................................................ 45 Table 4. C++ and Python performance test [60] .......................................................... 47 Table 5. C++ and Rust performance test [75]