Comment by creata

3 months ago

> hence its "zero-cost abstractions", made to give the illusion of a high-level language without its actual high-level abstraction

What does this mean?

For example (you can pick another example if you want), how is C++'s std::vector less abstract than Java's ArrayList?

Because std::vector isn't much of an abstraction, in the sense of removing a set of concerns from consideration. v[i] is just pointer math. What happens if you index outside the bounds of v is anybody's guess, and it can fail silently. You could use v.at(i), but then somebody will yell at you for using exceptions. Regardless of where you stand on C++ exceptions, the fact that it's up for debate means that it will get debated. The cost of zero-cost abstractions in C++ is quite high.

  • I assume that whatever pron had in mind would apply equally to Rust, and this does not.

    • You chose the example here. Pick a different one if it’s not what you want to talk about.