4 ms·
> I would find it extremely surprising if a regular function call in C++ took any more instructions than in JS. We're talking about Qt 'signals' though - they'
by chrisseaton 4y ago
> I would find it extremely surprising if a regular function call in C++ took any more instructions than in JS.
We're talking about Qt 'signals' though - they're sort of heavy-weight virtual call, reimplemented in C++, not regular function calls.
- int_19h 4y agoThen you should be comparing them with the direct JavaScript equivalent, which would be something like an array of functions and a foreach/invoke over that. It should also be noted that Qt signals are far from the optimal way this can be implemented in C++. On top of that, C++ itself makes it more complicated than it needs to be by not providing a bound (to receiver) member function pointer as a primitive; but even then, this can be done in two indirections. A compiler for a language that supports such a facility directly - say, Delphi - can compile it down to a single indirection.
- chrisseaton 4y ago> Then you should be comparing them with the direct JavaScript equivalent, which would be something like an array of functions and a foreach/invoke over that. But again... a JS JIT could unroll that loop, leaving with just a couple of instruction per call and no loop.
- spaetzleesser 4y agoDoes it or maybe could? I hear a lot about the miracles of JS JIT but from my experience C++ code will run circles around JS code in real world scenarios.