Doing stuff because that's the way C does it is a surefire route to unintentional autoemasculation.
Remove the ++ and –- operators
31–40 of 249 posts
Re: Remove the ++ and –- operators
#32> Their expressive advantage is minimal - x++ is not much shorter than x += 1. And there is no ++ equivalent of x += 2.
Yes. Anointing "+ 1" as a thing that needs special syntax is weird .
Its not a special syntax for "+1", its a special syntax for the combination of assignment and increment/decrement.
The postfix versions (increment/decrement variable and then return the value that was present before the increment/decrement), particularly, are equivalent to:
_x = x; x += 1; _x
In an environment where that pattern of operations is common, I can see the value of having a concise mechanism for expressing it.OTOH, there's a cost to it, too, and I'm mostly happier without them around.
Re: Remove the ++ and –- operators
#33While 4 touches on this a bit, I think another reason is that mutable value types are generally harmful. Save mutability for compiler optimizations and write your code with "let".
Re: Remove the ++ and –- operators
#34Go’s compromise here is that these operators are statements, not expressions. There is no return value. This makes it semantically identical to i += 1. It keeps some sugar while removing some classes of gotcha.
Just having `i += 1` would seem more in line with Go's professed Simplicity philosophy. When both `++i` and `i += 1` mean the same thing, you might as well drop one of them. `++i` (and/or I guess `i++`) is barely syntactic sugar.
Re: Remove the ++ and –- operators
#35Why not leave those operators for more "advanced" users? I also contest "++" and "--" operators are seriously tripping up "beginners". In most programming books, it's taught a few chapters in...
Re: Remove the ++ and –- operators
#36Re: Remove the ++ and –- operators
#37> Their expressive advantage is minimal - x++ is not much shorter than x += 1 Personal opinion, but I definitely miss '++' every time I'm doing '+=' in Python.
I think forcing me to use "+=" in Ruby reminds me that it's really a method call (which can be overridden), rather than an increment operation on primitive types.
Re: Remove the ++ and –- operators
#38Why not leave those operators for more "advanced" users? I also contest "++" and "--" operators are seriously tripping up "beginners". In most programming books, it's taught a few chapters in...
I remember the day I first saw a '++'. It was a rainy night, and I was inspecting a colleague's for loop, when suddenly a '++' operator appeared. I asked myself, "What in the holy bacon of Zeus is that?" So I looked it up in my book. My head almost exploded, and I asked myself if I should quit programming immediately. It was simply too complicated. After four months of agony and pain I finally recovered and started programming again. And yet... Sometimes, when it's raining outside, the memories come back. Programming... No, my life will never be the same again.
Re: Remove the ++ and –- operators
#39> Their expressive advantage is minimal - x++ is not much shorter than x += 1 Personal opinion, but I definitely miss '++' every time I'm doing '+=' in Python.
I think I'd argue with the "not much shorter" because it's less typing to perform a `++` versus `+=1`; I hold shift, I type the = key, obtaining the +, then I have to pause typing long enough to release the shift key, type the = key again, and now my other hand has to get involved and type a 1. And that's without the spaces.
Re: Remove the ++ and –- operators
#40Then again, my most common use for `++` was `for (;;) {}` index, and we have better in these new languages like Rust and Swift.
There are millions of people in this world trying to learn to code and understand the layers upon layers of cruft and quirks we've added. I don't mind the `++` or `--` operators, but I certainly don't mind them being gone either. They add extra complexity to code which is already arguably too complex.
In any case, I favor understandability over guesswork, and `++` is another odd cornercase which you have to mentally `grep` over.