askql
askql copied to clipboard
[askscript] Should we implement (pre) incrementation?
Javascript has both pre- and post-incrementation, useful in loops, e.g.:
let result = [];
for (let i = 1; i <= m; ++i) {
result.push(n*i);
}
How about we implement preincrementation (++i)?
@mhagmajer
I think i = i +1
is fine for now. I know that a lot of C programmers (me included) are used to ++
, however it is more difficult to read than i = i + 1
while not offering little advantage (given the current performance limitations). If I remember correctly, the popular AirBnB preset for eslint actually forbids i++
and prefers i=i+1
. Therefore I would hold on with this until we have better performance where it actually matters how this operation is done (i++
vs ++i
)
I guess in scripting languages like Javascript ++
is no longer about program performance, it's about programmer's convenience.