Hacker News new | ask | show | jobs
by jfkebwjsbx 2266 days ago
Of course dynamic dispatch helps, but using it for a state machine is going to raise eyebrows and kill performance.
1 comments

I think this would depend on the application. Its possibly a problem in a parser of large data, but in a network protocol or business rule its not going make any difference at all.
If you are using a compiled, systems programming language like Rust, you do care about performance to begin with.

Specially in things like parsing or a network protocol!

I think what they're saying is that it literally makes no difference, not negligible difference. At some point you have to do the branching that decides which part of the logic in the state machine runs next. Dynamic dispatch is essentially just a way to do this kind of branching.