Zero Cost Abstractions

Zero Cost Abstractions

The idea of a zero cost abstraction is very important to certain programming languages, like Rust and C++, which intend to enable users to write programs with excellent performance profiles with relatively little effort. The idea is summarized in its original by Bjarne Stroustrup, the original developer of C++:

In this definition, there are two factors that make something a proper zero cost abstraction:

However, I think its important to keep in mind that there is a third requirement for something to be a zero cost abstraction. But we rarely achieve something so great, because its extremely difficult and involves a fair amount of luck as well (many problems probably just don’t have a really great zero cost abstraction yet to be discovered, at least within the design constraints prior decisions have put around them).

Source: boats.gitlab.io