4 ms·
> unless you happen to work with binary formats and protocols ie, embedded systems and microcontrollers - which is where binary formats and bitwise operations
by Alupis 5y ago
> unless you happen to work with binary formats and protocols
ie, embedded systems and microcontrollers - which is where binary formats and bitwise operations still rule out of necessity (limited processing power, precious cycle counts per operation, limited memory and storage, etc).
I highly doubt your average web or app developer will ever need to use bitwise operations. They're harder to read and understand quickly, and none of the limitations that make bitwise operations attractive exist on devices with gigabytes of ram and terabytes of storage.
- FpUser 5y ago>"They're harder to read and understand quickly" Disagree. Never had problem with bits. Also it is one of the basics of general computing so it would not hurt to know about the subject.
- Alupis 5y agoDoesn't hurt to know it, sure, but it's entirely not useful for a large majority of developers these days. Something like: (some_var & 0x003ff000) >> 12; Or even: _displayControl &= ~DISPLAY_ON; Is not immediately clear what is going on (other than some masking and shifting is happening), and these are simple cases without a lot going on. To understand these operations, we have to figure out what's significant about these numbers, what the variables might be here, etc. It's a lot easier to understand: display.disable(); Which is what most higher-level-language developers (web, apps, even backend, and more) will use and expect to find in a codebase.
- FpUser 5y ago>"Doesn't hurt to know it, sure, but it's entirely not useful for a large majority of developers these days" I read about a lot of things that are not immediately useful for me. Still somehow it falls into nooks and crannies of my brain and helps me to solve various problem when / if need arises. I do not even remember the exact things but general understanding of what is available and how does it functions approximately. If I need details Google does the rest. >"It's a lot easier to understand: display.disable();" No arguments about this one. Even though I do work with bits sometimes I wrap those into something digestible like your example. Inlining helps not to use performance when it is needed.
- BulgarianIdiot 5y agoWhat you're saying: "In practice good modern API design prefers explicit intent over low-level details like exposing bitshifting for flags" What people are saying to you: "You say bitshifting is complex, so if I say bitshifting is simple, it means I'm smarter than you"
- FpUser 5y ago>"so if I say bitshifting is simple, it means I'm smarter than you" To BulgarianIdiot: This is quite a conclusion.