News for hackers. Stuff that matters.
Re:4B If Statements by AussieWog93 on Thursday December 28, 2023 @07:28AM (#38792793)
This is the first time I'm hearing about this guy, but not sure why there's so much hate.

It looks like he came from a non-technical background, and is trying to make the language more noob friendly.

Compare the pair:

if isEven(n) { }

if (n % 2) == 0 { }

I guarantee you my wife would have no idea what the second snippet even means.

Re:4B If Statements by numpad0 on Thursday December 28, 2023 @08:25AM (#38793222)
if !(n & 1) {} // rightmost bit(LSB) is always `true` for odd integers
Re:4B If Statements by btdmaster on Thursday December 28, 2023 @09:07AM (#38793584)
For code golf purposes, ~n&1 works fine
Re:4B If Statements by extrememacaroni on Thursday December 28, 2023 @09:05AM (#38793566)
AussieWog93 should marry this guy instead.
Re:4B If Statements by cperciva on Thursday December 28, 2023 @03:39PM (#38798307)
// FIXME: This breaks on negative numbers on ones-complement machines
Re:4B If Statements by MrJohz on Thursday December 28, 2023 @09:00AM (#38793530)
There's an argument to be made for writing functions like `isEven` and using them instead of n%2. There's an argument that the JS standard library, or other comprehensive util libraries like Lodash or Underscore should include these functions.

The problem here is introducing separate dependencies for each of these tiny functions. Dependencies are code that you haven't written, but are still your responsibility. For a lot of things, that's a good tradeoff: if you don't have the expertise in a specific area, or if you can offload work to a dependency that you trust, that's great. But for micro dependencies like this, it's usually a bad deal - you don't get anything in return (seriously, how hard is it to write your own isEven function?) but you have to rely on a third party to be secure, to not push anything accidentally broken, to not change the API, etc.

(I think it's also worth pointing out that your wife is not a paid programmer. Software development should be accessible, but this isn't the only goal, and I think it's reasonable to assume that most programmers either understand the n%2 idiom, or know enough to be able to find help on the subject.)

Re:4B If Statements by buttercraft on Thursday December 28, 2023 @10:26AM (#38794308)
The hate is deserved. This person lacks ethics.
Re:4B If Statements by wvh on Friday December 29, 2023 @09:14AM (#38805077)
Most professions require some sort of degree or license before you get to practice it. If your wife wants to develop software, she should learn the basics. Especially when her code is included in larger projects and ecosystems.

I think the criticism comes from the fact it is hard to avoid driving over badly designed bridges or avoid wasteful dependencies in the Javascript ecosystem due to the way the package management is organised, and it is felt this specific person contributes a lot to that problem.

I have no knowledge of this person, but I often avoid Javascript and NPM for exactly that reason. I'm hopeful of Deno though to fix some of that mess.