DOC PREVIEW
Stanford CS 106A - Chapter 0 - What is C++

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Chapter 0: What is C++?Chapter 0: What is C++?_________________________________________________________________________________________________________C++ is a general purpose programming language with a bias towards systems programming that• is a better C.• supports data abstraction.• supports object-oriented programming.• supports generic programming– Bjarne Stroustrup, inventor of C++ [Str09.2]Every programming language has its own distinct flavor influenced by its history and design. Before seri-ously studying a programming language, it's important to learn why the language exists and what its ob-jectives are. This chapter covers a quick history of C++, along with some of its design principles.An Abbreviated History of C++*The story of C++ begins with Bjarne Stroustrup, a Danish computer scientist working toward his PhD at Cambridge University. Stroustrup's research focus was distributed systems, software systems split across several computers that communicated over a network to solve a problem. At one point during his re-search, Stroustrup came up with a particularly clever idea for a distributed system. Because designing dis-tributed systems is an enormously complicated endeavor, Stroustrup decided to test out his idea by writ-ing a simulation program, which is a significantly simpler task. Stroustrup chose to write this simulation program in a language called Simula, one of the earliest object-oriented programming languages. As Stroustrup recalled, initially, Simula seemed like the perfect tool for the job:It was a pleasure to write that simulator. The features of Simula were almost ideal for the pur -pose, and I was particularly impressed by the way the concepts of the language helped me think about the problems in my application. The class concept allowed me to map my applica-tion concepts into the language constructs in a direct way that made my code more readable than I had seen in any other language...I had used Simula before... but was very pleasantly surprised by the way the mechanisms of the Simula language became increasingly helpful as the size of the program increased. [Str94]In Simula, it was possible to model a physical computer using a computer object and a physical network us-ing a network object, and the way that physical computers sent packets over physical networks correspon-ded to the way computer objects sent and received messages from network objects. But while Simula made it easier for Stroustrup to develop the simulator, the resulting program was so slow that it failed to produce any meaningful results. This was not the fault of Stroustrup's implementation, but of the lan-guage Simula itself. Simula was bloated and language features Stroustrup didn't use in his program were crippling the simulator's efficiency. For example, Stroustrup found that eighty percent of his program time was being spent on garbage collection despite the fact that the simulation didn't create any garbage. [Str94] In other words, while Simula had decreased the time required to build the simulator, it dramatic-ally increased the time required for the simulator to execute.Stroustrup realized that his Simula-based simulator was going nowhere. To continue his research, Strous-trup scrapped his Simula implementation and rewrote the program in a language he knew ran quickly and efficiently: BCPL. BCPL has since gone the way of the dodo, but at the time was a widely used, low-level * This section is based on information from The Design and Evolution of C++ by Bjarne Stroustrup.- 6 - Chapter 0: What is C++?systems programming language. Stroustrup later recalled that writing the simulator in BCPL was “hor-rible.” [Str94] As a low-level language, BCPL lacked objects and to represent computers and networks Stroustrup had to manually lay out and manipulate the proper bits and bytes. However, BCPL programs were far more efficient than their Simula counterparts, and Stroustrup's updated simulator worked mar-velously.Stroustrup's experiences with the distributed systems simulator impressed upon him the need for a more suitable tool for constructing large software systems. Stroustrup sought a hybridization of the best fea-tures of Simula and BCPL – a language with both high-level constructs and low-level runtime efficiency. After receiving his PhD, Stroustrup accepted a position at Bell Laboratories and began to create such a lan -guage. Settling on C as a base language, Stroustrup incorporated high-level constructs in the style of Sim-ula while still maintaining C's underlying efficiency. After several revisions, C with Classes, as his language was known, accumulated other high-level features and was officially renamed C++. C++ was an overnight success and spread rapidly into the programming community; for many years the number of C++ pro-grammers was doubling every seven months. By 2007, there were over three million C++ programmers worldwide, and despite competition from other languages like Java and Python the number of C++ pro-grammers is still increasing. [Str09] What began as Stroustrup's project at Bell Laboratories became an ISO-standardized programming language found in a variety of applications.C++ as a LanguageWhen confronted with a new idea or concept, it's often enlightening to do a quick Wikipedia search to see what others have to say on the subject. If you look up C++ this way, one of the first sentences you'll read (at least, at the time of this writing) will tell you that C++ is a general-purpose, compiled, statically-typed, multiparadigm, mid-level programming language. If you are just learning C++, this description may seem utterly mystifying. However, this sentence very aptly captures much of the spirit of C++, and so before con-tinuing our descent into the realm of C++ let's take a few minutes to go over exactly what this definition entails.C++ is a General-Purpose Programming LanguageProgramming languages can be broadly categorized into two classes – domain-specific programming lan-guages and general-purpose programming languages. A language is domain-specific if it is designed to solve a certain class of problems in a particular field. For example, the MATLAB programming language is a domain-specific language designed for numerical and mathematical computing, and so has concise and el-egant support for matrix and vector operations. Domain-specific languages tend to be extremely easy to use,


View Full Document

Stanford CS 106A - Chapter 0 - What is C++

Download Chapter 0 - What is C++
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Chapter 0 - What is C++ and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Chapter 0 - What is C++ 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?