Re:Ask HN: Why Are Conditionals Important?
by q_eng_anon on Monday August 19, 2019 @06:39PM
(#20742444)
thanks for tying it back into quantum - also for the clarification that the way you write them doesn't matter - whether that be in terms of if/else, switch statements or actual CPU-level branch instructions.
Interestingly (but I think there is no deeper connection), vectorization uses masks to avoid branching. Programmatically, one implements then both branches at the same time, and on a per-data level different operations are performed. A simple pseudo-numpy example would be
One can write long programs following this paradigm which frequently excel at performance at GPUs and modern day CPUs (which are actually vector machines).