Write up on Tech Geek History : C++ Programming Language

Literature Review

As a Bell Labs employee, Bjarne Stroustrup was exposed to and appreciated the strengths of C, but also appreciated the power and convenience of higher-level languages like Simula, which had language support for object-oriented programming (OOP). Stroustrup realized that there was nothing in the nature of C that prevented it from directly supporting higher-level abstractions such as OOP or type programming. He wanted a language that provided programmers with both elegance when expressing high-level ideas and efficiency of execution size and speed. He worked on developing his own language, originally called C With Classes, which, as a superset of C, would have the control and power of portable assembler, but which also had extensions that supported the higher-level abstractions that he wanted from Simula

The extensions that he created for what would ultimately become known as C++ allowed users to define their own types. These types could behave (almost) like the built-in types provided by the language, but could also have the inheritance relationships that supported OOP

Alex Stepanov was using C++ templates to create what would even tually become known as the Standard Template Library (STL). Ste panov was exploring a paradigm he called generic programming. Generic programming is “an approach to programming that focuses on designing algorithms and data structures so that they work in the most general setting without loss of efficiency.” [FM2G] Although the STL was a departure from every other library at the time, Andrew Koenig, then the chair of the Library Working Group for the ISO C++ Standards Committee, saw the value in it and invi ted Stepanov to make a submission to the committee. Stepanov was skeptical that the committee would accept such a large proposal when it was so close to releasing the first version of the standard. Koenig asserted that Stepanov was correct. The committee would not accept it…if Stepanov didn’t submit it. Stepanov and his team created a formal specification for his library and submitted it to the committee. As expected, the committee felt that it was an overwhelming submission that came too late to be accepted

In 1998, the committee released the first ISO standard for C++. It standardized “classic” C++ with a number of nice improvements and included the STL, a library and programming paradigm clearly ahead of its time. One challenge that the Library Working Group faced was that it was tasked not to create libraries, but to standardize common usage. The problem it faced was that most libraries were either like the STL (not in common use) or they were proprietary (and therefore not good candidates for standardization).

Also in 1998, Beman Dawes, who succeeded Koenig as Library Working Group chair, worked with Dave Abrahams and a few other members of the Library Working Group to set up the Boost Libra ries.4 Boost is an open source, peer-reviewed collection of C++ libra ries,5 which may or may not be candidates for inclusion in the standard. Boost was created so that libraries that might be candidates for standardization would be vetted (hence the peer reviews) and popu larized (hence the open source). Although it was set up by members of the Standards Committee with the express purpose of developing candidates for standardiza tion, Boost is an independent project of the nonprofit Software Freedom Conservancy.6 With the release of the standard and the creation of Boost.org, it seemed that C++ was ready to take off at the end of the ʽ90s. But it didn’t work out that way

In 2011, the first major revision to Standard C++ was released, and it was very clear that the ISO Committee had not been sitting on its hands for the previous 13 years. The new standard was a major update to both the core language and the standard library.4 The update, which Bjarne Stroustrup, the creator of C++, reported “feels like a new language,”5 seemed to offer something for everyone. It had dozens of changes, some small and some fundamental, but the most important achievement was that C++ now had the features programmers expected of a modern language

After the standard was completed in 1997, several formal motions by different countries made it an international ISO and ANSI standard in 1998. The standardization process included the development of a C++ standard library. The library extends the core language to provide some general components. By using C++’s ability to program new abstract and generic types, the library provides a set of common classes and interfaces. This gives programmers a higher level of abstraction. The library provides the ability to use

• String types

 • Different data structures (such as dynamic arrays, linked lists, and binary trees)

 • Different algorithms (such as different sorting algorithms)

• Numeric classes

 • Input/output (I/O) classes

• Classes for internationalization support All of these are supported by a fairly simple programming interface. These components are very important for many programs. These days, data processing often means inputting, computing, processing, and outputting large amounts of data, which are often strings.

The core language and the library of C++ were standardized in parallel. In this way, the library could benefit from improvements in the language and the language could benefit from experiences of library implementation. In fact, during the standardization process the library often used special language features that were not yet available. C++ is not the same language it was five years ago. If you didn’t follow its evolution, you may be surprised with the new language features used by the library. This section gives you a brief overview of those new features. For details, refer to books on the language in question. While I was writing this book (in 1998), not all compilers were able to provide all of the new language features. I hope (and expect) that this will change very soon (most compiler vendors were part of the standardization process). Thus, you may be restricted in your use of the library. Portable implementations of the library typically consider whether features are present in the environment they use (they usually have some test programs to check which language features are present, and then set preprocessor directives according to the result of the check). I’ll mention any restrictions that are typical and important throughout the book by using footnotes. The following subsections describe the most important new language features that are relevant for the C++ standard library.

