Hacker News new | ask | show | jobs
by zsombor 4122 days ago
In 2015 clang & gcc have a more or less working devirtualization feature that eliminates the virtual overhead in a simple benchmark such as this. The compiler sees all classes and knows that a particular interface is implemented by only one class, so it simply elides the virtual table lookup. Add that features such as speculative devirtualization that can remove a surprisingly large number of virtual calls in an established code base such as Firefox: http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00007.html

If C++ will exist in 10 years from now, I predict 'virtual' to be just yet another legacy keyword.

2 comments

>If C++ will exist in 10 years from now, I predict 'virtual' to be just yet another legacy keyword.

I really doubt that. Not so much because of the virtual call overhead, but because there's plenty of cases where you really want control over how your class objects and structs look in memory. Adding a vtable entry to every struct is something you really don't want in many cases.

Also from semantic point of view expressing which methods you are expecting to be overwritten in quite handy.
A lot of people forget about small and embedded devices.
If C++ will exist in 10 years from now

Apart from it being quite an interesting do-it-all type of language, solely seeing the huge amounts of existing codebases in 'slow' fields like production/manufacturing industries I am pretty sure it will.

Even if new applications stopped being written in C++ today, the amount of legacy code written in C++ would ensure that there would be jobs for C++ programmers for many decades to come. But of course, people will almost certainly still be writing new C++ code 10 years from now.
Just like they are still writing new COBOL.
And earning lots of money in doing so.
Indeed. I like to see it as hazard pay. Don't sell your soul for cheap.