I call it making assumptions that may be incorrect, and do you know if the compiler will do the optimization anyway in this case?
Comment on I wish
mryessir@lemmy.sdf.org 1 year agoYou call it premature optimization. I call it obvious.
You use a flat head as a Phillip’s.
BeigeAgenda@lemmy.ca 1 year ago
mryessir@lemmy.sdf.org 1 year ago
What statement do you flag as assumption? Yes, I do. The modulo operator is only a subset of bit masks. It is more explicit to write:
if ( (variable &EVEN_MASK) == 0) …
To act upon even numbers then:
if ( (variable %1) == 0) …
How would you name the 1 in the above statement for more expressive power?
EVEN_MODULO_OP ? That may throw more people off imo.
kogasa@programming.dev 1 year ago
You shouldn’t rename 2 at all. “Even” has a commonly understood meaning that is instantly recognizable from
(variable %2) == 0
. The bitmask is an overgeneralization.BeigeAgenda@lemmy.ca 1 year ago
I give up, I was wrong to even think about the modulo operator, you are clearly the master programmer. 🥇
This reminds me of a discussion about the ternary operator
? :
, some people think its the one true way of writing code because its just so clear what it does. And I say please use it sparingly because if you start doing nested ternary operators its very hard to unpack what your code does, and I prefer readability over compact code, especially with today’s compilers.uranibaba@lemmy.world 1 year ago
I feel you said about JavaScript as a whole.
mrbaby@lemmy.world 1 year ago
Psh screw those people, they need to see my massive coder wang
if(!i&1){ … }
Maalus@lemmy.world 1 year ago
You can call it whatever you like, the fact of the matter remains - code readibility is more important than most optimizations you can ever hope to make.
Bad programmers optimize everything and produce code that is not understandabe and 0.001% “faster”
spudwart@spudwart.com 1 year ago
Optimization isn’t inherently better than Readable code.
What’s most important is what matters to your project.
If your project manages itself with limited resources, Optimization is better than Readable code, and it should be supplemented with comments.
If your project has a wealth of resources, readable code is probably the better option.
The “This is the ONLY WAY” mindset in coding is the only thing that I would argue is completely wrong. The “One-size fits all” mindset in development is short sighted, sure. but what makes it the worst, is when it becomes “One-Size fits all ONLY”.
“One-size fits all” means the project runs well on everything. “Optimized for one” means the project runs exceptionally on one Architecture/OS.
Basically, this situation is the highly unsatisfying “It’s your preference”.
But given the context of Yandere Dev and the Target Audience of Yandere Simulator, his code is perfect. It’s code that runs terribly on everything and the project is for no one.
droans@lemmy.world 1 year ago
Okay wow no need to get personal.