4 ms·
You appear to be conflating compilers with runtimes. Dynamic dispatch happens at runtime. C++ and Rust are compile-time tools, not runtimes.
by ukj 5y ago
You appear to be conflating compilers with runtimes.
Dynamic dispatch happens at runtime.
C++ and Rust are compile-time tools, not runtimes.
- BoiledCabbage 5y agoYou are wrong. C++ supports dynamic dispatch. Please read about it on Wikipedia https://en.m.wikipedia.org/wiki/Dynamic_dispatch https://en.m.wikipedia.org/wiki/Dynamic_dispatch And for the future to not litter HN with comments like these, next time 10 different people in thread are all explaining to you why you're mistaken, take a moment to try to listen and think through what they're saying instead of just digging deeper. Having an open mind to learning something new, not just arguing a point is a great approach to life.
- ukj 5y agoYou are wrong about me being wrong. C++ is just a compiler. It outputs a binary for a target platform. The compiler does nothing for you at runtime - certainly not "type safety". Sometimes the 10 people on HN are wrong. This is one of those times.
- Jtsummers 5y agoC++ is not a compiler. C++ is a language with a specification from which people derive compilers and standard libraries and runtimes. C++ the language very much does tell you what to expect at runtime, though perhaps not everything you could ever want. I mean, it's not Haskell or Idris with their much richer type systems.
- ukj 5y agoPerfect! Please produce a piece of code (in a language such as Coq or Agda) which proves whether any given piece of random data has the type “C++ compiler” or “C++ program”. That is the epitome of static type-checking, right?
- ukj 5y agoHah! No wonder you don't grok my perspective. If you derive a C++ compiler that accepts file A as valid C++. And I derive a C++ compiler that rejects file A as valid C++, then from the lens of type theory the two compilers have different type-signatures! They are not the same formal language. One, or both compilers implement a language that is not C++.
- detaro 5y agoAnd the compiler generates the code necessary for dynamic dispatch to happen at runtime.
- ukj 5y agoBut it doesn’t static-type-check that particular code-path. Because it can’t.