About ADA, C++ and C ..
From
Wisdom90@21:1/5 to
All on Sun Jan 19 17:45:16 2020
Hello,
About ADA, C++ and C ..
Ada was designed to support a high-level of abstraction and, in
particular, safe abstractions. The C philosophy is to keep the design of
the language simple, and the runtime overhead minimal, at the cost of
safety. The C++ philosophy, centered on the concept of “zero-cost abstractions,” is that as few safeguards as possible are added by the compiler, especially if those safe-guards imply a runtime cost. Ada’s philosophy tends to be at the opposite of the spectrum, favoring safety
before other criteria.
And what are zero-cost abstractions in programming languages?
Zero cost abstractions are exemplified by C++
For example a C++ std::vector object is almost like a C array except it
can grow and shrink - It has a more abstract and powerful interface than
a C array.
However the runtime performance of a vector is identical to that of an
array - the additional features in a std::vector do not cost anything at runtime if you were to replace a dynamically allocated C array with a
vector.
Most C++ features are like this - in fact it’s one of the primary considerations for a feature to be added to the language.
In C++, operator overloading, static inheritance, constexpr, templates, deterministic destruction and references are all features that introduce
a more powerful abstraction that costs nothing at runtime.
You could try writing alternative code without using that feature and it
would not be any faster.
Thank you,
Amine Moulay Ramdane.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)