Is multiple dispatch the same as function overloading?

For types known at compiletime, the combination of operator overloading and templates in C++ gives something very similar to Julia (well, in reality C++ has tricks like SFINAE for generic insanity that has no Julia equivalent, and more if you count concepts in C++20). So in principle, you have much more powerful control of compile time generic programming in C++ (often at the cost of your sanity) . But…

None of that works for types that are not known at compiletime. That would require http://www.stroustrup.com/multimethods.pdf (talked about for decades, so don’t hold your breath). Static and dynamic polymorphism in C++ are incompatible and almost different languages.

Moreover, in Julia you don’t need to consider what is compile time or runtime, and it can still figure out when to devirtualize and inline (which is very difficult for C++ due to its compilation model). Much easier to reason when you can just let the compiler do its job. (post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

Edit: oops, accidentally hit the “withdraw post” on the orginal, but thought it might be worth reposting if there is anyone who finds it useful.

10 Likes