Almost all parts of the library are written as templates. Without template support, you can’t use the standard library. Moreover, the library needed new special template features, which I introduce after a short overview of templates. 14 dyne-book The C++ Standard Library Templates are functions or classes that are written for one or more types not yet specified. When you use a template, you pass the types as arguments, explicitly or implicitly. The following is a typical example — a function that returns the maximum of two values:

Template<Class t>

inline const T& max (const T& a, const T& b)

{

// if a<b  then use b else use a

return a < b ? b : a;

}

https://resources.jetbrains.com/storage/products/cpp/books/Cplusplus_Today.pdf

Here, the first line defines T as an arbitrary data type that is specified by the caller when the caller calls the function. You can use any identifier as a parameter name, but using T is very common, if not a de facto convention. The type is classified by class, although it does not have to be a class. You can use any data type as long as it provides the operations that the template uses.[3]

https://www.cesarkallas.net/arquivos/livros/informatica/cpp/The%20C%2B%2B%20Standard%20Library.pdf

Standard Library Algorithms What is an algorithm? A general definition of an algorithm is ‘‘a finite set of rules which gives a sequence of operations for solving a specific set of problems [and] has five important features: Finiteness … Definiteness … Input … Output … Effectiveness’’ [Knuth,1968,§1.1]. In the context of the C++standard library, an algorithm is a set of templates operating on sequences of elements. The standard library provides dozens of algorithms.

https://www.stroustrup.com/3rd_tour2.pdf

The algorithm library in the C++ Standard Library is a cornerstone for writing efficient and readable code. Algorithms are pre-defined methods that perform computations on ranges of data, which are typically specified by iterators. This aspect of the library is pivotal as it provides a standardized set of tools for operations like searching, sorting, and modifying data elements, thereby ensuring consistency and efficiency across C++ programs. One of the key advantages of using the algorithm library is its ability to abstract complex operations into simple function calls. This not only enhances code readability but also leverages highly optimized implementations that are often better than custom-built solutions. The algorithms encompass a wide range of functionalities, but some of the most commonly used categories include searching, sorting, and manipulating collections of data. Searching algorithms are fundamental for locating specific elements within a collection.

Understanding the role of iterators in the C++ Standard Library is crucial for efficiently bridging the world of algorithms and containers. Iterators are a generalized way to access elements stored in various container types, enabling a uniform approach to traverse and manipulate these elements. By understanding different types of iterators and their functionalities, developers can leverage the full power of the C++ algorithms and container classes. At its core, an iterator is an object that points to an element within a container and allows the traversal of elements without exposing the underlying structure of the container. Iterators provide an abstraction by defining how elements are accessed sequentially; they can be thought of as a generalized pointer. The five primary categories of iterators are:

  1. **Input Iterators**: Designed for reading data from the container sequentially

2. **Output Iterators**: Serve the purpose of writing data to the container sequentially

3. **Forward Iterators**: Combine the capabilities of input and output iterators, allowing read/write operations and traversal in a single direction.

 4. **Bidirectional Iterators**: Extend forward iterators to support traversal in both directions (forward and backward).

5. **Random Access Iterators**: Provide all functionalities of bidirectional iterators with additional capabilities to jump directly to any element within the container in constant time (similar to pointer arithmetic)

The C++ Standard Library offers robust support for strings, streams, and input/output (IO) operations, which are critical aspects of many applications.

The Standard Library provides several stream classes, including `std::cin`, `std::cout`, and `std::cerr`, among others.

 **Basic IO Operations:**- Input: `std::cin` is commonly used to read data from standard input, typically via the extraction operator (`>>`).

 – Output: `std::cout` outputs data to the standard output, using the insertion operator (`<

**File Streams:** The library includes `std::ifstream` and `std::ofstream` for reading from and writing to files, respectively. `std::fstream` supports both input and output operations. **File Operations:

**- Opening and Closing Files: The `open()` method accepts a filename and an optional mode (e.g., input, output, append), and the `close()` method terminates the connection with th

file.- Reading and Writing: Utilize the same operators and methods as standard IO streams (`>>` (`>>` for reading and `<  <writing )

https://cdn.bookey.app/files/pdf/book/en/the-c—standard-library.pdf

References:

https://resources.jetbrains.com/storage/products/cpp/books/Cplusplus_Today.pdf

https://www.stroustrup.com/3rd_tour2.pdf

https://cdn.bookey.app/files/pdf/book/en/the-c—standard-library.pdf

https://www.cesarkallas.net/arquivos/livros/informatica/cpp/The%20C%2B%2B%20Standard%20Library.pdf

Leave a Comment

Your email address will not be published. Required fields are marked *