Lightning Talk: Virtual Functions Are Not Slow - Rud Merriam - CppNorth 2023

Sdílet
Vložit
  • čas přidán 12. 10. 2023
  • www.cppnorth.ca​
    ---
    Lightning Talk: Virtual Functions Are Not Slow - Rud Merriam - CppNorth 2023
    It is frequently asserted even by C++ developers that virtual functions are slow. Actual timing shows something different.
    ---
    Slides: github.com/CppNorth/CppNorth_...
    Sponsored By:
    think-cell: www.think-cell.com/cppnorth
    JetBrains: www.jetbrains.com/
    ---
    Rudyard Merriam
    Rud Merriam is a retired software developer, having lived through the spaghetti, structured programming, and object-oriented development paradigms. He's now trying to figure out functional programming.
    Rud wrote his first FORTRAN IV in 1968 and his first C++ in 1990 with Borland's Turbo C++. Along the way, he developed computers that measured flow in real pipelines and used satellite communications to access swamps and mountaintops. He's competed with C++ in three NASA Centennial Challenges for robots on Mars and the Moon, winning some prize money along the way.
    ---
    CppNorth is an annual C++ conference held in Toronto, Canada.
    - Annual CppNorth C++ conference: cppnorth.ca/
    - CppNorth Twitter: / cppnorth
    ---
    CZcams Videos Edited & Optimised by Digital Medium: events.digital-medium.co.uk
    #cppnorth #cpp #programming
  • Věda a technologie

Komentáře • 5

  • @GreenJalapenjo
    @GreenJalapenjo Před 7 měsíci +2

    Hmm, I don't think this is completely fair. It's a bit hard to tell because the slides aren't there, but when people say "virtual functions are slow", they don't usually mean "virtual functions are slower than function pointers". Sometimes, you *need* runtime polymorphism, and virtual functions are good then (though reducing virtual calls is still good). But often, you can make a choice between runtime polymorphism and static polymorphism (e.g templates), and runtime polymorphism is usually the slower option there.

  • @thelatestartosrs
    @thelatestartosrs Před 7 měsíci

    I think the argument is more about if you have chains of virtual functions which can be avoided if you only compute the type once through your std::variant usage.

  • @babgab
    @babgab Před 7 měsíci +1

    Someone should let Casey Muratori know :D

  • @sparker2426
    @sparker2426 Před 6 měsíci

    If a switch statement is as slow as a virtual function call then the compiler isn't doing its job.

  • @higaski
    @higaski Před 7 měsíci

    Just because you can doesn't mean you should. Are you going to rewire the Arduino during runtime? Most likely no, then why pay for any overhead at all? Hardware simply isn't virtual.