This optimization is fantastic. And horrific at the same time. It can provide performance improvement seemingly out of thin air. And it can be a nightmare to support for anyone other than the author. What if the number of groups changes dramatically? Like, grows to 100, or 200? Or is removed entirely? What if first is replaced by 6 booleans? What if... the metadata changes completely?
My point: bitwise operations are a great tool, but it has extremely specific usage cases. I'd advice average software developers to be extremely skeptical about it (don't use it unless you know what you want to achieve and there's no better way, or it requires significant sacrifices elsewhere).
And it can be a nightmare to support for anyone other than the author.
Not really, especially if you're used to it. It is common practice to assign each flag to a constant in order to improve readability, rather than using the numbers directly.
it has extremely specific usage cases
Bitmasks are quite common in systems programming and binary file formats. Several UI toolkits (Qt, Gtk...) also use them. They can also be used to implement certain mathematical functions on machines that don't have a FPU.
There's life outside web development.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This optimization is fantastic. And horrific at the same time. It can provide performance improvement seemingly out of thin air. And it can be a nightmare to support for anyone other than the author. What if the number of groups changes dramatically? Like, grows to 100, or 200? Or is removed entirely? What if first is replaced by 6 booleans? What if... the metadata changes completely?
My point: bitwise operations are a great tool, but it has extremely specific usage cases. I'd advice average software developers to be extremely skeptical about it (don't use it unless you know what you want to achieve and there's no better way, or it requires significant sacrifices elsewhere).
Not really, especially if you're used to it. It is common practice to assign each flag to a constant in order to improve readability, rather than using the numbers directly.
Bitmasks are quite common in systems programming and binary file formats. Several UI toolkits (Qt, Gtk...) also use them. They can also be used to implement certain mathematical functions on machines that don't have a FPU.
There's life outside web development.