3 ms·
There's a lot of discussion about "should most devs be expected to know this off the top of their head these days?" that I think misses the point entirely. A m
by majormajor 5y ago
There's a lot of discussion about "should most devs be expected to know this off the top of their head these days?" that I think misses the point entirely.
A much more relevant question is: when you are working on code that eventually needs a "give me the first 42 bits of a 64-bit value" function, do you: (a) do some basic research into binary operators since you're at least aware that binary operations are a thing, or (b) just whip up the first loop implementation that comes to mind?
If you're verifying your code anyway - which I sure hope you are when writing a delightful loop like the one in the linked article - it won't take you long to check out what the bitwise operators do.
- mypalmike 5y ago* deleted... in hindsight my silly comment doesn't add to the discussion.
- rednerrus 5y agoIsn't this what engineers that build tangible things do?
- smitty1e 5y agoConsider a spectrum ranging from "new hire" to "understands Duff's Device[1] at a glance". The code needs to default toward the former, with well-socialized exceptions. [1] https://en.m.wikipedia.org/wiki/Duff's_device https://en.m.wikipedia.org/wiki/Duff's_device