@wallhackio It is an amazing syntax! Makes programs so much more concise... (Who ever said otherwise? )
@wallhackio I'm annoyed at Python for not having ++ and --
@vaporeon_ To quote Douglas Crockford in his 2018 book How JavaScript Works:
"I do not recommend use of the increment operators ++
or --
. They were created in antiquity for doing pointer arithmetic. We have since discovered that pointer arithmetic is harmful, so modern languages no longer allow it. The last popular language to boast of having pointer arithmetic was C++, a language so bad that it was named after ++
."
I don't agree with it but I also appreciate C++ slander so I will permit it.
@wallhackio I hate everything about this paragraph
@wallhackio This isn't C++ slander, this is C slander, and I will not allow it
@wallhackio Also: you can increment any variable with ++
, it doesn't need to be a pointer, you can just grab an integer variable and increment/decrement it, why does this guy think that they're only for pointer?
@wallhackio Does JavaScript even have pointers?
@vaporeon_ continuing the quote:
"We got rid of pointer arithmetic, but we are still stuck with ++
. Now it adds 1 to something. Why do we need a different syntactic form to add 1 than to add every other value? How does that make any sense?
The answer is: It does not make any sense.
Making matters worse, ++
has a pre-increment form and a post-increment form. It is very easy to get them reversed, and that can be very difficult to debug. And ++
has been implicated in buffer overrun errors and other security failures. We should discard features that are unnecessary and hazardous."
@vaporeon_ specifically in the case of javascript it's possible, and quite easy, to iterate over data without explicitly writing array boundaries at all. For example, the two snippets
for (let i = 0; i < arr.length; ++i) console.log(arr[i]);
and
arr.forEach((x) => console.log(x));
do the exact same thing