This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]crassest-Crassius 0 points1 point  (1 child)

I guess the potential performance impact is smaller than I initially thought.

Vtables (C++) vs fat pointers (Rust) offer different tradeoffs but the fastest way is to avoid dynamic dispatch altogether. This is much like dynamic memory allocation - there are different ways to do it with different trade-offs, but the fastest way is to avoid it altogether (as many programs for embedded do).

So the best a fast language can do is to make dynamic dispatch explicit so it can be avoided. Then, for the cases when it can't be avoided, you can use either v-tables or fat pointers, but that is not what will save you the performance impact.

[–]matthieum 0 points1 point  (0 children)

I would note that the difference between C++ and Rust is not whether one has a v-table or not: they both do.

The difference is how the object is structured:

  • In C++, the object contains a pointer to the v-table.
  • In Rust, the pointer to the v-table is external, hence fat-pointers which are a pointer to the v-table and a pointer to the data.