The programming language C++

by | 16 December 2021 | Basics

Anyone who wants to implement software projects or programme a system must deal with the choice of the appropriate programming language. C++ is one of the classics among the Programming languagesalthough Java has become dominant in some areas in recent years.

But what are the advantages of the programming language and what are the possible applications with regard to artificial intelligence?

A brief overview: Is C++ still up to date?

In 1979, Bjarne Stroustrup developed C++ as a further development of C. The programming language enables the creation of programs at a high level of abstraction. The efficient and machine-oriented programming is one of the advantages of the language. It is one of the most widely used programming languages - both in application programming and in system programming.

Possible uses in the development of applications include the programming of:

  • Operating systems - Windows, for example, is largely written in C, C++ and C#.
  • embedded systems - embedded computer e.g. in washing machines
  • Games - such as GTI Racing (2006)

In this sector, the programming language replaced the classic assembly languages that were used for these tasks until the 1980s. The predecessor C already showed this capability.

In application programming, C++ has been pushed back by Java as the dominant language since 2000. However, it is still used in areas that require high efficiency. This is because a major advantage of the programming language is its ability to optimally exploit given performance limits.

How was the programming language C++ developed?

Bjarne Stroustrup studied the Simula programming language while writing his doctoral thesis at Cambridge University. While he recognised the advantages of Simula in terms of its use in large software projects, he criticised the structure of the language, which was cumbersome when creating highly efficient programs. If efficient programmes were to be written, then the programming language BCPL was available - but it was not suitable for large software programmes. This situation gave rise to the desire, To develop a programming language that was suitable for large software projects and at the same time allowed for highly efficient programmes.

Further development of C with influence of Simula-67

Bjarne Stroustrup worked at AT&T Bell Laboratories and was concerned with the programming language C, which he chose as the basis for further development. Central reasons for this selection were the property as a multi-purpose language and the ability to produce fast code. Simula-67 acted as a template with regard to the design of a class concept with data encapsulation.

Bjarne Stroustrup not only developed the programming language further, he also wrote the compiler cfrontwhose first commercial version came onto the market in 1985. The compiler had the task of generating C code from "C with classes", a predecessor of C++. The extensions that were already decisive in 1983 were:

  • References,
  • Constants,
  • virtual functions,
  • overloading operators and function names
  • and the improved type checking.

Development of further functions

From the BCPL programming language, the developer took over the option of placing comments at the end of the line. This improves the readability and documentation of the programmes. The programmers use "//" to insert comments that are not translated by the compiler and serve exclusively as orientation for the human user. Especially for later analysis, it is essential in large projects to have such comments as an aid.

The first version of C++ came onto the market in 1985, the second version was published in 1989. The second version included static element functions, abstract classes and multiple inheritance. Later, the programming language received further changes, Boolean types, templates and namespaces.

Which language design is used?

The language core of the programming language consists of around 60 keywords, whereby some are used several times in different contexts. The required functionality is made possible by the standard library. These include lists, vectors and arrays. Furthermore, the standard library establishes the connection to the operating system. To increase the functionality, the use of further libraries and frameworks is possible.

Among the advantages of the programming language is the Combination of powerful language tools with machine-oriented, efficient programming. Abstract command sequences are used - both complex and simple implementation details are packed into the command sequences.

Are C and C++ compatible?

The design of the 1979 new programming language was deliberately as a further development, which laid the foundation for compatibility. However, this decision also inherited some of the disadvantages of C, which continue to exist:

  • C syntax is considered difficult to understand at times - a vice that has carried over to further development.
  • The preprocessor is obsolete, but its core remains the same in the successor version.
  • C++ programmes can often only be transferred between operating systems and different types of computers with great effort - here, too, the legacy of the past becomes clear.

How is the "Hello World!" output in C++?

One of the best-known programmes is the output of the word "Hello, world! Almost every beginner programmer creates the output of a word or sentence (mostly "Hello world!") as their first task. The following code can be seen as a solution for this task:

#include
int main() {
std::cout << "Hello world!" << std::endl;
return 0;
}

If the programme is to be executed, the above function main () is called. The programme starts here. Passing parameters are not present, they would be in the parenthesis after the keyword main. The function main () contains only one command: the output of the sentence "Hello world!

Is it easy to work with the programming language C++?

The programming language offers great opportunities and is easy to understand in its approaches. However, as with all other programming languages, it is also essential to have programmes created in a professional environment by experienced experts. The programming language is a powerful tool whose strengths must be used carefully.

In this context, reference can be made to a well-known quote by Bjarne Stroustrup:

"In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg."

Source: www.stroustrup.com/quotes.html

The programming language leads to simplification, which programmers like to use. At the same time, however, the programming language also contains many powerful tools that must be used with care. Experienced developers know how to handle these possibilities.

An example of this is the use of pointers, which is common in programming. The so-called pointers refer to the content of another variable. An example of this would be a number card that a visitor receives when handing in his jacket at the cloakroom. The number card stands for the pointer. It refers to the place where the jacket is deposited.

A pointer that has not yet been assigned a target address (in the example, a hook in the cloakroom) is set to 0. There is no variable at this point, an accidental access to it leads to a crash. Although this leads to an error at this moment, it does not trigger any further errors. If, however, the pointer refers to a random value, the programme can continue to work. A wrong value is then used, but the error is not noticed.

It is obvious that with a powerful programming language also comes a great responsibility, which is, however, mastered by experts.

Can you program artificial intelligence applications with C++?

Artificial intelligence (AI), or artificial intelligence (AI), is concerned with the task of realising machine learning and imitating human intelligence. In this way, powerful and versatile programmes are created. AI 2.0 is concerned with the goal of using AI in non-tech companies.

Artificial intelligence makes it possible to increase efficiency by automating tasks. Extensive amounts of data can be processed in this way and automated decisions can be made based on this information.

The basis for every AI programme is the programming language. C++ is particularly suitable in this area for deep learning in the edge area (the artificial intelligence is directly on the end device). This is because artificial intelligence is increasingly demanded across devices. In the process, it is necessary to implement programmes for systems that have only very limited resources available. This is because many end products are limited in terms of costs, memory size, dimensions and power consumption. C++ allows itself the greatest performance here.

Conclusion

C++ is a programming language that provides extensive tools to successfully manage large projects. Experienced developers can use C++ to create complex programmes and systems that have a wide range of applications.

A modern application area here is artificial intelligence. Since mobile devices and IoT devices in particular only have limited resources, C++ is an efficient solution. For developers, the area thus offers an exciting field of activity that makes C++ a correspondingly attractive programming language.

<a href="https://www.alexanderthamm.com/en/blog/author/at-redaktion/" target="_self">[at] EDITORIAL</a>

[at] EDITORIAL

Our AT editorial team consists of various employees who prepare the corresponding blog articles with the greatest care and to the best of their knowledge and belief. Our experts from the respective fields regularly provide you with current contributions from the data science and AI sector. We hope you enjoy reading.

0 Comments

Submit a Comment

Your email address will not be published.