Google
 

Sunday, August 22, 2010

The Art of C++: leaning notes: Chapter 1-The Power of C++

  1. The Power of C++
    1. C++ is all about power:
    2. the power to control the machine at its lowest level, the power to produce highly optimized code, the power to interact directly with the operating system.
    3. With C++ you have detailed control over objects, including their creation, destruction, and inheritance; access to pointers; and support for low-level I/O.
    4. You can add new features by defining classes and overloading operators.
    5. You can construct your own libraries and hand-optimize code.
    6. You can even “break the rules” when necessary.
    7. Although C++ excels in the creation of high-performance system code, it is suitable for any type of programming task.
  2. A Terse yet Rich Syntax:
    1. C++ defines only 63 keywords
    2. First, the keywords and syntax of C++ apply to all environments in which C++ can be used. That is, the core features of C++ are universally available to all applications, independent of the execution environment.Features that are sensitive to the execution environment, such as multithreading, are left to the operating system, which is best able to handle them efficiently.
    3. Second, a streamlined, logically consistent syntax allows complex constructs to be expressed with clarity.
  3. Powerful Libraries
    1. Of course, the modern programming environment requires many features beyond those supported by the C++ keywords and syntax. C++ provides access to those features in a truly elegant way: through its standard library.
    2. Because of its reliance on library routines rather than keywords, new functionality can be added to C++ by simply expanding its library rather than by inventing new keywords.
    3. Even in its function and class libraries, C++ takes a lean, “less is more” approach, which avoids the “one-size-fits-all” trap. The libraries offer only those features that can be reasonably implemented for a wide range of programming environments.
  4. The STL (the Standard Template Library (STL).)
    1. At its core, the STL is a sophisticated set of template classes and functions that implement many popular and commonly used data structures, which the STL refers to as containers.
    2. Building on the foundation of a class library, the STL took the concept one important step further: it modularized the library into generic components that are applicable to a wide range of data. Furthermore, because the STL is extensible, you can define your own containers, add your own algorithms, and even adapt the built-in containers. The ability to extend, adapt, and reuse functionality is the essence of the software component.
  5. The Programmer Is in Control
    1. There are two competing philosophies of programming languages. One says that the language should prevent a programmer from causing problems by avoiding features that can cause problems in the first place.
    2. The second philosophy, and the one to which C++ adheres, is that “the programmer is king.” This means that the programmer is in control.
  6. Detailed Control
    1. C++ does more than just put you, the programmer, in control, it gives you detailed control.
    2. The fine-grained control that C++ gives the programmer is one reason C++ has effectively replaced assembler as the language of choice for programming system code.
  7. Operator Overloading
    1. One of the most important features in C++ is operator overloading because it supports type extensibility.
      1. Type extensibility is the attribute that enables you to add and fully integrate new data types into the C++ programming environment.Type extensibility is built on two features.
      2. The first is the class, which lets you define a new data type.
      3. The second is operator overloading, which lets you define what the various operators mean relative to a class type.
      4. Through operator overloading and classes, you can create a new data type and then operate on that type in the same way that you operate on built-in types: through operators.
    2. Type extensibility is very powerful because it makes C++ an open system rather than a closed one.
  8. A Clean, Streamlined Object Model
    1. The C++ object model is a masterpiece of brevity!
  9. The Legacy of C++
    1. Designed by Bjarne Stroustrup, C++ was built on the foundation of C.
    2. Invented by Dennis Ritchie in the 1970s, C marked the beginning of a radical transformation in programming.

No comments: