I learned that the ReScript language does not provide a modulo operator, instead, you have to use a mod() function (though, I believe it's misnamed, and it actually does remainder as well). I liked that design decision, because it made me realize how little I used modulo, and that it really didn't need to be an operator. I certainly use it, and the operator is convenient, but probably not convenient enough to pass the syntax bar we normally place on operators.
However, given that remainder is already an operator in JavaScript, the question then becomes - when people use "%" in JavaScript, are they trying to use modulo or remainder? Is "%" a potential footgun? Even if we introduced a "Math.rem()" and "Math.mod()" function, will people try to use "%" anyways, because it's consise? If so, maybe it would be worth adding a %% operator, so that developers have an operator that's equally concise as "%", that isn't a footgun.
I don't know the answer to that. But, either way, I do think introducing functions would certainly be a good first step.
First: I am a total beginner and coded just five programs with javascript (p5js) so far. I was linked here after failing to understand why % behaved (imo) so weirdly.
For what it's worth, I would really like a proper modulo function as I needed it in three of my programs so far. The main functions for me would be to:
-easily direct movement when the screen is a torus (+ moves right/down, - moves left/up)
-allow for easier implementation of mathematical structures such as principal ideal domains and irreducible polynomials
Mathematically I believe modulo has primacy over remainder, but I assume in computer science this is not so. For now I have my personal modulo function but it would be nice if it just exists.
I'm really surprised to see this claim. I use it (and see it used) all the time, especially for things like pagination. In most of those cases, the difference between mod vs remainder is either unimportant or modulo would be preferable.
For a very rough indication of how commonly it's used, GitHub JS code search for n % length gives 1.4k results, while n === length gives 1.3k results.