Interview with Bjarne Stroustrup - abstraction and hand-crafted code
c++
Solution
"Machine model" means the ways in which the computer manifests itself in the language. So for example, C and C++ treat bytes, memory locations, pointers, integer types in more or less the same ways.
"Hand-crafted" here means equivalent code that does not use the abstraction provided in C++, and is written efficiently in C or assembly (or C++, just excluding that abstraction). This is an "aim", not a "constraint" -- C++ does not precisely achieve it in all cases.
So just as an example, `vector<int>` does not always achieve exactly the same performance as a similar resizable array written using `malloc` and `free`, because that code could (and naturally would) use `realloc` to resize the storage when necessary. `realloc` doesn't very often save you any time, but when it does it saves a chunk. `vector` cannot do that, because the allocator interface has nothing equivalent to `realloc`, and hence has introduced a small overhead. But `vector` has roughly the same performance, almost all of the time, so the aim of zero-overhead is nearly met.
For another example: with a decent C++ compiler in release mode, writing `myvector_of_int[3]` genuinely has zero overhead compared with writing `my_int_pointer[3]`. It may not be immediately obvious why accessing a data member of a local variable (the data pointer stored in `myvector_of_int`) has no overhead compared with accessing a local variable of pointer type (`my_int_pointer`), but it needn't cost anything extra.
Problem
I have read an interview with Bjarne Stroustrup on C++ and its design. I was confused by the terminology he used there so I was hoping to get some of such moments clarified. I documented my design aims and the constraints on the design in my book “The Design and Implementation of C++” and in my two History of Programming Languages conference papers, but briefly, I aim for - zero overhead compared to hand-crafted code when using abstractions, - a machine model very similar to that of C, - an extremely flexible set of abstraction mechanism, and - static type safety. - What does "hand-crafted code" mean in this case?.. Does Stroustrup mean some hand-crafted tool for an abstraction concept a programer could create? - What does "machine model" mean in this case? A way a language interact with hardware? I took a look on the book he mentioned (which is actually “The Design and Evolution of C++”, I believe) but I'm still not really sure. These two terms are also not googled very well.