Introduction
Disclaimer: This course is not meant to be a comprehensive complete C++ course. It is rather meant to be an introduction to C++ for programmers with Java skills that want to start programming embedded systems.
Information: This section has been imported from https://plugins.jetbrains.com/plugin/22621-embedded-c- written by Serge Ayer.
Tips: You can use an online c++ compiler like https://www.onlinegdb.com/online_c++_compiler to try the code snippets in this course.
Java and C/C++
Although Java and C++ share some common grounds, they are essentially different in the way programmers may write programs that meet some quality standards. While C and C++ were designed for getting programs that run as fast as possible, Java’s main priority was to reduce risks of writing bad programs.
Programmers with Java skills that start programming in C++ or programmers with little programming experience must be aware that C++ is not designed to help you write correct code. Java does introduce a lot of safety checks that slow down the execution of the code. C and C++ do not execute safety checks for reaching faster execution at the price that incorrect code will not be detected at compile time and produce errors that are difficult to debug.
What is C++
C++ is a powerful programming language that is a combination of high level programming (Java) and low level programming (C). It was developed in 1979 at Bell Labs as an enhancement to the C programming language, while maintaining backward compatibility with C.
The C++ programming language is fast, just like C, and is the preferred programming language with C for embedded systems. Like Java, it provides object-oriented programming mechanisms, like classes, polymorphism, exception handling, strong typing, or templates. Among differences as compared to Java, it also offers operator overloading and does not provide built-in memory management (Garbage Collector). It is also not meant for running programs through a virtual machine.
C++ for Programming of Embedded Systems
The programs for embedded systems are usually developed at a relatively low level. The lowest level would be the Assembly language. However, for improved portability and development efficiency, C++ is often preferred. It is easier to learn, portable and allows easy handling of data structures. Although direct control and access to instructions and memory may be an advantage, it is rarely required. In addition to the advantages of the C programming language, C++ also offers the advantages of object-oriented programming, in particular encapsulation of low level concepts in portable and easy to use classes.